]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: etm3x: Set active path on target CPU
authorLeo Yan <leo.yan@arm.com>
Fri, 15 May 2026 20:08:28 +0000 (21:08 +0100)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Mon, 18 May 2026 09:18:46 +0000 (10:18 +0100)
Set the path pointer on the target CPU during ETM enable and disable.

This ensures the device mode and path pointer are updated together and
observed atomically by the CPU PM notifier.

Tested-by: James Clark <james.clark@linaro.org>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Tested-by: Jie Gan <jie.gan@oss.qualcomm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260515-arm_coresight_path_power_management_improvement-v14-21-f88c4a3ecfe9@arm.com
drivers/hwtracing/coresight/coresight-etm3x-core.c

index aeeb284abdbe4b6a0960da45baa1138e203f3e3c..c6fe8b25b855a4119110fee4162f55c0154c3d05 100644 (file)
@@ -441,6 +441,7 @@ done:
 
 struct etm_enable_arg {
        struct etm_drvdata *drvdata;
+       struct coresight_path *path;
        int rc;
 };
 
@@ -462,8 +463,12 @@ static void etm_enable_sysfs_smp_call(void *info)
        arg->rc = etm_enable_hw(arg->drvdata);
 
        /* The tracer didn't start */
-       if (arg->rc)
+       if (arg->rc) {
                coresight_set_mode(csdev, CS_MODE_DISABLED);
+               return;
+       }
+
+       csdev->path = arg->path;
 }
 
 void etm_release_trace_id(struct etm_drvdata *drvdata)
@@ -492,10 +497,13 @@ static int etm_enable_perf(struct coresight_device *csdev,
        ret = etm_enable_hw(drvdata);
 
        /* Failed to start tracer; roll back to DISABLED mode */
-       if (ret)
+       if (ret) {
                coresight_set_mode(csdev, CS_MODE_DISABLED);
+               return ret;
+       }
 
-       return ret;
+       csdev->path = path;
+       return 0;
 }
 
 static int etm_enable_sysfs(struct coresight_device *csdev, struct coresight_path *path)
@@ -514,6 +522,7 @@ static int etm_enable_sysfs(struct coresight_device *csdev, struct coresight_pat
         */
        if (cpu_online(drvdata->cpu)) {
                arg.drvdata = drvdata;
+               arg.path = path;
                ret = smp_call_function_single(drvdata->cpu,
                                               etm_enable_sysfs_smp_call, &arg, 1);
                if (!ret)
@@ -583,6 +592,7 @@ static void etm_disable_sysfs_smp_call(void *info)
 
        etm_disable_hw(drvdata);
 
+       drvdata->csdev->path = NULL;
        coresight_set_mode(drvdata->csdev, CS_MODE_DISABLED);
 }
 
@@ -607,6 +617,7 @@ static void etm_disable_perf(struct coresight_device *csdev)
 
        CS_LOCK(drvdata->csa.base);
 
+       drvdata->csdev->path = NULL;
        coresight_set_mode(drvdata->csdev, CS_MODE_DISABLED);
 
        /*