From: Songwei Chai <quic_songchai@quicinc.com>
To: <quic_songchai@quicinc.com>
Cc: <linux-arm-msm@vger.kernel.org>
Subject: [PATCH v4 7/7] coresight-tgu: add reset node to initialize
Date: Wed, 23 Apr 2025 14:26:51 +0800 [thread overview]
Message-ID: <20250423-tgu_patch-v4-7-92bbca66c766@quicinc.com> (raw)
In-Reply-To: <20250423-tgu_patch-v4-0-92bbca66c766@quicinc.com>
Add reset node to initialize the value of
priority/condition_decode/condition_select/timer/counter nodes
Signed-off-by: Songwei Chai <quic_songchai@quicinc.com>
---
.../ABI/testing/sysfs-bus-coresight-devices-tgu | 7 ++
drivers/hwtracing/coresight/coresight-tgu.c | 75 ++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu
index 2843cecead55f520026739731f702bf5cb66a48d..117e648d28535ef813a5d4381927acf0a4440203 100644
--- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu
+++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu
@@ -42,3 +42,10 @@ KernelVersion 6.15
Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Sam Chai (QUIC) <quic_songchai@quicinc.com>
Description:
(RW) Set/Get the counter value with specific step for TGU.
+
+What: /sys/bus/coresight/devices/<tgu-name>/reset_tgu
+Date: February 2025
+KernelVersion 6.15
+Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Sam Chai (QUIC) <quic_songchai@quicinc.com>
+Description:
+ (Write) Write 1 to reset the dataset for TGU.
diff --git a/drivers/hwtracing/coresight/coresight-tgu.c b/drivers/hwtracing/coresight/coresight-tgu.c
index 4a58f2cb8d8caf98dc29a3c5e1ce0222f15c5a6e..b44c876e7cc7e9bb6ac30cfef702e7621a29596f 100644
--- a/drivers/hwtracing/coresight/coresight-tgu.c
+++ b/drivers/hwtracing/coresight/coresight-tgu.c
@@ -477,6 +477,80 @@ static ssize_t enable_tgu_store(struct device *dev,
}
static DEVICE_ATTR_RW(enable_tgu);
+/* reset_tgu_store - Reset Trace and Gating Unit (TGU) configuration. */
+static ssize_t reset_tgu_store(struct device *dev,
+ struct device_attribute *attr, const char *buf,
+ size_t size)
+{
+ unsigned long value;
+ struct tgu_drvdata *drvdata = dev_get_drvdata(dev->parent);
+ int i, j, ret;
+
+ if (kstrtoul(buf, 0, &value) || value == 0)
+ return -EINVAL;
+
+ if (!drvdata->enable) {
+ ret = pm_runtime_get_sync(drvdata->dev);
+ if (ret < 0) {
+ pm_runtime_put(drvdata->dev);
+ return ret;
+ }
+ }
+
+ spin_lock(&drvdata->spinlock);
+ CS_UNLOCK(drvdata->base);
+
+ tgu_writel(drvdata, 0, TGU_CONTROL);
+
+ if (drvdata->value_table->priority)
+ memset(drvdata->value_table->priority, 0,
+ MAX_PRIORITY * drvdata->max_step *
+ drvdata->max_reg * sizeof(unsigned int));
+
+ if (drvdata->value_table->condition_decode)
+ memset(drvdata->value_table->condition_decode, 0,
+ drvdata->max_condition_decode * drvdata->max_step *
+ sizeof(unsigned int));
+
+ /* Initialize all condition registers to NOT(value=0x1000000) */
+ for (i = 0; i < drvdata->max_step; i++) {
+ for (j = 0; j < drvdata->max_condition_decode; j++) {
+ drvdata->value_table
+ ->condition_decode[calculate_array_location(
+ drvdata, i, TGU_CONDITION_DECODE, j)] =
+ 0x1000000;
+ }
+ }
+
+ if (drvdata->value_table->condition_select)
+ memset(drvdata->value_table->condition_select, 0,
+ drvdata->max_condition_select * drvdata->max_step *
+ sizeof(unsigned int));
+
+ if (drvdata->value_table->timer)
+ memset(drvdata->value_table->timer, 0,
+ (drvdata->max_step) *
+ (drvdata->max_timer) *
+ sizeof(unsigned int));
+
+ if (drvdata->value_table->counter)
+ memset(drvdata->value_table->counter, 0,
+ (drvdata->max_step) *
+ (drvdata->max_counter) *
+ sizeof(unsigned int));
+
+ dev_dbg(dev, "Coresight-TGU reset complete\n");
+
+ CS_LOCK(drvdata->base);
+
+ drvdata->enable = false;
+ spin_unlock(&drvdata->spinlock);
+ pm_runtime_put(drvdata->dev);
+
+ return size;
+}
+static DEVICE_ATTR_WO(reset_tgu);
+
static const struct coresight_ops_helper tgu_helper_ops = {
.enable = tgu_enable,
.disable = tgu_disable,
@@ -488,6 +562,7 @@ static const struct coresight_ops tgu_ops = {
static struct attribute *tgu_common_attrs[] = {
&dev_attr_enable_tgu.attr,
+ &dev_attr_reset_tgu.attr,
NULL,
};
--
2.34.1
next prev parent reply other threads:[~2025-04-23 6:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 6:26 [PATCH v4 0/7] Provides support for Trigger Generation Unit Songwei Chai
2025-04-23 6:26 ` [PATCH v4 1/7] dt-bindings: arm: Add support for Coresight TGU trace Songwei Chai
2025-04-23 6:26 ` [PATCH v4 2/7] coresight: Add coresight TGU driver Songwei Chai
2025-04-23 6:26 ` [PATCH v4 3/7] coresight-tgu: Add signal priority support Songwei Chai
2025-04-23 6:26 ` [PATCH v4 4/7] coresight-tgu: Add TGU decode support Songwei Chai
2025-04-23 6:26 ` [PATCH v4 5/7] coresight-tgu: add support to configure next action Songwei Chai
2025-04-23 6:26 ` [PATCH v4 6/7] coresight-tgu: add timer/counter functionality for TGU Songwei Chai
2025-04-23 6:26 ` Songwei Chai [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-04-23 6:38 [PATCH v4 0/7] Provides support for Trigger Generation Unit Songwei Chai
2025-04-23 6:38 ` [PATCH v4 7/7] coresight-tgu: add reset node to initialize Songwei Chai
2025-04-23 10:10 [PATCH v4 0/7] Provides support for Trigger Generation Unit Songwei Chai
2025-04-23 10:10 ` [PATCH v4 7/7] coresight-tgu: add reset node to initialize Songwei Chai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250423-tgu_patch-v4-7-92bbca66c766@quicinc.com \
--to=quic_songchai@quicinc.com \
--cc=linux-arm-msm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox