On 05/03/2026 10:17, Leo Yan wrote:
Add a callback in the source device that returns a boolean indicating whether power management operations are required. The save and restore flow is skipped if the callback returns false.
The ETMv4 driver implements its own version's callback.
Reviewed-by: James Clark james.clark@linaro.org Tested-by: James Clark james.clark@linaro.org Signed-off-by: Leo Yan leo.yan@arm.com
drivers/hwtracing/coresight/coresight-core.c | 9 ++++++++- drivers/hwtracing/coresight/coresight-etm4x-core.c | 16 ++++++++++++++++ include/linux/coresight.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 5f7930ef537e2877649c404858d9fe6f593af037..6956429ca507d850c8b8c62c65de4b6fe1a1740c 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1681,7 +1681,14 @@ static bool coresight_pm_is_needed(struct coresight_device *csdev) !coresight_ops(csdev)->pm_restore_enable) return false;
- return true;
- /*
* PM callbacks are provided but pm_is_neended() is absent, it means* no extra check is needed.*/- if (!coresight_ops(csdev)->pm_is_needed)
return true;
Do we really need this call back ? The ETM can skip registering the PM ops when it is not needed (make them NULL) ? And the oresight_get_mode() is any way available for all devices and use that simply in the core function ?
Suzuki
- return coresight_ops(csdev)->pm_is_needed(csdev); }
static int coresight_pm_save(struct coresight_device *csdev) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index ab2031647616111d0689442149bcfdb0accbb218..d005983ee1e595f4ddc0b1f87596b1fbe4a0e41a 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -1861,6 +1861,21 @@ static int etm4_dying_cpu(unsigned int cpu) return 0; } +static bool etm4_need_save_restore_context(struct coresight_device *csdev) +{
- if (pm_save_enable != PARAM_PM_SAVE_SELF_HOSTED)
return false;- /*
* Save and restore the ETM Trace registers only if* the ETM is active.*/- if (coresight_get_mode(csdev))
return true;- return false;
+}
- static int __etm4_cpu_save(struct etmv4_drvdata *drvdata) { int i, ret = 0;
@@ -2136,6 +2151,7 @@ static const struct coresight_ops etm4_cs_ops = { .trace_id = coresight_etm_get_trace_id, .pm_save_disable = etm4_cpu_save, .pm_restore_enable = etm4_cpu_restore,
- .pm_is_needed = etm4_need_save_restore_context, .source_ops = &etm4_source_ops, };
diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 63d77a064d9431d512b6407946c403f5c331d086..2de2ef94d2e046effb264cc97e5cd1a61e609249 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -439,6 +439,7 @@ struct coresight_ops { struct coresight_device *sink); int (*pm_save_disable)(struct coresight_device *csdev); void (*pm_restore_enable)(struct coresight_device *csdev);
- bool (*pm_is_needed)(struct coresight_device *csdev); const struct coresight_ops_sink *sink_ops; const struct coresight_ops_link *link_ops; const struct coresight_ops_source *source_ops;