Re: [PATCH v10 1/8] coresight: etm4x: fix inconsistencies with sysfs configuration
From: sashiko-bot
Date: Fri Sep 11 2026 - 07:42:26 EST
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Hardware counter values (`cntr_val`) read back during trace disable are saved to the temporary runtime `active_config` instead of the sysfs-visible `config` structure, permanently losing the post-session hardware state.
--
commit 293039b149bb540c924b83cd181604cbff99de4c
Author: Yeoreum Yun <yeoreum.yun@xxxxxxx>
coresight: etm4x: fix inconsistencies with sysfs configuration
This commit addresses inconsistencies in ETM4x sysfs configuration by
separating the configuration into an active_config for the current session
and a config for sysfs. It updates the enable/disable paths to use the
active session configuration to prevent corruption from concurrent access.
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
[ ... ]
> @@ -1044,7 +1054,7 @@ static void etm4_disable_trace_unit(struct etmv4_drvdata *drvdata)
> static void etm4_disable_hw(struct etmv4_drvdata *drvdata)
> {
> u32 control;
> - struct etmv4_config *config = &drvdata->config;
> + struct etmv4_config *config = &drvdata->active_config;
> struct coresight_device *csdev = drvdata->csdev;
> struct csdev_access *csa = &csdev->access;
> int i;
[Severity: High]
Does this change cause the post-session hardware counter values to be lost?
Later in etm4_disable_hw(), the hardware counter values are read back from
the device:
/* read back the current counter values */
for (i = 0; i < caps->nr_cntr; i++) {
config->cntr_val[i] =
etm4x_relaxed_read32(csa, TRCCNTVRn(i));
}
Because config now points to drvdata->active_config, the updated counter
values are saved to the temporary active session configuration instead of
the primary sysfs configuration.
When a user subsequently reads the counter value via the sysfs interface
in cntr_val_show():
struct etmv4_config *config = &drvdata->config;
...
val = config->cntr_val[idx];
they will read from the static drvdata->config, which never receives these
read-back values and will instead return the initial configuration value.
Should the read-back hardware state be synchronized back to drvdata->config
when the trace is disabled?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911-separate_etm_cfg_v2-v10-0-1b715d95927a@xxxxxxx?part=1