[PATCH v3 15/31] coresight: etm4x: Hook CPU PM callbacks
Mike Leach
mike.leach at linaro.org
Thu Oct 2 05:50:59 PDT 2025
On Mon, 15 Sept 2025 at 11:34, Leo Yan <leo.yan at arm.com> wrote:
>
> Since the CoreSight core layer has registered CPU PM notifiers, this
> patch hooks CPU save and restore callbacks to be invoked from the core
> layer.
>
> The CPU PM notifier in the ETMv4 driver is no longer needed, remove it
> along with its registration and unregistration code.
>
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
> drivers/hwtracing/coresight/coresight-etm4x-core.c | 73 ++++++----------------
> 1 file changed, 18 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index 7e66d094269de4a1344f5d962bc320b2603b7627..ec7e8d09ce58d62dac826fba9edafc967504a1a5 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -1186,19 +1186,6 @@ static void etm4_pause_perf(struct coresight_device *csdev)
> drvdata->paused = true;
> }
>
> -static const struct coresight_ops_source etm4_source_ops = {
> - .cpu_id = etm4_cpu_id,
> - .enable = etm4_enable,
> - .disable = etm4_disable,
> - .resume_perf = etm4_resume_perf,
> - .pause_perf = etm4_pause_perf,
> -};
> -
> -static const struct coresight_ops etm4_cs_ops = {
> - .trace_id = coresight_etm_get_trace_id,
> - .source_ops = &etm4_source_ops,
> -};
> -
> static bool cpu_supports_sysreg_trace(void)
> {
> u64 dfr0 = read_sysreg_s(SYS_ID_AA64DFR0_EL1);
> @@ -1903,8 +1890,9 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)
> return ret;
> }
>
> -static int etm4_cpu_save(struct etmv4_drvdata *drvdata)
> +static int etm4_cpu_save(struct coresight_device *csdev)
> {
> + struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
> int ret = 0;
>
> if (pm_save_enable != PARAM_PM_SAVE_SELF_HOSTED)
> @@ -1927,8 +1915,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
> etm4_enable_hw(drvdata, false);
> }
>
> -static void etm4_cpu_restore(struct etmv4_drvdata *drvdata)
> +static void etm4_cpu_restore(struct coresight_device *csdev)
> {
> + struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
> +
> if (pm_save_enable != PARAM_PM_SAVE_SELF_HOSTED)
> return;
>
> @@ -1936,38 +1926,19 @@ static void etm4_cpu_restore(struct etmv4_drvdata *drvdata)
> __etm4_cpu_restore(drvdata);
> }
>
> -static int etm4_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> - void *v)
> -{
> - struct etmv4_drvdata *drvdata;
> - unsigned int cpu = smp_processor_id();
> -
> - if (!etmdrvdata[cpu])
> - return NOTIFY_OK;
> -
> - drvdata = etmdrvdata[cpu];
> -
> - if (WARN_ON_ONCE(drvdata->cpu != cpu))
> - return NOTIFY_BAD;
> -
> - switch (cmd) {
> - case CPU_PM_ENTER:
> - if (etm4_cpu_save(drvdata))
> - return NOTIFY_BAD;
> - break;
> - case CPU_PM_EXIT:
> - case CPU_PM_ENTER_FAILED:
> - etm4_cpu_restore(drvdata);
> - break;
> - default:
> - return NOTIFY_DONE;
> - }
> -
> - return NOTIFY_OK;
> -}
> +static const struct coresight_ops_source etm4_source_ops = {
> + .cpu_id = etm4_cpu_id,
> + .enable = etm4_enable,
> + .disable = etm4_disable,
> + .resume_perf = etm4_resume_perf,
> + .pause_perf = etm4_pause_perf,
> + .save = etm4_cpu_save,
> + .restore = etm4_cpu_restore,
> +};
>
> -static struct notifier_block etm4_cpu_pm_nb = {
> - .notifier_call = etm4_cpu_pm_notify,
> +static const struct coresight_ops etm4_cs_ops = {
> + .trace_id = coresight_etm_get_trace_id,
> + .source_ops = &etm4_source_ops,
> };
>
> /* Setup PM. Deals with error conditions and counts */
> @@ -1975,16 +1946,12 @@ static int __init etm4_pm_setup(void)
> {
> int ret;
>
> - ret = cpu_pm_register_notifier(&etm4_cpu_pm_nb);
> - if (ret)
> - return ret;
> -
> ret = cpuhp_setup_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING,
> "arm/coresight4:starting",
> etm4_starting_cpu, etm4_dying_cpu);
>
> if (ret)
> - goto unregister_notifier;
> + return ret;
>
> ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
> "arm/coresight4:online",
> @@ -1998,15 +1965,11 @@ static int __init etm4_pm_setup(void)
>
> /* failed dyn state - remove others */
> cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
> -
> -unregister_notifier:
> - cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
> return ret;
> }
>
> static void etm4_pm_clear(void)
> {
> - cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
> cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
> if (hp_online) {
> cpuhp_remove_state_nocalls(hp_online);
>
> --
> 2.34.1
>
c.f. my previous comments regarding save/restore nameing and location
otherwise looks fine.
Mike
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
More information about the linux-arm-kernel
mailing list