* [PATCH v2] cpuidle: psci: Init cpuidle only for present CPUs
@ 2024-11-20 10:37 Jacky Bai
2025-03-05 6:31 ` Yuanjie Yang
0 siblings, 1 reply; 4+ messages in thread
From: Jacky Bai @ 2024-11-20 10:37 UTC (permalink / raw)
To: lpieralisi, sudeep.holla, rafael, daniel.lezcano, james.morse,
d-gole
Cc: linux-pm, linux-arm-kernel, linux-kernel, imx, khilman
With 'nosmp' or 'maxcpus=0' boot command line parameters,
the 'cpu_present_mask' may not be the same as 'cpu_possible_mask'.
In current psci cpuidle driver init, for_each_possible_cpu()
is used to init the cpuidle for each possible CPU. but in
drivers/base/cpu.c ->cpu_dev_register_generic(),
for_each_present_cpu() is used to register cpu device for
present CPUs.
When boot system with 'nosmp' or 'maxcpus=0', the cpuidle driver
init failed due to no valid CPU device sysfs node for non-boot CPUs.
[ 0.182993] Failed to register cpuidle device for cpu1
Use for_each_present_cpu() to register cpuidle only for present
CPUs.
Fixes: b0c69e1214bc ("drivers: base: Use present CPUs in GENERIC_CPU_DEVICES")
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
---
drivers/cpuidle/cpuidle-psci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
index 2562dc001fc1..00117e9b33e8 100644
--- a/drivers/cpuidle/cpuidle-psci.c
+++ b/drivers/cpuidle/cpuidle-psci.c
@@ -410,7 +410,7 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
struct cpuidle_driver *drv;
struct cpuidle_device *dev;
- for_each_possible_cpu(cpu) {
+ for_each_present_cpu(cpu) {
ret = psci_idle_init_cpu(&pdev->dev, cpu);
if (ret)
goto out_fail;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] cpuidle: psci: Init cpuidle only for present CPUs
2024-11-20 10:37 [PATCH v2] cpuidle: psci: Init cpuidle only for present CPUs Jacky Bai
@ 2025-03-05 6:31 ` Yuanjie Yang
2025-03-05 10:25 ` Sudeep Holla
0 siblings, 1 reply; 4+ messages in thread
From: Yuanjie Yang @ 2025-03-05 6:31 UTC (permalink / raw)
To: Jacky Bai, lpieralisi, sudeep.holla, rafael, daniel.lezcano,
james.morse, d-gole
Cc: linux-pm, linux-arm-kernel, linux-kernel, imx, khilman,
quic_tingweiz, quic_yuanjiey
On Wed, Nov 20, 2024 at 06:37:49PM +0800, Jacky Bai wrote:
> With 'nosmp' or 'maxcpus=0' boot command line parameters,
> the 'cpu_present_mask' may not be the same as 'cpu_possible_mask'.
>
> In current psci cpuidle driver init, for_each_possible_cpu()
> is used to init the cpuidle for each possible CPU. but in
> drivers/base/cpu.c ->cpu_dev_register_generic(),
> for_each_present_cpu() is used to register cpu device for
> present CPUs.
>
> When boot system with 'nosmp' or 'maxcpus=0', the cpuidle driver
> init failed due to no valid CPU device sysfs node for non-boot CPUs.
>
> [ 0.182993] Failed to register cpuidle device for cpu1
>
> Use for_each_present_cpu() to register cpuidle only for present
> CPUs.
>
> Fixes: b0c69e1214bc ("drivers: base: Use present CPUs in GENERIC_CPU_DEVICES")
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> Reviewed-by: Dhruva Gole <d-gole@ti.com>
> ---
> drivers/cpuidle/cpuidle-psci.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
> index 2562dc001fc1..00117e9b33e8 100644
> --- a/drivers/cpuidle/cpuidle-psci.c
> +++ b/drivers/cpuidle/cpuidle-psci.c
> @@ -410,7 +410,7 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
> struct cpuidle_driver *drv;
> struct cpuidle_device *dev;
>
> - for_each_possible_cpu(cpu) {
> + for_each_present_cpu(cpu) {
> ret = psci_idle_init_cpu(&pdev->dev, cpu);
> if (ret)
> goto out_fail;
> --
> 2.34.1
>
Tested-by: Yuanjie Yang <quic_yuanjiey@quicinc.com>
I meet the same problem, and I test your patch, it is good to me.
Thanks,
Yuanjie
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] cpuidle: psci: Init cpuidle only for present CPUs
2025-03-05 6:31 ` Yuanjie Yang
@ 2025-03-05 10:25 ` Sudeep Holla
2025-03-05 10:29 ` Jacky Bai
0 siblings, 1 reply; 4+ messages in thread
From: Sudeep Holla @ 2025-03-05 10:25 UTC (permalink / raw)
To: Yuanjie Yang, Jacky Bai
Cc: lpieralisi, rafael, daniel.lezcano, james.morse, d-gole, linux-pm,
linux-arm-kernel, linux-kernel, imx, khilman, quic_tingweiz
Hi Jacky,
I wasn't Cc-ed on the original patch.
I was searching to provide feedback but couldn't find one.
On Wed, Mar 05, 2025 at 02:31:57PM +0800, Yuanjie Yang wrote:
> On Wed, Nov 20, 2024 at 06:37:49PM +0800, Jacky Bai wrote:
> > With 'nosmp' or 'maxcpus=0' boot command line parameters,
> > the 'cpu_present_mask' may not be the same as 'cpu_possible_mask'.
> >
> > In current psci cpuidle driver init, for_each_possible_cpu()
> > is used to init the cpuidle for each possible CPU. but in
> > drivers/base/cpu.c ->cpu_dev_register_generic(),
> > for_each_present_cpu() is used to register cpu device for
> > present CPUs.
> >
> > When boot system with 'nosmp' or 'maxcpus=0', the cpuidle driver
> > init failed due to no valid CPU device sysfs node for non-boot CPUs.
> >
> > [ 0.182993] Failed to register cpuidle device for cpu1
> >
> > Use for_each_present_cpu() to register cpuidle only for present
> > CPUs.
> >
Can you reword it something like
"
for_each_possible_cpu() is currently used to initialize cpuidle in the
PSCI cpuidle driver.
However, in cpu_dev_register_generic(), for_each_present_cpu() is used
to register CPU devices which means the CPU devices are only registered
for present CPUs and not all possible CPUs.
With nosmp or maxcpus=0, only the boot CPU is present, leading to the
failure:
| Failed to register cpuidle device for cpu1
Change for_each_possible_cpu() to for_each_present_cpu() in the PSCI
cpuidle driver to ensure it only registers cpuidle devices for CPUs
that are actually present.
"
With that, you can add:
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Please cc Ulf Hansson <ulf.hansson@linaro.org> as well. Either him or
Rafael can then pick up the patch.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] cpuidle: psci: Init cpuidle only for present CPUs
2025-03-05 10:25 ` Sudeep Holla
@ 2025-03-05 10:29 ` Jacky Bai
0 siblings, 0 replies; 4+ messages in thread
From: Jacky Bai @ 2025-03-05 10:29 UTC (permalink / raw)
To: Sudeep Holla, Yuanjie Yang
Cc: lpieralisi@kernel.org, rafael@kernel.org,
daniel.lezcano@linaro.org, james.morse@arm.com, d-gole@ti.com,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev,
khilman@baylibre.com, quic_tingweiz@quicinc.com
> Subject: Re: [PATCH v2] cpuidle: psci: Init cpuidle only for present CPUs
>
> Hi Jacky,
>
> I wasn't Cc-ed on the original patch.
>
> I was searching to provide feedback but couldn't find one.
>
> On Wed, Mar 05, 2025 at 02:31:57PM +0800, Yuanjie Yang wrote:
> > On Wed, Nov 20, 2024 at 06:37:49PM +0800, Jacky Bai wrote:
> > > With 'nosmp' or 'maxcpus=0' boot command line parameters, the
> > > 'cpu_present_mask' may not be the same as 'cpu_possible_mask'.
> > >
> > > In current psci cpuidle driver init, for_each_possible_cpu() is used
> > > to init the cpuidle for each possible CPU. but in drivers/base/cpu.c
> > > ->cpu_dev_register_generic(),
> > > for_each_present_cpu() is used to register cpu device for present
> > > CPUs.
> > >
> > > When boot system with 'nosmp' or 'maxcpus=0', the cpuidle driver
> > > init failed due to no valid CPU device sysfs node for non-boot CPUs.
> > >
> > > [ 0.182993] Failed to register cpuidle device for cpu1
> > >
> > > Use for_each_present_cpu() to register cpuidle only for present
> > > CPUs.
> > >
>
> Can you reword it something like
> "
>
> for_each_possible_cpu() is currently used to initialize cpuidle in the PSCI
> cpuidle driver.
>
> However, in cpu_dev_register_generic(), for_each_present_cpu() is used to
> register CPU devices which means the CPU devices are only registered for
> present CPUs and not all possible CPUs.
>
> With nosmp or maxcpus=0, only the boot CPU is present, leading to the
> failure:
>
> | Failed to register cpuidle device for cpu1
>
> Change for_each_possible_cpu() to for_each_present_cpu() in the PSCI
> cpuidle driver to ensure it only registers cpuidle devices for CPUs that are
> actually present.
>
> "
>
> With that, you can add:
>
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
>
> Please cc Ulf Hansson <ulf.hansson@linaro.org> as well. Either him or Rafael
> can then pick up the patch.
>
Sorry, I should Cc you in the list. Thank you for your suggestion, I will resolve it in v3.
BR
> --
> Regards,
> Sudeep
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-05 10:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-20 10:37 [PATCH v2] cpuidle: psci: Init cpuidle only for present CPUs Jacky Bai
2025-03-05 6:31 ` Yuanjie Yang
2025-03-05 10:25 ` Sudeep Holla
2025-03-05 10:29 ` Jacky Bai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox