diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-03-12 07:51:25 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-03-13 09:52:02 +0300 |
commit | 823345ecaed0deb7770d9bac1c881004a6410e91 (patch) | |
tree | e3b71fb186be4bebd610e796cc12f2d3f33424e6 /lib/sbi/sbi_system.c | |
parent | 16e7071f6ddd5ba69d416b5a68e4aa191fc19d3b (diff) | |
download | opensbi-823345ecaed0deb7770d9bac1c881004a6410e91.tar.xz |
include: Make sbi_current_hartid() as macro in riscv_asm.h
The sbi_current_hartid() being a regular function is quite
expensive because for callers it is a function call instead
of a direct CSR read. This patch converts sbi_current_hartid()
into a macro in riscv_asm.h.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_system.c')
-rw-r--r-- | lib/sbi/sbi_system.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c index 461e470..061cbf6 100644 --- a/lib/sbi/sbi_system.c +++ b/lib/sbi/sbi_system.c @@ -8,6 +8,7 @@ * Nick Kossifidis <mick@ics.forth.gr> */ +#include <sbi/riscv_asm.h> #include <sbi/sbi_bitops.h> #include <sbi/sbi_hart.h> #include <sbi/sbi_hsm.h> @@ -39,12 +40,12 @@ void sbi_system_final_exit(struct sbi_scratch *scratch) void __noreturn sbi_system_reboot(struct sbi_scratch *scratch, u32 type) { ulong hbase = 0, hmask; - u32 current_hartid = sbi_current_hartid(); + u32 cur_hartid = current_hartid(); /* Send HALT IPI to every hart other than the current hart */ while (!sbi_hsm_hart_started_mask(scratch, hbase, &hmask)) { - if (hbase <= current_hartid) - hmask &= ~(1UL << (current_hartid - hbase)); + if (hbase <= cur_hartid) + hmask &= ~(1UL << (cur_hartid - hbase)); if (hmask) sbi_ipi_send_halt(scratch, hmask, hbase); hbase += BITS_PER_LONG; @@ -63,12 +64,12 @@ void __noreturn sbi_system_reboot(struct sbi_scratch *scratch, u32 type) void __noreturn sbi_system_shutdown(struct sbi_scratch *scratch, u32 type) { ulong hbase = 0, hmask; - u32 current_hartid = sbi_current_hartid(); + u32 cur_hartid = current_hartid(); /* Send HALT IPI to every hart other than the current hart */ while (!sbi_hsm_hart_started_mask(scratch, hbase, &hmask)) { - if (hbase <= current_hartid) - hmask &= ~(1UL << (current_hartid - hbase)); + if (hbase <= cur_hartid) + hmask &= ~(1UL << (cur_hartid - hbase)); if (hmask) sbi_ipi_send_halt(scratch, hmask, hbase); hbase += BITS_PER_LONG; |