]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: etm4x: Remove the state_needs_restore flag
authorLeo Yan <leo.yan@arm.com>
Tue, 11 Nov 2025 18:58:42 +0000 (18:58 +0000)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Wed, 12 Nov 2025 16:53:19 +0000 (16:53 +0000)
When the restore flow is invoked, it means no error occurred during the
save phase. Otherwise, if any errors happened while saving the context,
the function would return an error and abort the suspend sequence.

Therefore, the state_needs_restore flag is unnecessary. The save and
restore functions are changed to check two conditions:

1) The global flag pm_save_enable is SELF_HOSTED mode;
2) The device is in active mode (non DISABLED).

Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Reviewed-by: Mike Leach <mike.leach@linaro.org>
Tested-by: James Clark <james.clark@linaro.org>
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/20251111-arm_coresight_power_management_fix-v6-8-f55553b6c8b3@arm.com
drivers/hwtracing/coresight/coresight-etm4x-core.c
drivers/hwtracing/coresight/coresight-etm4x.h

index bdf5ab85b2213dfd601391fdcf50960667fa7cea..560975b70474c3449aa6799fc1a8e05d5ea93495 100644 (file)
@@ -1966,8 +1966,6 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)
                goto out;
        }
 
-       drvdata->state_needs_restore = true;
-
        /*
         * Power can be removed from the trace unit now. We do this to
         * potentially save power on systems that respect the TRCPDCR_PU
@@ -1985,11 +1983,14 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata)
 {
        int ret = 0;
 
+       if (pm_save_enable != PARAM_PM_SAVE_SELF_HOSTED)
+               return 0;
+
        /*
         * Save and restore the ETM Trace registers only if
         * the ETM is active.
         */
-       if (coresight_get_mode(drvdata->csdev) && drvdata->save_state)
+       if (coresight_get_mode(drvdata->csdev))
                ret = __etm4_cpu_save(drvdata);
        return ret;
 }
@@ -2079,8 +2080,6 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
        if (!drvdata->skip_power_up)
                etm4x_relaxed_write32(csa, state->trcpdcr, TRCPDCR);
 
-       drvdata->state_needs_restore = false;
-
        /*
         * As recommended by section 4.3.7 ("Synchronization when using the
         * memory-mapped interface") of ARM IHI 0064D
@@ -2099,7 +2098,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
 
 static void etm4_cpu_restore(struct etmv4_drvdata *drvdata)
 {
-       if (drvdata->state_needs_restore)
+       if (pm_save_enable != PARAM_PM_SAVE_SELF_HOSTED)
+               return;
+
+       if (coresight_get_mode(drvdata->csdev))
                __etm4_cpu_restore(drvdata);
 }
 
index b8796b4271025f6aba79fe3cd6e4d17d0b56952d..012c52fd19338133129752d35523dc102df24604 100644 (file)
@@ -980,7 +980,6 @@ struct etmv4_save_state {
  *             in EL2. Otherwise, 0.
  * @config:    structure holding configuration parameters.
  * @save_state:        State to be preserved across power loss
- * @state_needs_restore: True when there is context to restore after PM exit
  * @skip_power_up: Indicates if an implementation can skip powering up
  *                the trace unit.
  * @paused:    Indicates if the trace unit is paused.
@@ -1036,7 +1035,6 @@ struct etmv4_drvdata {
        u64                             trfcr;
        struct etmv4_config             config;
        struct etmv4_save_state         *save_state;
-       bool                            state_needs_restore;
        bool                            skip_power_up;
        bool                            paused;
        DECLARE_BITMAP(arch_features, ETM4_IMPDEF_FEATURE_MAX);