2020-04-22 21:58:04

by Doug Anderson

[permalink] [raw]
Subject: [PATCH v4 1/5] soc: qcom: rpmh-rsc: Corrently ignore CPU_CLUSTER_PM notifications

Our switch statement doesn't have entries for CPU_CLUSTER_PM_ENTER,
CPU_CLUSTER_PM_ENTER_FAILED, and CPU_CLUSTER_PM_EXIT and doesn't have
a default. This means that we'll try to do a flush in those cases but
we won't necessarily be the last CPU down. That's not so ideal since
our (lack of) locking assumes we're on the last CPU.

Luckily this isn't as big a problem as you'd think since (at least on
the SoC I tested) we don't get these notifications except on full
system suspend. ...and on full system suspend we get them on the last
CPU down. That means that the worst problem we hit is flushing twice.
Still, it's good to make it correct.

Fixes: 985427f997b6 ("soc: qcom: rpmh: Invoke rpmh_flush() for dirty caches")
Reported-by: Stephen Boyd <[email protected]>
Signed-off-by: Douglas Anderson <[email protected]>
---

Changes in v4:
- ("...Corrently ignore CPU_CLUSTER_PM notifications") split out for v4.

Changes in v3: None
Changes in v2: None

drivers/soc/qcom/rpmh-rsc.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index a9e15699f55f..3571a99fc839 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -806,6 +806,8 @@ static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb,
case CPU_PM_EXIT:
cpumask_clear_cpu(smp_processor_id(), &drv->cpus_entered_pm);
goto exit;
+ default:
+ return NOTIFY_DONE;
}

ret = rpmh_rsc_ctrlr_is_busy(drv);
--
2.26.1.301.g55bc3eb7cb9-goog


2020-04-22 21:59:28

by Doug Anderson

[permalink] [raw]
Subject: [PATCH v4 3/5] kernel/cpu_pm: Fix uninitted local in cpu_pm

cpu_pm_notify() is basically a wrapper of notifier_call_chain().
notifier_call_chain() doesn't initialize *nr_calls to 0 before it
starts incrementing it--presumably it's up to the callers to do this.

Unfortunately the callers of cpu_pm_notify() don't init *nr_calls.
This potentially means you could get too many or two few calls to
CPU_PM_ENTER_FAILED or CPU_CLUSTER_PM_ENTER_FAILED depending on the
luck of the stack.

Let's fix this.

Fixes: ab10023e0088 ("cpu_pm: Add cpu power management notifiers")
Signed-off-by: Douglas Anderson <[email protected]>
---

Changes in v4: None
Changes in v3: None
Changes in v2:
- ("Fix uninitted local in cpu_pm") new for v2.

kernel/cpu_pm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c
index cbca6879ab7d..44a259338e33 100644
--- a/kernel/cpu_pm.c
+++ b/kernel/cpu_pm.c
@@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_unregister_notifier);
*/
int cpu_pm_enter(void)
{
- int nr_calls;
+ int nr_calls = 0;
int ret = 0;

ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls);
@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_exit);
*/
int cpu_cluster_pm_enter(void)
{
- int nr_calls;
+ int nr_calls = 0;
int ret = 0;

ret = cpu_pm_notify(CPU_CLUSTER_PM_ENTER, -1, &nr_calls);
--
2.26.1.301.g55bc3eb7cb9-goog

2020-04-23 04:48:58

by Maulik Shah

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] soc: qcom: rpmh-rsc: Corrently ignore CPU_CLUSTER_PM notifications

Hi,

there is a typo in subject, Corrently to correctly.
Other than this, fix seems good to me.

Reviewed-by: Maulik Shah <[email protected]>

Thanks,
Maulik

