linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] cpuidle: psci: Iterate backwards over list in psci_pd_remove()
@ 2023-03-04  7:41 Shawn Guo
  2023-03-07 13:06 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Guo @ 2023-03-04  7:41 UTC (permalink / raw)
  To: Daniel Lezcano, Rafael J . Wysocki
  Cc: Sudeep Holla, Ulf Hansson, Konrad Dybcio, linux-pm,
	linux-arm-kernel, linux-kernel, Shawn Guo

In case that psci_pd_init_topology() fails for some reason,
psci_pd_remove() will be responsible for deleting provider and removing
genpd from psci_pd_providers list.  There will be a failure when removing
the cluster PD, because the cpu (child) PDs haven't been removed.

[    0.050232] CPUidle PSCI: init PM domain cpu0
[    0.050278] CPUidle PSCI: init PM domain cpu1
[    0.050329] CPUidle PSCI: init PM domain cpu2
[    0.050370] CPUidle PSCI: init PM domain cpu3
[    0.050422] CPUidle PSCI: init PM domain cpu-cluster0
[    0.050475] PM: genpd_remove: unable to remove cpu-cluster0
[    0.051412] PM: genpd_remove: removed cpu3
[    0.051449] PM: genpd_remove: removed cpu2
[    0.051499] PM: genpd_remove: removed cpu1
[    0.051546] PM: genpd_remove: removed cpu0

Fix the problem by iterating the provider list reversely, so that parent
PD gets removed after child's PDs like below.

[    0.029052] CPUidle PSCI: init PM domain cpu0
[    0.029076] CPUidle PSCI: init PM domain cpu1
[    0.029103] CPUidle PSCI: init PM domain cpu2
[    0.029124] CPUidle PSCI: init PM domain cpu3
[    0.029151] CPUidle PSCI: init PM domain cpu-cluster0
[    0.029647] PM: genpd_remove: removed cpu0
[    0.029666] PM: genpd_remove: removed cpu1
[    0.029690] PM: genpd_remove: removed cpu2
[    0.029714] PM: genpd_remove: removed cpu3
[    0.029738] PM: genpd_remove: removed cpu-cluster0

Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd")
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
Hi Rafael,

This is a resend of the patch [1].  Could you help pick it up or let me
know if there is anything need to be improved, thanks!

Shawn

[1] https://lore.kernel.org/linux-arm-kernel/20220308082931.3385902-1-shawn.guo@linaro.org/

 drivers/cpuidle/cpuidle-psci-domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c
index c80cf9ddabd8..1fca250d5dec 100644
--- a/drivers/cpuidle/cpuidle-psci-domain.c
+++ b/drivers/cpuidle/cpuidle-psci-domain.c
@@ -103,7 +103,8 @@ static void psci_pd_remove(void)
 	struct psci_pd_provider *pd_provider, *it;
 	struct generic_pm_domain *genpd;
 
