[PATCH 04/12] lib: sbi: Remove wait_for_coldboot and wake_coldboot_harts
Xiang W
wxjstz at 126.com
Wed Jun 11 05:12:21 PDT 2025
Remove wait_for_coldboot and wake_coldboot_harts and use more
general methods instead.
Signed-off-by: Xiang W <wxjstz at 126.com>
---
lib/sbi/sbi_init.c | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index a8983f4d..8405fcf3 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -197,21 +197,6 @@ static void sbi_boot_print_hart(struct sbi_scratch *scratch, u32 hartid)
sbi_hart_delegation_dump(scratch, "Boot HART ", " ");
}
-static unsigned long coldboot_done;
-
-static void wait_for_coldboot(struct sbi_scratch *scratch)
-{
- /* Wait for coldboot to finish */
- while (!__smp_load_acquire(&coldboot_done))
- cpu_relax();
-}
-
-static void wake_coldboot_harts(struct sbi_scratch *scratch)
-{
- /* Mark coldboot done */
- __smp_store_release(&coldboot_done, 1);
-}
-
static void __noreturn init_warm_resume(struct sbi_scratch *scratch, u32 hartid)
{
int rc;
@@ -238,7 +223,9 @@ static void __noreturn init_startup(struct sbi_scratch *scratch, u32 hartid, boo
int hstate;
unsigned long *count;
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
+ static atomic_t sync_a = ATOMIC_INITIALIZER(0);
+ sbi_wait_for_boot_hart_first(cold_boot, &sync_a);
if (cold_boot) {
/* Note: This has to be first thing in coldboot init sequence */
rc = sbi_scratch_init(scratch);
@@ -258,8 +245,6 @@ static void __noreturn init_startup(struct sbi_scratch *scratch, u32 hartid, boo
entry_count_offset = sbi_scratch_alloc_offset(__SIZEOF_POINTER__);
init_count_offset = sbi_scratch_alloc_offset(__SIZEOF_POINTER__);
} else {
- wait_for_coldboot(scratch);
-
hstate = sbi_hsm_hart_get_state(sbi_domain_thishart_ptr(), hartid);
if (hstate < 0)
sbi_hart_hang();
@@ -284,8 +269,7 @@ static void __noreturn init_startup(struct sbi_scratch *scratch, u32 hartid, boo
* have these HARTs busy spin in wait_for_coldboot() until coldboot
* path is completed.
*/
- if (cold_boot)
- wake_coldboot_harts(scratch);
+ sbi_signal_boot_hart_first_done(cold_boot, &sync_a);
rc = sbi_platform_early_init(plat, cold_boot);
if (rc)
--
2.47.2
More information about the opensbi
mailing list