Attention is currently required from: Philipp Hug, ron minnich.
Maximilian Brune has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81082?usp=email )
Change subject: Add weak function for SMP hart count ......................................................................
Add weak function for SMP hart count
Signed-off-by: Maximilian Brune maximilian.brune@9elements.com Change-Id: Icc53185991fed4dbed032a52e51ff71d085ad587 --- M src/arch/riscv/include/arch/smp/smp.h M src/arch/riscv/smp.c 2 files changed, 16 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/82/81082/1
diff --git a/src/arch/riscv/include/arch/smp/smp.h b/src/arch/riscv/include/arch/smp/smp.h index 9d3ae5f..758c4de 100644 --- a/src/arch/riscv/include/arch/smp/smp.h +++ b/src/arch/riscv/include/arch/smp/smp.h @@ -3,6 +3,8 @@ #ifndef _RISCV_SMP_H #define _RISCV_SMP_H
+unsigned int smp_get_hart_count(void); + /* * This function is used to pause smp. Only the hart with hartid equal * to working_hartid can be returned from smp_pause, other harts will diff --git a/src/arch/riscv/smp.c b/src/arch/riscv/smp.c index 0a93763..6ecfbc5 100644 --- a/src/arch/riscv/smp.c +++ b/src/arch/riscv/smp.c @@ -6,6 +6,12 @@ #include <arch/smp/atomic.h> #include <console/console.h> #include <mcall.h> +#include <assert.h> + +__weak unsigned int smp_get_hart_count(void) +{ + return CONFIG_MAX_CPUS; +}
void smp_pause(int working_hartid) { @@ -38,10 +44,13 @@ atomic_set(&SYNCB, 0); atomic_set(&SYNCA, 0x01234567);
- /* waiting for other Hart to enter the halt */ + int hart_count = smp_get_hart_count(); + /* waiting for other Hart to enter the halt + * use a poor mans timeout to not wait indefinitiely + */ do { barrier(); - } while (atomic_read(&SYNCB) + 1 < CONFIG_MAX_CPUS); + } while (atomic_read(&SYNCB) + 1 < hart_count);
/* initialize for the next call */ atomic_set(&SYNCA, 0); @@ -54,16 +63,17 @@ void smp_resume(void (*fn)(void *), void *arg) { int hartid = read_csr(mhartid); + int hart_count = smp_get_hart_count();
if (fn == NULL) die("must pass a non-null function pointer\n");
- for (int i = 0; i < CONFIG_MAX_CPUS; i++) { + for (int i = 0; i < hart_count; i++) { OTHER_HLS(i)->entry.fn = fn; OTHER_HLS(i)->entry.arg = arg; }
- for (int i = 0; i < CONFIG_MAX_CPUS; i++) + for (int i = 0; i < hart_count; i++) if (i != hartid) set_msip(i, 1);