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

From: Maulik Shah
Date: Wed Apr 08 2020 - 03:09:14 EST


Hi,

On 4/8/2020 8:20 AM, Stephen Boyd wrote:
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.
Okay i will remove 'do' from this line.
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?

genpd was used in v3 and v4 of this series, where from pd's .power_off function, rpmh_flush() was invoked.

genpd can be useful if target firmware supports PSCI's OSI mode, while sc7180 is non-OSI target.

The current approch (using cpu pm notification) can be used for both OSI and non-OSI targets to invoke rpmh_flush() when last cpu goes to power down.

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?
Yes, seems it will work as well. I will change to use smp_processor_id().

+ &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;
+}
+
Thanks,
Maulik

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation