diff mbox series

[U-Boot,19/19] riscv: Allow U-Boot to run on hart 0 only

Message ID 1542097327-6629-20-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Andes
Headers show
Series riscv: Adding RISC-V CPU and timer driver | expand

Commit Message

Bin Meng Nov. 13, 2018, 8:22 a.m. UTC
Allow U-Boot to run on hart 0 only, and suspend other harts.

With this change, '-smp n' works on QEMU RISC-V board.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

 arch/riscv/cpu/start.S | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Lukas Auer Nov. 14, 2018, 11:05 p.m. UTC | #1
Hi Bin,

On Tue, 2018-11-13 at 00:22 -0800, Bin Meng wrote:
> Allow U-Boot to run on hart 0 only, and suspend other harts.
> 
> With this change, '-smp n' works on QEMU RISC-V board.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> 
> ---
> 
>  arch/riscv/cpu/start.S | 4 ++++
>  1 file changed, 4 insertions(+)
> 

Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>

I'll try to send my patch series with multi-hart support soon, so I
hope we won't need this patch for long :)

> diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
> index 9858058..fcb0466 100644
> --- a/arch/riscv/cpu/start.S
> +++ b/arch/riscv/cpu/start.S
> @@ -46,6 +46,10 @@ _start:
>  	/* mask all interrupts */
>  	csrw	mie, zero
>  
> +	csrr t0, mhartid
> +	beqz t0, call_board_init_f
> +1:	j 1b
> +

To suspend the other harts, you can also add a WFI instruction before
the jump instruction.

Thanks,
Lukas

>  /*
>   * Set stackpointer in internal/ex RAM to call board_init_f
>   */
diff mbox series

Patch

diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
index 9858058..fcb0466 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -46,6 +46,10 @@  _start:
 	/* mask all interrupts */
 	csrw	mie, zero
 
+	csrr t0, mhartid
+	beqz t0, call_board_init_f
+1:	j 1b
+
 /*
  * Set stackpointer in internal/ex RAM to call board_init_f
  */