-	list_for_each_entry_safe(pd_provider, it, &psci_pd_providers, link) {
+	list_for_each_entry_safe_reverse(pd_provider, it,
+					 &psci_pd_providers, link) {
 		of_genpd_del_provider(pd_provider->node);
 
 		genpd = of_genpd_remove_last(pd_provider->node);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] cpuidle: psci: Iterate backwards over list in psci_pd_remove()
  2023-03-04  7:41 [PATCH RESEND] cpuidle: psci: Iterate backwards over list in psci_pd_remove() Shawn Guo
@ 2023-03-07 13:06 ` Rafael J. Wysocki
  2023-03-08  1:15   ` Shawn Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2023-03-07 13:06 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Daniel Lezcano, Rafael J . Wysocki, Sudeep Holla, Ulf Hansson,
	Konrad Dybcio, linux-pm, linux-arm-kernel, linux-kernel

On Sat, Mar 4, 2023 at 8:41 AM Shawn Guo <shawn.guo@linaro.org> wrote:
>
> In case that psci_pd_init_topology() fails for some reason,
> psci_pd_remove() will be responsible for deleting provider and removing
> genpd from psci_pd_providers list.  There will be a failure when removing
> the cluster PD, because the cpu (child) PDs haven't been removed.
>
> [    0.050232] CPUidle PSCI: init PM domain cpu0
> [    0.050278] CPUidle PSCI: init PM domain cpu1
> [    0.050329] CPUidle PSCI: init PM domain cpu2
> [    0.050370] CPUidle PSCI: init PM domain cpu3
> [    0.050422] CPUidle PSCI: init PM domain cpu-cluster0
> [    0.050475] PM: genpd_remove: unable to remove cpu-cluster0
> [    0.051412] PM: genpd_remove: removed cpu3
> [    0.051449] PM: genpd_remove: removed cpu2
> [    0.051499] PM: genpd_remove: removed cpu1
> [    0.051546] PM: genpd_remove: removed cpu0
>
> Fix the problem by iterating the provider list reversely, so that parent
> PD gets removed after child's PDs like below.
>
> [    0.029052] CPUidle PSCI: init PM domain cpu0
> [    0.029076] CPUidle PSCI: init PM domain cpu1
> [    0.029103] CPUidle PSCI: init PM domain cpu2
> [    0.029124] CPUidle PSCI: init PM domain cpu3
> [    0.029151] CPUidle PSCI: init PM domain cpu-cluster0
> [    0.029647] PM: genpd_remove: removed cpu0
> [    0.029666] PM: genpd_remove: removed cpu1
> [    0.029690] PM: genpd_remove: removed cpu2
> [    0.029714] PM: genpd_remove: removed cpu3
> [    0.029738] PM: genpd_remove: removed cpu-cluster0
>
> Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd")

So I guess there should be Cc: stable for 5.10 and later?

> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> Hi Rafael,
>
> This is a resend of the patch [1].  Could you help pick it up or let me
> know if there is anything need to be improved, thanks!

Is this regarded as 6.3-rc material, or can it wait for 6.4?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] cpuidle: psci: Iterate backwards over list in psci_pd_remove()
  2023-03-07 13:06 ` Rafael J. Wysocki
@ 2023-03-08  1:15   ` Shawn Guo
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2023-03-08  1:15 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Daniel Lezcano, Sudeep Holla, Ulf Hansson, Konrad Dybcio,
	linux-pm, linux-arm-kernel, linux-kernel

On Tue, Mar 07, 2023 at 02:06:31PM +0100, Rafael J. Wysocki wrote:
> On Sat, Mar 4, 2023 at 8:41 AM Shawn Guo <shawn.guo@linaro.org> wrote:
> >
> > In case that psci_pd_init_topology() fails for some reason,
> > psci_pd_remove() will be responsible for deleting provider and removing
> > genpd from psci_pd_providers list.  There will be a failure when removing
> > the cluster PD, because the cpu (child) PDs haven't been removed.
> >
> > [    0.050232] CPUidle PSCI: init PM domain cpu0
> > [    0.050278] CPUidle PSCI: init PM domain cpu1
> > [    0.050329] CPUidle PSCI: init PM domain cpu2
> > [    0.050370] CPUidle PSCI: init PM domain cpu3
> > [    0.050422] CPUidle PSCI: init PM domain cpu-cluster0
> > [    0.050475] PM: genpd_remove: unable to remove cpu-cluster0
> > [    0.051412] PM: genpd_remove: removed cpu3
> > [    0.051449] PM: genpd_remove: removed cpu2
> > [    0.051499] PM: genpd_remove: removed cpu1
> > [    0.051546] PM: genpd_remove: removed cpu0
> >
> > Fix the problem by iterating the provider list reversely, so that parent
> > PD gets removed after child's PDs like below.
> >
> > [    0.029052] CPUidle PSCI: init PM domain cpu0
> > [    0.029076] CPUidle PSCI: init PM domain cpu1
> > [    0.029103] CPUidle PSCI: init PM domain cpu2
> > [    0.029124] CPUidle PSCI: init PM domain cpu3
> > [    0.029151] CPUidle PSCI: init PM domain cpu-cluster0
> > [    0.029647] PM: genpd_remove: removed cpu0
> > [    0.029666] PM: genpd_remove: removed cpu1
> > [    0.029690] PM: genpd_remove: removed cpu2
> > [    0.029714] PM: genpd_remove: removed cpu3
> > [    0.029738] PM: genpd_remove: removed cpu-cluster0
> >
> > Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd")
> 
> So I guess there should be Cc: stable for 5.10 and later?

Yes.  I was thinking that stable team will pick it up due to the Fixes
tag, but yes, explicitly copying stable would be the best.

> 
> > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> > Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > ---
> > Hi Rafael,
> >
> > This is a resend of the patch [1].  Could you help pick it up or let me
> > know if there is anything need to be improved, thanks!
> 
> Is this regarded as 6.3-rc material, or can it wait for 6.4?

As it's regarded as a fix, it would nice to apply it for 6.3-rc.

Shawn

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-08  1:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-04  7:41 [PATCH RESEND] cpuidle: psci: Iterate backwards over list in psci_pd_remove() Shawn Guo
2023-03-07 13:06 ` Rafael J. Wysocki
2023-03-08  1:15   ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).