If nr_cpus command line option is set, maximum possible cpu should be
set to that value.

Signed-off-by: Atish Patra <atish.pa...@wdc.com>
---
 arch/riscv/kernel/smpboot.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 609475c5..a8fe590c 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -86,11 +86,19 @@ void __init setup_smp(void)
                }
 
                cpuid_to_hartid_map(cpuid) = hart;
-               set_cpu_possible(cpuid, true);
                cpuid++;
        }
 
        BUG_ON(!found_boot_cpu);
+
+       if (cpuid > nr_cpu_ids)
+               pr_warn("Total number of cpus [%d] are greater than configured 
via nr_cpus [%d]\n",
+                       cpuid, nr_cpu_ids);
+
+       for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
+               if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID)
+                       set_cpu_possible(cpuid, true);
+       }
 }
 
 int __cpu_up(unsigned int cpu, struct task_struct *tidle)
-- 
2.21.0

Reply via email to