Re: [PATCH v16 4/6] soc: qcom: rpmh: Invoke rpmh_flush() for dirty caches

From: Stephen Boyd
Date: Tue Apr 07 2020 - 22:50:49 EST


Quoting Maulik Shah (2020-04-05 23:32:19)
> Add changes to invoke rpmh flush() from CPU PM notification.
> This is done when the last the cpu is entering power collapse and
> controller is not busy.
>
> Controllers that do have 'HW solver' mode do not need to register

Controllers that have 'HW solver' mode don't need to register? The 'do
have' is throwing me off.

> for CPU PM notification. They may be in autonomous mode executing
> low power mode and do not require rpmh_flush() to happen from CPU
> PM notification.
>
> Signed-off-by: Maulik Shah <mkshah@xxxxxxxxxxxxxx>
> Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
> ---
> drivers/soc/qcom/rpmh-internal.h | 25 +++++---
> drivers/soc/qcom/rpmh-rsc.c | 123 +++++++++++++++++++++++++++++++++++----
> drivers/soc/qcom/rpmh.c | 26 +++------
> 3 files changed, 137 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
> index b718221..fbe1f3e 100644
> --- a/drivers/soc/qcom/rpmh-rsc.c
> +++ b/drivers/soc/qcom/rpmh-rsc.c
> @@ -6,6 +6,7 @@
[...]
> +
> +static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb,
> + unsigned long action, void *v)
> +{
> + struct rsc_drv *drv = container_of(nfb, struct rsc_drv, rsc_pm);
> + int ret = NOTIFY_OK;
> +
> + spin_lock(&drv->pm_lock);
> +
> + switch (action) {
> + case CPU_PM_ENTER:

I thought CPU_PM notifiers weren't supposed to be used anymore? Or at
least, the genpd work that has gone on for cpuidle could be used here in
place of CPU_PM notifiers? And so this isn't actually any different
than what was proposed originally to use genpd for this?

> + cpumask_set_cpu(raw_smp_processor_id(),

Why do we need to use raw_smp_processor_id()? smp_processor_id() should
work just as well?

> + &drv->cpus_entered_pm);
> +
> + if (!cpumask_equal(&drv->cpus_entered_pm, cpu_online_mask))
> + goto exit;
> + break;
> + case CPU_PM_ENTER_FAILED:
> + case CPU_PM_EXIT:
> + cpumask_clear_cpu(raw_smp_processor_id(),
> + &drv->cpus_entered_pm);
> + goto exit;
> + }
> +
> + ret = rpmh_rsc_ctrlr_is_busy(drv);
> + if (ret) {
> + ret = NOTIFY_BAD;
> + goto exit;
> + }
> +
> + ret = rpmh_flush(&drv->client);
> + if (ret)
> + ret = NOTIFY_BAD;
> + else
> + ret = NOTIFY_OK;
> +
> +exit:
> + spin_unlock(&drv->pm_lock);
> + return ret;
> +}
> +