[PATCH 09/12] lib: sbi: Ensure that all Harts complete sbi_hart_init
Xiang W
wxjstz at 126.com
Wed Jun 11 05:12:26 PDT 2025
Make sure all cores complete sbi_hart_init. This way, the boot
Hart in the subsequent code can detect the extensions of other
Hart.
Signed-off-by: Xiang W <wxjstz at 126.com>
---
lib/sbi/sbi_hart.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 30149c36..9da54145 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -1038,6 +1038,7 @@ int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot)
{
int rc;
static atomic_t sync_a = ATOMIC_INITIALIZER(0);
+ static atomic_t sync_b = ATOMIC_INITIALIZER(0);
/*
* Clear mip CSR before proceeding with init to avoid any spurious
@@ -1061,7 +1062,16 @@ int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot)
if (rc)
return rc;
- return sbi_hart_reinit(scratch);
+ rc = sbi_hart_reinit(scratch);
+ if (rc)
+ return rc;
+
+ /*
+ * Make sure all Harts complete sbi_hart_init so that the subsequent
+ * code can detect the extensions of other Harts
+ */
+ sbi_sync_and_wait_all_harts(&sync_b);
+ return 0;
}
void __attribute__((noreturn)) sbi_hart_hang(void)
--
2.47.2
More information about the opensbi
mailing list