Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3425545ybh; Mon, 16 Mar 2020 23:23:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvaKvKiDJb5yB9zyZJUs2pIFRISbSu9EljjNOB6E3GDI7eOj02TDcUXKXW7xezQnYKSPRxo X-Received: by 2002:a9d:d04:: with SMTP id 4mr2461002oti.101.1584426199268; Mon, 16 Mar 2020 23:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584426199; cv=none; d=google.com; s=arc-20160816; b=RyNUqVqMvbpqjeEKIWSZnty6G7Uf1vWidbSzI44txHClNMQclbl5EXP6ujkziE2PuH Xf5M1kF/k6i0gV+Qs6bAcz16HTNltrsaAHNxF5mPXZP+Wr4kDRvsMgNZ8GBL1Rbgtj94 XE7B0WYNUNTRa2oZxafAnyc4HwwgpccyVQWkusS1ZFGG7KeKTjJe6k+c+uOxvxgn1erI xri2wnaaUC7x7iHZVrA4zAZvKJoyULNNd9SKCIxak32XPayt8TCXSG+yjqfy53+5Tvdq vHR+s5FaHeFOeVpOyWg7Xgt985rHe6Y9/NIFlqVOQa/HfpHL12xS4EyDRSNfJCtWFqil Jk8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=w9lhdYSLOWMPREFMd9D9cQ6B7qiNBtUMMPkSRhyWHEo=; b=R6eIziJw1k3g1eXfXQ2RykkPDCxiSyNH2mExSX8dkNPjjxTqPZImczfMwmR2r5eLXe f+aQZ70JM0owYbosd6SvJ96567patQMc7DWLkN5H4pIYIoxcH0UpUoxUf0fkhJ+pX7L6 y0N+bMeDSsARhZcHQorQHJUi+hiiBbJnGUXNNzX8bYx/68DJMg7ZR2QNlACkRkngI7CG CPO1Dde4RR8SWsm1HMWV8xFudkOF7eR/HSs8UhyCMYdqATs6CtZdIgV2VCwqBBdd0/1v JNi8waGQrNiLmgXGPHND9sUM82s7752BnagV5SKBow73tcSMupoBD9HNjCUGQFEqjRSU uPqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si1189053otk.97.2020.03.16.23.23.07; Mon, 16 Mar 2020 23:23:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726421AbgCQGWl (ORCPT + 99 others); Tue, 17 Mar 2020 02:22:41 -0400 Received: from mga12.intel.com ([192.55.52.136]:53584 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbgCQGWk (ORCPT ); Tue, 17 Mar 2020 02:22:40 -0400 IronPort-SDR: kYrrwdzL0L6S7C72DeR3nlhyu3whj4NhoYeJfoZ8SmEtmZQ8SXc/SSPYpU6riLDb/UOoiHrJ31 hzilha/CGHOg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2020 23:22:40 -0700 IronPort-SDR: J4plOpkVXSuwaaBljT4MbkXKzSRokxtbrXEyAQmoKdgfD1VpMJRlCTjgR2hXAtYqyGJgzqr5jM qcSWtvEG4b7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,563,1574150400"; d="scan'208";a="445390322" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 16 Mar 2020 23:22:39 -0700 From: Alexander Shishkin To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Alexander Shishkin , Andy Shevchenko Subject: [GIT PULL 3/6] intel_th: msu: Make stopping the trace optional Date: Tue, 17 Mar 2020 08:22:12 +0200 Message-Id: <20200317062215.15598-4-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317062215.15598-1-alexander.shishkin@linux.intel.com> References: <20200317062215.15598-1-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some use cases prefer to keep collecting the trace data into the last available window while the other windows are being offloaded instead of stopping the trace. In this scenario, the window switch happens automatically when the next window becomes available again. Add an option to allow this and a sysfs attribute to enable it. Signed-off-by: Alexander Shishkin Reviewed-by: Andy Shevchenko --- .../testing/sysfs-bus-intel_th-devices-msc | 8 ++++ drivers/hwtracing/intel_th/msu.c | 37 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc b/Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc index 456cb62b384c..7fd2601c2831 100644 --- a/Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc +++ b/Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc @@ -40,3 +40,11 @@ Description: (RW) Trigger window switch for the MSC's buffer, in triggering a window switch for the buffer. Returns an error in any other operating mode or attempts to write something other than "1". +What: /sys/bus/intel_th/devices/-msc/stop_on_full +Date: March 2020 +KernelVersion: 5.7 +Contact: Alexander Shishkin +Description: (RW) Configure whether trace stops when the last available window + becomes full (1/y/Y) or wraps around and continues until the next + window becomes available again (0/n/N). + diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c index 6e118b790d83..45916b48bcf0 100644 --- a/drivers/hwtracing/intel_th/msu.c +++ b/drivers/hwtracing/intel_th/msu.c @@ -138,6 +138,7 @@ struct msc { struct list_head win_list; struct sg_table single_sgt; struct msc_window *cur_win; + struct msc_window *switch_on_unlock; unsigned long nr_pages; unsigned long single_sz; unsigned int single_wrap : 1; @@ -154,6 +155,8 @@ struct msc { struct list_head iter_list; + bool stop_on_full; + /* config */ unsigned int enabled : 1, wrap : 1, @@ -1717,6 +1720,10 @@ void intel_th_msc_window_unlock(struct device *dev, struct sg_table *sgt) return; msc_win_set_lockout(win, WIN_LOCKED, WIN_READY); + if (msc->switch_on_unlock == win) { + msc->switch_on_unlock = NULL; + msc_win_switch(msc); + } } EXPORT_SYMBOL_GPL(intel_th_msc_window_unlock); @@ -1757,7 +1764,11 @@ static irqreturn_t intel_th_msc_interrupt(struct intel_th_device *thdev) /* next window: if READY, proceed, if LOCKED, stop the trace */ if (msc_win_set_lockout(next_win, WIN_READY, WIN_INUSE)) { - schedule_work(&msc->work); + if (msc->stop_on_full) + schedule_work(&msc->work); + else + msc->switch_on_unlock = next_win; + return IRQ_HANDLED; } @@ -2050,11 +2061,35 @@ win_switch_store(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_WO(win_switch); +static ssize_t stop_on_full_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct msc *msc = dev_get_drvdata(dev); + + return scnprintf(buf, PAGE_SIZE, "%d\n", msc->stop_on_full); +} + +static ssize_t stop_on_full_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + struct msc *msc = dev_get_drvdata(dev); + unsigned long val; + int ret; + + ret = kstrtobool(buf, &msc->stop_on_full); + + return ret ? ret : size; +} + +static DEVICE_ATTR_RW(stop_on_full); + static struct attribute *msc_output_attrs[] = { &dev_attr_wrap.attr, &dev_attr_mode.attr, &dev_attr_nr_pages.attr, &dev_attr_win_switch.attr, + &dev_attr_stop_on_full.attr, NULL, }; -- 2.25.1