Skip to content

Commit 90f84f3

Browse files
committed
cpuidle: Init cpuidle only for present CPUs
JIRA: https://issues.redhat.com/browse/RHEL-87863 Conflicts: drivers/cpuidle/cpuidle-riscv-sbi.c - doesn't exist in centos-stream-9 and was ignored commit 68cb013 Author: Jacky Bai <ping.bai@nxp.com> Date: Wed, 12 Mar 2025 21:31:59 +0000 for_each_possible_cpu() is currently used to initialize cpuidle in below cpuidle drivers: drivers/cpuidle/cpuidle-arm.c drivers/cpuidle/cpuidle-big_little.c drivers/cpuidle/cpuidle-psci.c drivers/cpuidle/cpuidle-qcom-spm.c drivers/cpuidle/cpuidle-riscv-sbi.c 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, lead to the failure: | Failed to register cpuidle device for cpu1 Then rollback to cancel all CPUs' cpuidle registration. Change for_each_possible_cpu() to for_each_present_cpu() in the above cpuidle drivers to ensure it only registers cpuidle devices for CPUs that are actually present. Fixes: b0c69e1 ("drivers: base: Use present CPUs in GENERIC_CPU_DEVICES") Reviewed-by: Dhruva Gole <d-gole@ti.com> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Tested-by: Yuanjie Yang <quic_yuanjiey@quicinc.com> Signed-off-by: Jacky Bai <ping.bai@nxp.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://patch.msgid.link/20250307145547.2784821-1-ping.bai@nxp.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
1 parent e9f0ee0 commit 90f84f3

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

drivers/cpuidle/cpuidle-arm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,17 @@ static int __init arm_idle_init_cpu(int cpu)
137137
/*
138138
* arm_idle_init - Initializes arm cpuidle driver
139139
*
140-
* Initializes arm cpuidle driver for all CPUs, if any CPU fails
141-
* to register cpuidle driver then rollback to cancel all CPUs
142-
* registration.
140+
* Initializes arm cpuidle driver for all present CPUs, if any
141+
* CPU fails to register cpuidle driver then rollback to cancel
142+
* all CPUs registration.
143143
*/
144144
static int __init arm_idle_init(void)
145145
{
146146
int cpu, ret;
147147
struct cpuidle_driver *drv;
148148
struct cpuidle_device *dev;
149149

150-
for_each_possible_cpu(cpu) {
150+
for_each_present_cpu(cpu) {
151151
ret = arm_idle_init_cpu(cpu);
152152
if (ret)
153153
goto out_fail;

drivers/cpuidle/cpuidle-big_little.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int __init bl_idle_driver_init(struct cpuidle_driver *drv, int part_id)
148148
if (!cpumask)
149149
return -ENOMEM;
150150

151-
for_each_possible_cpu(cpu)
151+
for_each_present_cpu(cpu)
152152
if (smp_cpuid_part(cpu) == part_id)
153153
cpumask_set_cpu(cpu, cpumask);
154154

drivers/cpuidle/cpuidle-psci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static int psci_idle_init_cpu(struct device *dev, int cpu)
403403
/*
404404
* psci_idle_probe - Initializes PSCI cpuidle driver
405405
*
406-
* Initializes PSCI cpuidle driver for all CPUs, if any CPU fails
406+
* Initializes PSCI cpuidle driver for all present CPUs, if any CPU fails
407407
* to register cpuidle driver then rollback to cancel all CPUs
408408
* registration.
409409
*/
@@ -413,7 +413,7 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
413413
struct cpuidle_driver *drv;
414414
struct cpuidle_device *dev;
415415

416-
for_each_possible_cpu(cpu) {
416+
for_each_present_cpu(cpu) {
417417
ret = psci_idle_init_cpu(&pdev->dev, cpu);
418418
if (ret)
419419
goto out_fail;

drivers/cpuidle/cpuidle-qcom-spm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static int spm_cpuidle_drv_probe(struct platform_device *pdev)
135135
if (ret)
136136
return dev_err_probe(&pdev->dev, ret, "set warm boot addr failed");
137137

138-
for_each_possible_cpu(cpu) {
138+
for_each_present_cpu(cpu) {
139139
ret = spm_cpuidle_register(&pdev->dev, cpu);
140140
if (ret && ret != -ENODEV) {
141141
dev_err(&pdev->dev,

0 commit comments

Comments
 (0)