coresight: trbe: Save/restore state across CPU low power state
PATCH v2 1/1 coresight: trbe: Save/restore state across CPU low power state
Similar to ETE, TRBE may lose its context when a CPU enters low power state. To make things worse, if ETE is restored without TRBE being restored, we have an enabled source device with no enabled sink devices, which can cause CPU hang on some devices (Pixel 9).
This patch adds sink operations to save and restore state for TRBE, and calls them when saving and restoring state for ETE. This is to ensure that we always restore the state of TRBE before ETE.
Signed-off-by Yabin Cui <[email protected]>
--- .../coresight/coresight-etm4x-core.c | 13 ++++- drivers/hwtracing/coresight/coresight-trbe.c | 58 +++++++++++++++++++ include/linux/coresight.h | 6 ++ 3 files changed, 76 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +12 -1
@@ -1863,6 +1863,7 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)static int etm4_cpu_save (struct etmv4_drvdata *drvdata) {int ret =0 ; +struct coresight_device *sink;/* Save the TRFCR irrespective of whether the ETM is ON */ if (drvdata->trfcr)
@@ -1871,8 +1872,14 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata)* 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) && drvdata->save_state) { ret =__etm4_cpu_save (drvdata); +if (ret ==0 ) { + sink =coresight_get_percpu_sink (drvdata->cpu); +if (sink &&sink_ops (sink)->percpu_save) +sink_ops (sink)->percpu_save (sink); + } + }return ret; }
@@ -1977,6 +1984,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)static void etm4_cpu_restore (struct etmv4_drvdata *drvdata) { +struct coresight_device *sink =coresight_get_percpu_sink (drvdata->cpu); + +if (sink &&sink_ops (sink)->percpu_restore) +sink_ops (sink)->percpu_restore (sink);if (drvdata->trfcr)write_trfcr (drvdata->save_trfcr);if (drvdata->state_needs_restore)
drivers/hwtracing/coresight/coresight-trbe.c +58 -0
94 lines not on this page · raw message
include/linux/coresight.h +6 -0
@@ -362,6 +362,10 @@ enum cs_mode {* @alloc_buffer: initialises perf's ring buffer for trace collection. * @free_buffer: release memory allocated in @get_config. * @update_buffer: update buffer pointers after a trace session. +* @percpu_save: saves state when CPU enters idle state. +* Only set for percpu sink. +* @percpu_restore: restores state when CPU exits idle state. +* only set for percpu sink. */ struct coresight_ops_sink { int (*enable)(struct coresight_device *csdev, enum cs_mode mode,
@@ -374,6 +378,8 @@ struct coresight_ops_sink {unsigned long (*update_buffer)(struct coresight_device *csdev,struct perf_output_handle *handle,void *sink_config); +void (*percpu_save)(struct coresight_device *csdev); +void (*percpu_restore)(struct coresight_device *csdev); };/**
Signature · 1 line
2.49.0.967.g6a0df3ecc3-goog