From 968a23d2e0afcf3ead23d3075aecc5c6e27211e4 Mon Sep 17 00:00:00 2001 From: Philipp Hug Date: Sat, 1 Dec 2018 18:17:18 +0100 Subject: riscv: fix non-SMP support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use CONFIG_CPU_MAX which defaults to 1 instead of CONFIG_RISCV_HART_NUM. The default value of CONFIG_RISCV_HART_NUM was 0 and cause a jump to address 0. Add a die() call to fail gracefully. Change-Id: I4e3aa09b787ae0f26a4aae375f4e5fcd745a0a1e Signed-off-by: Philipp Hug Reviewed-on: https://review.coreboot.org/c/29993 Tested-by: build bot (Jenkins) Reviewed-by: Xiang Wang Reviewed-by: Jonathan Neuschäfer --- src/arch/riscv/Kconfig | 3 --- src/arch/riscv/smp.c | 9 ++++++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/arch') diff --git a/src/arch/riscv/Kconfig b/src/arch/riscv/Kconfig index ae83be855b..9fa43bc9f2 100644 --- a/src/arch/riscv/Kconfig +++ b/src/arch/riscv/Kconfig @@ -33,8 +33,5 @@ config RISCV_USE_ARCH_TIMER bool default n -config RISCV_HART_NUM - int - config RISCV_WORKING_HARTID int diff --git a/src/arch/riscv/smp.c b/src/arch/riscv/smp.c index 8d07d39ded..8942ec5b93 100644 --- a/src/arch/riscv/smp.c +++ b/src/arch/riscv/smp.c @@ -55,7 +55,7 @@ void smp_pause(int working_hartid) /* waiting for other Hart to enter the halt */ do { barrier(); - } while (SYNCB + 1 < CONFIG_RISCV_HART_NUM); + } while (SYNCB + 1 < CONFIG_MAX_CPUS); /* initialize for the next call */ SYNCA = 0; @@ -72,14 +72,17 @@ void smp_resume(void (*fn)(void *), void *arg) if (fn == NULL) die("must pass a non-null function pointer\n"); - for (int i = 0; i < CONFIG_RISCV_HART_NUM; i++) { + for (int i = 0; i < CONFIG_MAX_CPUS; i++) { OTHER_HLS(i)->entry.fn = fn; OTHER_HLS(i)->entry.arg = arg; } - for (int i = 0; i < CONFIG_RISCV_HART_NUM; i++) + for (int i = 0; i < CONFIG_MAX_CPUS; i++) if (i != hartid) set_msip(i, 1); + if (HLS()->entry.fn == NULL) + die("entry fn not set\n"); + HLS()->entry.fn(HLS()->entry.arg); } -- cgit v1.2.3