Re: [PATCH 1/4] coresight/etm4x: disallow altering config via sysfs while enabled

From: Suzuki K Poulose
Date: Thu Jan 09 2025 - 06:47:03 EST


Hi Levi,

On 21/12/2024 16:59, Yeoreum Yun wrote:
When etm4x configuration is modified via sysfs while etm4x is being
enabled via perf, enabled etm4x could run with different configuration
from perf_event.

To address this, disallow altering config via sysfs while csdev is enabled.

Signed-off-by: Yeoreum Yun <yeoreum.yun@xxxxxxx>
---
.../coresight/coresight-etm4x-sysfs.c | 132 +++++++++++++++++-
1 file changed, 128 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
index 11e865b8e824..cc1f112921d7 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
@@ -174,6 +174,9 @@ static ssize_t reset_store(struct device *dev,
if (kstrtoul(buf, 16, &val))
return -EINVAL;
+ if (coresight_get_mode(drvdata->csdev))
+ return -EBUSY;
+

Is it not better to have separate "configs" for perf and sysfs ?
And etmX driver can populate the "running" config, based on the
mode specific config. That way, the configs can be updated
independently without affecting the running config or the perf one.

Suzuki