[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250624060438.7469-9-jie.gan@oss.qualcomm.com>
Date: Tue, 24 Jun 2025 14:04:36 +0800
From: Jie Gan <jie.gan@....qualcomm.com>
To: Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach <mike.leach@...aro.org>,
James Clark <james.clark@...aro.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Tingwei Zhang <quic_tingweiz@...cinc.com>, coresight@...ts.linaro.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-arm-msm@...r.kernel.org, devicetree@...r.kernel.org,
jie.gan@....qualcomm.com
Subject: [PATCH v3 08/10] coresight: tmc: add a switch buffer function for byte-cntr
Switching the sysfs_buf when current buffer is full or the timeout is
triggered and resets rrp and rwp registers after switched the buffer.
Disable the ETR device if it cannot find an available buffer to switch.
Signed-off-by: Jie Gan <jie.gan@....qualcomm.com>
---
.../hwtracing/coresight/coresight-tmc-etr.c | 52 +++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index 2b73bd8074bb..3e3e1b5e78ca 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -1287,6 +1287,58 @@ static struct etr_buf *tmc_etr_get_sysfs_buffer(struct coresight_device *csdev)
return ret ? ERR_PTR(ret) : drvdata->sysfs_buf;
}
+static bool tmc_byte_cntr_switch_buffer(struct tmc_drvdata *drvdata,
+ struct ctcu_byte_cntr *byte_cntr_data)
+{
+ struct etr_buf_node *nd, *next, *curr_node, *picked_node;
+ struct etr_buf *curr_buf = drvdata->sysfs_buf;
+ bool found_free_buf = false;
+
+ if (WARN_ON(!drvdata || !byte_cntr_data))
+ return found_free_buf;
+
+ /* Stop the ETR before we start the switching process */
+ if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS)
+ __tmc_etr_disable_hw(drvdata);
+
+ list_for_each_entry_safe(nd, next, &drvdata->etr_buf_list, node) {
+ /* curr_buf is free for next round */
+ if (nd->sysfs_buf == curr_buf) {
+ nd->is_free = true;
+ curr_node = nd;
+ }
+
+ if (!found_free_buf && nd->is_free && nd->sysfs_buf != curr_buf) {
+ if (nd->reading)
+ continue;
+
+ picked_node = nd;
+ found_free_buf = true;
+ }
+ }
+
+ if (found_free_buf) {
+ curr_node->reading = true;
+ curr_node->pos = 0;
+ drvdata->reading_node = curr_node;
+ drvdata->sysfs_buf = picked_node->sysfs_buf;
+ drvdata->etr_buf = picked_node->sysfs_buf;
+ picked_node->is_free = false;
+ /* Reset irq_cnt for next etr_buf */
+ atomic_set(&byte_cntr_data->irq_cnt, 0);
+ /* Reset rrp and rwp when the system has switched the buffer*/
+ CS_UNLOCK(drvdata->base);
+ tmc_write_rrp(drvdata, 0);
+ tmc_write_rwp(drvdata, 0);
+ CS_LOCK(drvdata->base);
+ /* Restart the ETR when we find a free buffer */
+ if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS)
+ __tmc_etr_enable_hw(drvdata);
+ }
+
+ return found_free_buf;
+}
+
static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
{
int ret = 0;
--
2.34.1
Powered by blists - more mailing lists