Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp145507lqr; Wed, 5 Jun 2024 01:25:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXenVWBVWPuXeigMT2DO9HM6TlCpm2bItAKZiiOWvf2Xaso8lEDp5Cw6n7RRN2i79smhI+IoKAzGTq1rFNo2zhySZocxGEvH7/XZB0Wag== X-Google-Smtp-Source: AGHT+IHHYwnCDJjIDssPc4f4fZkB8PEeUcu9h4EedKAM6EwvC0+GIulIeu7iNhvcOzmq2gAXubuw X-Received: by 2002:a67:f9ce:0:b0:48b:ab60:e71f with SMTP id ada2fe7eead31-48c0483c2bcmr2064474137.9.1717575908995; Wed, 05 Jun 2024 01:25:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717575908; cv=pass; d=google.com; s=arc-20160816; b=UCrASPsDUgqvpnWpbKmKOjI/BQE0G7M7OLn0HGNS2y3NQqg02VlIbUZz1UIWX2n5v8 RCYVClkw4B0c8zMRWhQGtoy1fF2aCSumsv4bt2k5h8z27WnmxTShxIBNIOIt9MwWxixF Q24Nr2rBMTMF+VM0bpTu8pFzYP3xp7FXs0vFwq+ih6bs9ArQq4PZvTnVqScAO8oc8GFF CZa42HHvDPlStm7lPDogSoGMmopk/SYSGU6qzd7GqkXE0cuDfYeC3f53RWBPSh1ZPdvQ J3ttdfp0Cztd7gIaA79OvZTDFM38xQktpWci3JhhUYwTv36cp8/f1Kv+prA5+hQzFvga 541A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FlSxrikqovQUj05g9nd1zRdxavMfM9DsAoZ3542vhlw=; fh=Lmcwnbrzc6iXxb3h/s4EQlBYs2WnsA2bZNBJIYM8/3Y=; b=hKpUJAldznFg691DB9s1GkKwci8HI4WpcpK/jZsj2nBYBHD2R9Iq4e4KCUlJORkoeZ qa+HZyEyJTdZi1mWGBTP86VlOkpWWXH2LAy9wbplY7WMTKseOEcSGmWrZgm28SIuibyt T9Fn5nJHwOnO7OdxPNv5Lb3ZgslDT0kgBYBE5dFg4YBc2rfdHBl/DQMvWJzLG9FNcOAc xG40Mx8IS0R68eZX2n87l8Rz3TlV52yEkphc6SnBFBe3spU/FcSAbKpW+BV2ib7pg/qx b+4EWt+JPX/BRcTK1q4YVerX2OpIobHGtYm03WgWTjhBA5cQO5Abnwm6w1esItNMIOQZ 1mFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=T6entOlv; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-201982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201982-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794f3063a97si442550685a.344.2024.06.05.01.25.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 01:25:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=T6entOlv; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-201982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201982-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A6EF61C209B0 for ; Wed, 5 Jun 2024 08:25:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7763E18FDB7; Wed, 5 Jun 2024 08:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="T6entOlv" Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0CEC199237; Wed, 5 Jun 2024 08:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717575527; cv=none; b=WDvl8+mlK1lcr8G3Pstg2/bnQzKxlkA1QJ1XTNOVIbuytMTwHc9ik9YtaWzSvVjliYd1TZSA4EW3kpwp+RdK14CRGpCieBtvzuIVnzpGVjQosgzXX9IGij+1VE0IxFRVv8B+OV8W7BTj4CEJpkTWZL3/eLw1JHDEyRbOGomD8mM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717575527; c=relaxed/simple; bh=bOapuxABj3fjSFCLKXs51xoWUEDvB/IzrHXNCOBtG+w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VK1682ZTpD98JU6ZMciduyyXPjPxL/MMvUkHwbz3kaA/ClRkAdneNyAhcMdi4r5In8L5YO3pvNUB78vR6jI+9Q1pvXpBCGqDRGx4CUbHhd/31ekZWd96bblJCYpHNS5qD4E1MtKqUtxeS1Qn3iAyUpOvde3JGgWrktmGzMyRHDc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=T6entOlv; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 454KRqZa004139; Wed, 5 Jun 2024 01:18:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=F lSxrikqovQUj05g9nd1zRdxavMfM9DsAoZ3542vhlw=; b=T6entOlvg6ij2JUFa F/yw4NX9JSKkUIAuP1Dyq36z05RHQdoQFPcFDZY50rSjCkk1TRMc3AYXyikpUTyl 2nJMoNtyJ3u0uwhOFtCoKQOYVnUtXxvgrjiJXdAdsk2Fv2qr33ZYylgCcaw7iwdA igBzqkrPOHDguGmoxALLX+svo0KvhMjgunHLscwvhOkjY8TSse2FOsPfwZet5u+D +HoynAEprrKIlUWl7IN6ZPXWNBRAkQDHPE0hp3qaj+GquoVFOnIqUR0uoH8IdoEm xggkDazuLfbq0I41qWux7aXa2KHl0CEmf5vxamKFDLkGJ0AoLIZ4VUDh4pwdRkcx F1G5w== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3yj167cf60-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 01:18:13 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 5 Jun 2024 01:18:08 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 5 Jun 2024 01:18:08 -0700 Received: from virtx40.. (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id 146173F706A; Wed, 5 Jun 2024 01:18:03 -0700 (PDT) From: Linu Cherian To: , , CC: , , , , , , , , , Linu Cherian Subject: [PATCH v9 6/7] coresight: tmc: Stop trace capture on FlIn Date: Wed, 5 Jun 2024 13:47:24 +0530 Message-ID: <20240605081725.622953-7-lcherian@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605081725.622953-1-lcherian@marvell.com> References: <20240605081725.622953-1-lcherian@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: wjhn0vQR0mdRJQ2TFRsl672bKaqG3DVO X-Proofpoint-GUID: wjhn0vQR0mdRJQ2TFRsl672bKaqG3DVO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-04_11,2024-06-05_01,2024-05-17_01 Configure TMC ETR and ETF to flush and stop trace capture on FlIn event based on sysfs attribute, /sys/bus/coresight/devices/tmc_etXn/stop_on_flush. Signed-off-by: Linu Cherian --- Changelog from v8: Removed redundant stop_on_flush_en variable. .../hwtracing/coresight/coresight-tmc-core.c | 31 +++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etf.c | 12 ++++--- .../hwtracing/coresight/coresight-tmc-etr.c | 12 ++++--- drivers/hwtracing/coresight/coresight-tmc.h | 2 ++ 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c index 0c145477ba66..d1101f336160 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-core.c +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c @@ -454,9 +454,40 @@ static ssize_t buffer_size_store(struct device *dev, static DEVICE_ATTR_RW(buffer_size); +static ssize_t stop_on_flush_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent); + + return sprintf(buf, "%#x\n", drvdata->stop_on_flush); +} + +static ssize_t stop_on_flush_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + int ret; + u8 val; + struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent); + + ret = kstrtou8(buf, 0, &val); + if (ret) + return ret; + if (val) + drvdata->stop_on_flush = true; + else + drvdata->stop_on_flush = false; + + return size; +} + +static DEVICE_ATTR_RW(stop_on_flush); + + static struct attribute *coresight_tmc_attrs[] = { &dev_attr_trigger_cntr.attr, &dev_attr_buffer_size.attr, + &dev_attr_stop_on_flush.attr, NULL, }; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index a8cabbf6679b..27ddf83e6ec8 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -19,6 +19,7 @@ static int tmc_set_etf_buffer(struct coresight_device *csdev, static int __tmc_etb_enable_hw(struct tmc_drvdata *drvdata) { int rc = 0; + u32 ffcr; CS_UNLOCK(drvdata->base); @@ -32,10 +33,12 @@ static int __tmc_etb_enable_hw(struct tmc_drvdata *drvdata) } writel_relaxed(TMC_MODE_CIRCULAR_BUFFER, drvdata->base + TMC_MODE); - writel_relaxed(TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI | - TMC_FFCR_FON_FLIN | TMC_FFCR_FON_TRIG_EVT | - TMC_FFCR_TRIGON_TRIGIN, - drvdata->base + TMC_FFCR); + + ffcr = TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI | TMC_FFCR_FON_FLIN | + TMC_FFCR_FON_TRIG_EVT | TMC_FFCR_TRIGON_TRIGIN; + if (drvdata->stop_on_flush) + ffcr |= TMC_FFCR_STOP_ON_FLUSH; + writel_relaxed(ffcr, drvdata->base + TMC_FFCR); writel_relaxed(drvdata->trigger_cntr, drvdata->base + TMC_TRG); tmc_enable_hw(drvdata); @@ -225,7 +228,6 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev) used = true; drvdata->buf = buf; } - ret = tmc_etb_enable_hw(drvdata); if (!ret) { coresight_set_mode(csdev, CS_MODE_SYSFS); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index b12ae7cc3372..d8889282abcd 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1059,7 +1059,7 @@ static void tmc_sync_etr_buf(struct tmc_drvdata *drvdata) static int __tmc_etr_enable_hw(struct tmc_drvdata *drvdata) { - u32 axictl, sts; + u32 axictl, sts, ffcr; struct etr_buf *etr_buf = drvdata->etr_buf; int rc = 0; @@ -1105,10 +1105,12 @@ static int __tmc_etr_enable_hw(struct tmc_drvdata *drvdata) writel_relaxed(sts, drvdata->base + TMC_STS); } - writel_relaxed(TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI | - TMC_FFCR_FON_FLIN | TMC_FFCR_FON_TRIG_EVT | - TMC_FFCR_TRIGON_TRIGIN, - drvdata->base + TMC_FFCR); + ffcr = TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI | TMC_FFCR_FON_FLIN | + TMC_FFCR_FON_TRIG_EVT | TMC_FFCR_TRIGON_TRIGIN; + if (drvdata->stop_on_flush) + ffcr |= TMC_FFCR_STOP_ON_FLUSH; + writel_relaxed(ffcr, drvdata->base + TMC_FFCR); + writel_relaxed(drvdata->trigger_cntr, drvdata->base + TMC_TRG); tmc_enable_hw(drvdata); diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h index 6102eea3fc79..49bd36e5062e 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -206,6 +206,7 @@ struct tmc_resrv_buf { * @spinlock: only one at a time pls. * @pid: Process ID of the process being monitored by the session * that is using this component. + * @stop_on_flush: Stop on flush trigger user configuration. * @buf: Snapshot of the trace data for ETF/ETB. * @etr_buf: details of buffer used in TMC-ETR * @len: size of the available trace for ETF/ETB. @@ -240,6 +241,7 @@ struct tmc_drvdata { spinlock_t spinlock; pid_t pid; bool reading; + bool stop_on_flush; union { char *buf; /* TMC ETB */ struct etr_buf *etr_buf; /* TMC ETR */ -- 2.34.1