On 4/23/2020 3:24 AM, Douglas Anderson wrote:
> Our switch statement doesn't have entries for CPU_CLUSTER_PM_ENTER,
> CPU_CLUSTER_PM_ENTER_FAILED, and CPU_CLUSTER_PM_EXIT and doesn't have
> a default. This means that we'll try to do a flush in those cases but
> we won't necessarily be the last CPU down. That's not so ideal since
> our (lack of) locking assumes we're on the last CPU.
>
> Luckily this isn't as big a problem as you'd think since (at least on
> the SoC I tested) we don't get these notifications except on full
> system suspend. ...and on full system suspend we get them on the last
> CPU down. That means that the worst problem we hit is flushing twice.
> Still, it's good to make it correct.
>
> Fixes: 985427f997b6 ("soc: qcom: rpmh: Invoke rpmh_flush() for dirty caches")
> Reported-by: Stephen Boyd <[email protected]>
> Signed-off-by: Douglas Anderson <[email protected]>
> ---
>
> Changes in v4:
> - ("...Corrently ignore CPU_CLUSTER_PM notifications") split out for v4.
>
> Changes in v3: None
> Changes in v2: None
>
> drivers/soc/qcom/rpmh-rsc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
> index a9e15699f55f..3571a99fc839 100644
> --- a/drivers/soc/qcom/rpmh-rsc.c
> +++ b/drivers/soc/qcom/rpmh-rsc.c
> @@ -806,6 +806,8 @@ static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb,
> case CPU_PM_EXIT:
> cpumask_clear_cpu(smp_processor_id(), &drv->cpus_entered_pm);
> goto exit;
> + default:
> + return NOTIFY_DONE;
> }
>
> ret = rpmh_rsc_ctrlr_is_busy(drv);

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

2020-04-23 16:21:29

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] soc: qcom: rpmh-rsc: Corrently ignore CPU_CLUSTER_PM notifications

Hi,

On Wed, Apr 22, 2020 at 9:45 PM Maulik Shah <[email protected]> wrote:
>
> Hi,
>
> there is a typo in subject, Corrently to correctly.
> Other than this, fix seems good to me.
>
> Reviewed-by: Maulik Shah <[email protected]>

Sigh. My brian has never worked very well. One of these days I'll
see if I can get it tuned up. Unless there is another reason to spin
this series or I'm requested to, I'll assume that Bjron or Andy can
fix my typo in the subject when applying.

Thanks!

-Doug

2020-04-24 02:41:47

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] soc: qcom: rpmh-rsc: Corrently ignore CPU_CLUSTER_PM notifications

Quoting Douglas Anderson (2020-04-22 14:54:59)
> Our switch statement doesn't have entries for CPU_CLUSTER_PM_ENTER,
> CPU_CLUSTER_PM_ENTER_FAILED, and CPU_CLUSTER_PM_EXIT and doesn't have
> a default. This means that we'll try to do a flush in those cases but
> we won't necessarily be the last CPU down. That's not so ideal since
> our (lack of) locking assumes we're on the last CPU.
>
> Luckily this isn't as big a problem as you'd think since (at least on
> the SoC I tested) we don't get these notifications except on full
> system suspend. ...and on full system suspend we get them on the last
> CPU down. That means that the worst problem we hit is flushing twice.
> Still, it's good to make it correct.
>
> Fixes: 985427f997b6 ("soc: qcom: rpmh: Invoke rpmh_flush() for dirty caches")
> Reported-by: Stephen Boyd <[email protected]>
> Signed-off-by: Douglas Anderson <[email protected]>
> ---

Reviewed-by: Stephen Boyd <[email protected]>

2020-04-24 02:47:57

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH v4 3/5] kernel/cpu_pm: Fix uninitted local in cpu_pm

Quoting Douglas Anderson (2020-04-22 14:55:01)
> cpu_pm_notify() is basically a wrapper of notifier_call_chain().
> notifier_call_chain() doesn't initialize *nr_calls to 0 before it
> starts incrementing it--presumably it's up to the callers to do this.
>
> Unfortunately the callers of cpu_pm_notify() don't init *nr_calls.
> This potentially means you could get too many or two few calls to
> CPU_PM_ENTER_FAILED or CPU_CLUSTER_PM_ENTER_FAILED depending on the
> luck of the stack.
>
> Let's fix this.
>
> Fixes: ab10023e0088 ("cpu_pm: Add cpu power management notifiers")
> Signed-off-by: Douglas Anderson <[email protected]>
> ---

Reviewed-by: Stephen Boyd <[email protected]>