From 466fecb95732c6c7eb98e897df71996d0cef479b Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Mon, 2 Mar 2020 16:19:49 +0530 Subject: [PATCH] lib: sbi_system: Use sbi_hsm_hart_started_mask() API This patch replaces use of sbi_hart_available_mask() API with sbi_hsm_hart_started_mask() API. Signed-off-by: Anup Patel Reviewed-by: Bin Meng --- lib/sbi/sbi_system.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c index 68fad0fe..461e4703 100644 --- a/lib/sbi/sbi_system.c +++ b/lib/sbi/sbi_system.c @@ -38,12 +38,19 @@ void sbi_system_final_exit(struct sbi_scratch *scratch) void __noreturn sbi_system_reboot(struct sbi_scratch *scratch, u32 type) { - u32 current_hartid_mask = 1UL << sbi_current_hartid(); + ulong hbase = 0, hmask; + u32 current_hartid = sbi_current_hartid(); /* Send HALT IPI to every hart other than the current hart */ - sbi_ipi_send_halt(scratch, - sbi_hart_available_mask() & ~current_hartid_mask, 0); + while (!sbi_hsm_hart_started_mask(scratch, hbase, &hmask)) { + if (hbase <= current_hartid) + hmask &= ~(1UL << (current_hartid - hbase)); + if (hmask) + sbi_ipi_send_halt(scratch, hmask, hbase); + hbase += BITS_PER_LONG; + } + /* Stop current HART */ sbi_hsm_hart_stop(scratch, FALSE); /* Platform specific reooot */ @@ -55,12 +62,19 @@ void __noreturn sbi_system_reboot(struct sbi_scratch *scratch, u32 type) void __noreturn sbi_system_shutdown(struct sbi_scratch *scratch, u32 type) { - u32 current_hartid_mask = 1UL << sbi_current_hartid(); + ulong hbase = 0, hmask; + u32 current_hartid = sbi_current_hartid(); /* Send HALT IPI to every hart other than the current hart */ - sbi_ipi_send_halt(scratch, - sbi_hart_available_mask() & ~current_hartid_mask, 0); + while (!sbi_hsm_hart_started_mask(scratch, hbase, &hmask)) { + if (hbase <= current_hartid) + hmask &= ~(1UL << (current_hartid - hbase)); + if (hmask) + sbi_ipi_send_halt(scratch, hmask, hbase); + hbase += BITS_PER_LONG; + } + /* Stop current HART */ sbi_hsm_hart_stop(scratch, FALSE); /* Platform specific shutdown */