summaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_system.c
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-03-02 13:49:49 +0300
committerAnup Patel <anup@brainfault.org>2020-03-11 13:00:23 +0300
commit466fecb95732c6c7eb98e897df71996d0cef479b (patch)
tree8f14bd26f5447031ad14333c2e124ece32a80eb1 /lib/sbi/sbi_system.c
parent61f776861fcabd617f7d1cbd5e5b327500b04f38 (diff)
downloadopensbi-466fecb95732c6c7eb98e897df71996d0cef479b.tar.xz
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 <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'lib/sbi/sbi_system.c')
-rw-r--r--lib/sbi/sbi_system.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c
index 68fad0f..461e470 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 */