[PATCH v12 01/14] coresight: etm4x: read-back TRCSEQSTR at disabling and prohibit modifying seq_state while enabling.
Mike Leach
mike.leach at arm.com
Tue Sep 29 03:40:05 PDT 2026
Reviewed-by: Mike Leach <mike.leach at arm.com>
On 9/24/26 18:33, Yeoreum Yun wrote:
> TRCSEQSTR can be changed by the ETM while a session is active. Its value
> therefore needs to be preserved when a sysfs session is disabled so that
> users can read the current sequence state after the session ends.
>
> This means that any changes made to TRCSEQSTR while the sysfs-session is active
> would be lost when the session is disabled.
>
> Copy the TRCSEQSTR value when disabling a sysfs session, and prohibit
> modifying seq_state while the session is active.
>
> Suggested-by: Mike Leach <mike.leach at arm.com>
> Signed-off-by: Yeoreum Yun <yeoreum.yun at arm.com>
> ---
> drivers/hwtracing/coresight/coresight-etm4x-core.c | 4 ++++
> drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 2 ++
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index 2247ad55d444..9ca03a5913a3 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -1073,6 +1073,10 @@ static void etm4_disable_hw(struct etmv4_drvdata *drvdata)
> etm4x_relaxed_read32(csa, TRCCNTVRn(i));
> }
>
> + /* read back the sequence state */
> + if (drvdata->nrseqstate)
> + config->seq_state = etm4x_relaxed_read32(csa, TRCSEQSTR);
> +
> coresight_disclaim_device_unlocked(csdev);
> etm4_cs_lock(drvdata, csa);
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> index cc6cdd3ae29d..db3cf4ad6806 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> @@ -1437,6 +1437,8 @@ static ssize_t seq_state_store(struct device *dev,
> return -EINVAL;
> if (val >= drvdata->nrseqstate)
> return -EINVAL;
> + if (IS_ERR_OR_NULL(drvdata) || coresight_get_mode(drvdata->csdev))
> + return -EBUSY;
>
> config->seq_state = val;
> return size;
>
More information about the linux-arm-kernel
mailing list