[PATCH] riscv: BUG_ON() for no cpu nodes in setup_smp

From: Song Shuai
Date: Thu Jun 29 2023 - 06:58:59 EST


When booting with ACPI tables, the tiny devictree created by
EFI Stub doesn't provide cpu nodes.

In setup_smp(), of_parse_and_init_cpus() will bug on !found_boot_cpu
if acpi_disabled. That's unclear, so bug for no cpu nodes before
of_parse_and_init_cpus().

Signed-off-by: Song Shuai <suagrfillet@xxxxxxxxx>
---
arch/riscv/kernel/smpboot.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 6ca2b5309aab..243a7b533ad7 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -187,8 +187,13 @@ static void __init of_parse_and_init_cpus(void)

void __init setup_smp(void)
{
- if (acpi_disabled)
+ if (acpi_disabled) {
+ /* When booting with ACPI tables, the devictree created by EFI Stub
+ * doesn't provide cpu nodes. So BUG here for any acpi_disabled.
+ */
+ BUG_ON(!of_get_next_cpu_node(NULL));
of_parse_and_init_cpus();
+ }
else
acpi_parse_and_init_cpus();
}
--
2.20.1