diff options
| author | Anup Patel <[email protected]> | 2020-03-02 16:19:49 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2020-03-11 15:30:23 +0530 |
| commit | 466fecb95732c6c7eb98e897df71996d0cef479b (patch) | |
| tree | 8f14bd26f5447031ad14333c2e124ece32a80eb1 | |
| parent | 61f776861fcabd617f7d1cbd5e5b327500b04f38 (diff) | |
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 <[email protected]>
Reviewed-by: Bin Meng <[email protected]>
| -rw-r--r-- | lib/sbi/sbi_system.c | 26 |
1 files 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 */ |
