Skip to content

Commit 45f589b

Browse files
JackyBaivireshk
authored andcommitted
cpufreq: Init cpufreq only for present CPUs
for_each_possible_cpu() is currently used to initialize cpufreq. 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 cpufreq probe failure or defer probe due to no cpu device available for not present CPUs. Change for_each_possible_cpu() to for_each_present_cpu() in the above cpufreq drivers to ensure it only registers cpufreq for CPUs that are actually present. Fixes: b0c69e1 ("drivers: base: Use present CPUs in GENERIC_CPU_DEVICES") Reviewed-by: Sudeep Holla <[email protected]> Signed-off-by: Jacky Bai <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent be4ae8c commit 45f589b

11 files changed

+16
-16
lines changed

drivers/cpufreq/armada-8k-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void __init armada_8k_get_sharing_cpus(struct clk *cur_clk,
4747
{
4848
int cpu;
4949

50-
for_each_possible_cpu(cpu) {
50+
for_each_present_cpu(cpu) {
5151
struct device *cpu_dev;
5252
struct clk *clk;
5353

drivers/cpufreq/cpufreq-dt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static int dt_cpufreq_probe(struct platform_device *pdev)
283283
int ret, cpu;
284284

285285
/* Request resources early so we can return in case of -EPROBE_DEFER */
286-
for_each_possible_cpu(cpu) {
286+
for_each_present_cpu(cpu) {
287287
ret = dt_cpufreq_early_init(&pdev->dev, cpu);
288288
if (ret)
289289
goto err;

drivers/cpufreq/mediatek-cpufreq-hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)
303303
struct regulator *cpu_reg;
304304

305305
/* Make sure that all CPU supplies are available before proceeding. */
306-
for_each_possible_cpu(cpu) {
306+
for_each_present_cpu(cpu) {
307307
cpu_dev = get_cpu_device(cpu);
308308
if (!cpu_dev)
309309
return dev_err_probe(&pdev->dev, -EPROBE_DEFER,

drivers/cpufreq/mediatek-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static int mtk_cpufreq_probe(struct platform_device *pdev)
631631
return dev_err_probe(&pdev->dev, -ENODEV,
632632
"failed to get mtk cpufreq platform data\n");
633633

634-
for_each_possible_cpu(cpu) {
634+
for_each_present_cpu(cpu) {
635635
info = mtk_cpu_dvfs_info_lookup(cpu);
636636
if (info)
637637
continue;

drivers/cpufreq/mvebu-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int __init armada_xp_pmsu_cpufreq_init(void)
5656
* it), and registers the clock notifier that will take care
5757
* of doing the PMSU part of a frequency transition.
5858
*/
59-
for_each_possible_cpu(cpu) {
59+
for_each_present_cpu(cpu) {
6060
struct device *cpu_dev;
6161
struct clk *clk;
6262
int ret;

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static void qcom_get_related_cpus(int index, struct cpumask *m)
306306
struct of_phandle_args args;
307307
int cpu, ret;
308308

309-
for_each_possible_cpu(cpu) {
309+
for_each_present_cpu(cpu) {
310310
cpu_np = of_cpu_device_node_get(cpu);
311311
if (!cpu_np)
312312
continue;

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
489489
nvmem_cell_put(speedbin_nvmem);
490490
}
491491

492-
for_each_possible_cpu(cpu) {
492+
for_each_present_cpu(cpu) {
493493
struct dev_pm_opp_config config = {
494494
.supported_hw = NULL,
495495
};
@@ -543,7 +543,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
543543
dev_err(cpu_dev, "Failed to register platform device\n");
544544

545545
free_opp:
546-
for_each_possible_cpu(cpu) {
546+
for_each_present_cpu(cpu) {
547547
dev_pm_domain_detach_list(drv->cpus[cpu].pd_list);
548548
dev_pm_opp_clear_config(drv->cpus[cpu].opp_token);
549549
}
@@ -557,7 +557,7 @@ static void qcom_cpufreq_remove(struct platform_device *pdev)
557557

558558
platform_device_unregister(cpufreq_dt_pdev);
559559

560-
for_each_possible_cpu(cpu) {
560+
for_each_present_cpu(cpu) {
561561
dev_pm_domain_detach_list(drv->cpus[cpu].pd_list);
562562
dev_pm_opp_clear_config(drv->cpus[cpu].opp_token);
563563
}
@@ -568,7 +568,7 @@ static int qcom_cpufreq_suspend(struct device *dev)
568568
struct qcom_cpufreq_drv *drv = dev_get_drvdata(dev);
569569
unsigned int cpu;
570570

571-
for_each_possible_cpu(cpu)
571+
for_each_present_cpu(cpu)
572572
qcom_cpufreq_suspend_pd_devs(drv, cpu);
573573

574574
return 0;

drivers/cpufreq/scmi-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ scmi_get_sharing_cpus(struct device *cpu_dev, int domain,
104104
int cpu, tdomain;
105105
struct device *tcpu_dev;
106106

107-
for_each_possible_cpu(cpu) {
107+
for_each_present_cpu(cpu) {
108108
if (cpu == cpu_dev->id)
109109
continue;
110110

drivers/cpufreq/scpi-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ scpi_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
6565
if (domain < 0)
6666
return domain;
6767

68-
for_each_possible_cpu(cpu) {
68+
for_each_present_cpu(cpu) {
6969
if (cpu == cpu_dev->id)
7070
continue;
7171

drivers/cpufreq/sun50i-cpufreq-nvmem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
262262
snprintf(name, sizeof(name), "speed%d", speed);
263263
config.prop_name = name;
264264

265-
for_each_possible_cpu(cpu) {
265+
for_each_present_cpu(cpu) {
266266
struct device *cpu_dev = get_cpu_device(cpu);
267267

268268
if (!cpu_dev) {
@@ -288,7 +288,7 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
288288
pr_err("Failed to register platform device\n");
289289

290290
free_opp:
291-
for_each_possible_cpu(cpu)
291+
for_each_present_cpu(cpu)
292292
dev_pm_opp_clear_config(opp_tokens[cpu]);
293293
kfree(opp_tokens);
294294

@@ -302,7 +302,7 @@ static void sun50i_cpufreq_nvmem_remove(struct platform_device *pdev)
302302

303303
platform_device_unregister(cpufreq_dt_pdev);
304304

305-
for_each_possible_cpu(cpu)
305+
for_each_present_cpu(cpu)
306306
dev_pm_opp_clear_config(opp_tokens[cpu]);
307307

308308
kfree(opp_tokens);

0 commit comments

Comments
 (0)