[PATCH v12 02/14] coresight: etm4x: prohibit modifying cntr_val while session is enabled

From: Yeoreum Yun

Date: Thu Sep 24 2026 - 13:47:56 EST


cntr_val is overwritten with the values read from the corresponding
registers by etm4_disable_hw() when the session is disabled.

This means that any changes to these values made while the session is
enabled would be lost when the session is disabled.

Therefore, prohibit modifying cntr_val while the session is enabled.

Tested-by: Leo Yan <leo.yan@xxxxxxx>
Signed-off-by: Yeoreum Yun <yeoreum.yun@xxxxxxx>
---
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
index db3cf4ad6806..a547de5a3f9c 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
@@ -1615,6 +1615,9 @@ static ssize_t cntr_val_store(struct device *dev,
return -EINVAL;
if (val > ETM_CNTR_MAX_VAL)
return -EINVAL;
+ if (IS_ERR_OR_NULL(drvdata->csdev) ||
+ coresight_get_mode(drvdata->csdev))
+ return -EBUSY;

raw_spin_lock(&drvdata->spinlock);
idx = config->cntr_idx;

--
2.43.0