[PATCH v2 2/9] lib: sbi: Remove wait_for_coldboot and wake_coldboot_harts
Xiang W
wxjstz at 126.com
Fri Jun 20 21:22:50 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 | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index 84a63748..4c55b3dc 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -197,20 +197,7 @@ 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 atomic_t coldboot_done;
static unsigned long entry_count_offset;
static unsigned long init_count_offset;
@@ -254,10 +241,10 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
/*
* All non-coldboot HARTs do HSM initialization (i.e. enter HSM state
* machine) at the start of the warmboot path so it is wasteful to
- * have these HARTs busy spin in wait_for_coldboot() until coldboot
- * path is completed.
+ * have these HARTs busy spin in sbi_wait_for_boot_hart_first() until
+ * coldboot path is completed.
*/
- wake_coldboot_harts(scratch);
+ sbi_signal_boot_hart_first_done(true, &coldboot_done);
rc = sbi_platform_early_init(plat, true);
if (rc)
@@ -498,7 +485,7 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid)
{
int hstate;
- wait_for_coldboot(scratch);
+ sbi_wait_for_boot_hart_first(false, &coldboot_done);
hstate = sbi_hsm_hart_get_state(sbi_domain_thishart_ptr(), hartid);
if (hstate < 0)
--
2.47.2
More information about the opensbi
mailing list