diff options
author | Atish Patra <atish.patra@wdc.com> | 2020-02-12 04:32:37 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-02-24 15:37:55 +0300 |
commit | b677a9b8d641f1c16a4f8f52e00019a9bc747893 (patch) | |
tree | 5fa5b11867958b81cbeec0678819b60512fb9386 /lib/sbi/sbi_init.c | |
parent | f64f4b92e411709227ee830bc1e9f8f87c72423e (diff) | |
download | opensbi-b677a9b8d641f1c16a4f8f52e00019a9bc747893.tar.xz |
lib: Implement hart hotplug
This patch adds support for hart hotplug in OpenSBI using a generic WFI
based approach. Hart hotplug can be achieved via SBI HSM extension which
allows supervisor mode software to start or stop any harts anytime.
Any platform wishes to implement platform specific hart hotplug must
implement both hart_start and hart_stop in addition to enable platform
feature SBI_PLATFORM_HAS_HART_HOTPLUG.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_init.c')
-rw-r--r-- | lib/sbi/sbi_init.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 48bc653..1f113b9 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -12,6 +12,7 @@ #include <sbi/sbi_console.h> #include <sbi/sbi_ecall.h> #include <sbi/sbi_hart.h> +#include <sbi/sbi_hsm.h> #include <sbi/sbi_ipi.h> #include <sbi/sbi_platform.h> #include <sbi/sbi_system.h> @@ -85,6 +86,10 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) if (!init_count_offset) sbi_hart_hang(); + rc = sbi_hsm_init(scratch, hartid, TRUE); + if (rc) + sbi_hart_hang(); + rc = sbi_system_early_init(scratch, TRUE); if (rc) sbi_hart_hang(); @@ -131,6 +136,7 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) init_count = sbi_scratch_offset_ptr(scratch, init_count_offset); (*init_count)++; + sbi_hsm_prepare_next_jump(scratch, hartid); sbi_hart_switch_mode(hartid, scratch->next_arg1, scratch->next_addr, scratch->next_mode, FALSE); } @@ -146,6 +152,10 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid) if (!init_count_offset) sbi_hart_hang(); + rc = sbi_hsm_init(scratch, hartid, FALSE); + if (rc) + sbi_hart_hang(); + rc = sbi_system_early_init(scratch, FALSE); if (rc) sbi_hart_hang(); @@ -179,6 +189,7 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid) init_count = sbi_scratch_offset_ptr(scratch, init_count_offset); (*init_count)++; + sbi_hsm_prepare_next_jump(scratch, hartid); sbi_hart_switch_mode(hartid, scratch->next_arg1, scratch->next_addr, scratch->next_mode, FALSE); @@ -260,5 +271,5 @@ void __noreturn sbi_exit(struct sbi_scratch *scratch) sbi_platform_final_exit(plat); - sbi_hart_hang(); + sbi_hsm_exit(scratch); } |