All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] riscv: Introduce AVAILABLE_HARTS
@ 2022-09-21  6:34 Andes
  2022-09-21  6:34 ` [PATCH 2/2] riscv: ae350: Disable AVAILABLE_HARTS Andes
  2022-09-22  3:32 ` [PATCH 1/2] riscv: Introduce AVAILABLE_HARTS Leo Liang
  0 siblings, 2 replies; 4+ messages in thread
From: Andes @ 2022-09-21  6:34 UTC (permalink / raw)
  To: u-boot
  Cc: bmeng.cn, lukas.auer, anup, atishp, xypron.glpk, nikita.shubin,
	seanga2, ycliang, rick, rickchen36

From: Rick Chen <rick@andestech.com>

In SMP all harts will register themself in available_hart
during start up. Then main hart will send IPI to other harts
according to this variables. But this mechanism may not
guarantee that all other harts can jump to next stage.

When main hart is sending IPI to other hart according to
available_harts, but other harts maybe still not finish the
registration. Then the SMP booting will miss some harts finally.
So let it become an option and it will be enabled by default.

Please refer to the discussion:
https://www.mail-archive.com/u-boot@lists.denx.de/msg449997.html

Signed-off-by: Rick Chen <rick@andestech.com>
---
 arch/riscv/Kconfig                   |  7 +++++++
 arch/riscv/cpu/cpu.c                 |  2 ++
 arch/riscv/cpu/start.S               | 13 ++++++++-----
 arch/riscv/include/asm/global_data.h |  2 ++
 arch/riscv/lib/asm-offsets.c         |  2 ++
 arch/riscv/lib/smp.c                 |  2 ++
 6 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index c042506a64..32a90b83b5 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -276,6 +276,13 @@ config SPL_XIP
 	  rely on lock variables (for example hart_lottery and available_harts_lock),
 	  this affects only SPL, other stages should proceed as non-XIP.
 
+config AVAILABLE_HARTS
+	bool "Send IPI by available harts"
+	default y
+	help
+	  By default, IPI sending mechanism will depend on available_harts.
+	  If disable this, it will send IPI by CPUs node numbers of device tree.
+
 config SHOW_REGS
 	bool "Show registers on unhandled exception"
 
diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
index 0f323b26b3..52ab02519f 100644
--- a/arch/riscv/cpu/cpu.c
+++ b/arch/riscv/cpu/cpu.c
@@ -22,12 +22,14 @@
 #if !CONFIG_IS_ENABLED(XIP)
 u32 hart_lottery __section(".data") = 0;
 
+#ifdef CONFIG_AVAILABLE_HARTS
 /*
  * The main hart running U-Boot has acquired available_harts_lock until it has
  * finished initialization of global data.
  */
 u32 available_harts_lock = 1;
 #endif
+#endif
 
 static inline bool supports_extension(char ext)
 {
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
index de9d078da1..4687bca3c9 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -153,21 +153,23 @@ call_harts_early_init:
 	SREG	tp, GD_BOOT_HART(gp)
 
 #if !CONFIG_IS_ENABLED(XIP)
+#ifdef CONFIG_AVAILABLE_HARTS
 	la	t0, available_harts_lock
 	amoswap.w.rl zero, zero, 0(t0)
+#endif
 
 wait_for_gd_init:
-	la	t0, available_harts_lock
-	li	t1, 1
-1:	amoswap.w.aq t1, t1, 0(t0)
-	bnez	t1, 1b
-
 	/*
 	 * Set the global data pointer only when gd_t has been initialized.
 	 * This was already set by arch_setup_gd on the boot hart, but all other
 	 * harts' global data pointers gets set here.
 	 */
 	mv	gp, s0
+#ifdef CONFIG_AVAILABLE_HARTS
+	la	t0, available_harts_lock
+	li	t1, 1
+1:	amoswap.w.aq t1, t1, 0(t0)
+	bnez	t1, 1b
 
 	/* register available harts in the available_harts mask */
 	li	t1, 1
@@ -177,6 +179,7 @@ wait_for_gd_init:
 	SREG	t2, GD_AVAILABLE_HARTS(gp)
 
 	amoswap.w.rl zero, zero, 0(t0)
+#endif
 
 	/*
 	 * Continue on hart lottery winner, others branch to
diff --git a/arch/riscv/include/asm/global_data.h b/arch/riscv/include/asm/global_data.h
index b3c79e1760..858594a191 100644
--- a/arch/riscv/include/asm/global_data.h
+++ b/arch/riscv/include/asm/global_data.h
@@ -28,8 +28,10 @@ struct arch_global_data {
 	struct ipi_data ipi[CONFIG_NR_CPUS];
 #endif
 #if !CONFIG_IS_ENABLED(XIP)
+#ifdef CONFIG_AVAILABLE_HARTS
 	ulong available_harts;
 #endif
+#endif
 };
 
 #include <asm-generic/global_data.h>
diff --git a/arch/riscv/lib/asm-offsets.c b/arch/riscv/lib/asm-offsets.c
index c4f48c8373..452dfcea97 100644
--- a/arch/riscv/lib/asm-offsets.c
+++ b/arch/riscv/lib/asm-offsets.c
@@ -17,7 +17,9 @@ int main(void)
 	DEFINE(GD_BOOT_HART, offsetof(gd_t, arch.boot_hart));
 	DEFINE(GD_FIRMWARE_FDT_ADDR, offsetof(gd_t, arch.firmware_fdt_addr));
 #if !CONFIG_IS_ENABLED(XIP)
+#ifdef CONFIG_AVAILABLE_HARTS
 	DEFINE(GD_AVAILABLE_HARTS, offsetof(gd_t, arch.available_harts));
+#endif
 #endif
 
 	return 0;
diff --git a/arch/riscv/lib/smp.c b/arch/riscv/lib/smp.c
index f8b756291f..c0f65af191 100644
--- a/arch/riscv/lib/smp.c
+++ b/arch/riscv/lib/smp.c
@@ -46,9 +46,11 @@ static int send_ipi_many(struct ipi_data *ipi, int wait)
 		}
 
 #if !CONFIG_IS_ENABLED(XIP)
+#ifdef CONFIG_AVAILABLE_HARTS
 		/* skip if hart is not available */
 		if (!(gd->arch.available_harts & (1 << reg)))
 			continue;
+#endif
 #endif
 
 		gd->arch.ipi[reg].addr = ipi->addr;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] riscv: ae350: Disable AVAILABLE_HARTS
  2022-09-21  6:34 [PATCH 1/2] riscv: Introduce AVAILABLE_HARTS Andes
@ 2022-09-21  6:34 ` Andes
  2022-09-22  3:33   ` Leo Liang
  2022-09-22  3:32 ` [PATCH 1/2] riscv: Introduce AVAILABLE_HARTS Leo Liang
  1 sibling, 1 reply; 4+ messages in thread
From: Andes @ 2022-09-21  6:34 UTC (permalink / raw)
  To: u-boot
  Cc: bmeng.cn, lukas.auer, anup, atishp, xypron.glpk, nikita.shubin,
	seanga2, ycliang, rick, rickchen36

From: Rick Chen <rick@andestech.com>

Disable AVAILABLE_HARTS mechanism to make sure that all harts
can boot to Kernel shell successfully.

Signed-off-by: Rick Chen <rick@andestech.com>
---
 configs/ae350_rv32_spl_defconfig | 1 +
 configs/ae350_rv64_spl_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/ae350_rv32_spl_defconfig b/configs/ae350_rv32_spl_defconfig
index 9b79cc41b5..1cc98a2653 100644
--- a/configs/ae350_rv32_spl_defconfig
+++ b/configs/ae350_rv32_spl_defconfig
@@ -48,3 +48,4 @@ CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_ATCSPI200_SPI=y
 # CONFIG_BINMAN_FDT is not set
+# CONFIG_AVAILABLE_HARTS is not set
diff --git a/configs/ae350_rv64_spl_defconfig b/configs/ae350_rv64_spl_defconfig
index 4c33ca2383..4318300300 100644
--- a/configs/ae350_rv64_spl_defconfig
+++ b/configs/ae350_rv64_spl_defconfig
@@ -49,3 +49,4 @@ CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_ATCSPI200_SPI=y
 # CONFIG_BINMAN_FDT is not set
+# CONFIG_AVAILABLE_HARTS is not set
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] riscv: Introduce AVAILABLE_HARTS
  2022-09-21  6:34 [PATCH 1/2] riscv: Introduce AVAILABLE_HARTS Andes
  2022-09-21  6:34 ` [PATCH 2/2] riscv: ae350: Disable AVAILABLE_HARTS Andes
@ 2022-09-22  3:32 ` Leo Liang
  1 sibling, 0 replies; 4+ messages in thread
From: Leo Liang @ 2022-09-22  3:32 UTC (permalink / raw)
  To: Andes
  Cc: u-boot, bmeng.cn, lukas.auer, anup, atishp, xypron.glpk,
	nikita.shubin, seanga2, rick, rickchen36

On Wed, Sep 21, 2022 at 02:34:54PM +0800, Andes wrote:
> From: Rick Chen <rick@andestech.com>
> 
> In SMP all harts will register themself in available_hart
> during start up. Then main hart will send IPI to other harts
> according to this variables. But this mechanism may not
> guarantee that all other harts can jump to next stage.
> 
> When main hart is sending IPI to other hart according to
> available_harts, but other harts maybe still not finish the
> registration. Then the SMP booting will miss some harts finally.
> So let it become an option and it will be enabled by default.
> 
> Please refer to the discussion:
> https://www.mail-archive.com/u-boot@lists.denx.de/msg449997.html
> 
> Signed-off-by: Rick Chen <rick@andestech.com>
> ---
>  arch/riscv/Kconfig                   |  7 +++++++
>  arch/riscv/cpu/cpu.c                 |  2 ++
>  arch/riscv/cpu/start.S               | 13 ++++++++-----
>  arch/riscv/include/asm/global_data.h |  2 ++
>  arch/riscv/lib/asm-offsets.c         |  2 ++
>  arch/riscv/lib/smp.c                 |  2 ++
>  6 files changed, 23 insertions(+), 5 deletions(-)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] riscv: ae350: Disable AVAILABLE_HARTS
  2022-09-21  6:34 ` [PATCH 2/2] riscv: ae350: Disable AVAILABLE_HARTS Andes
@ 2022-09-22  3:33   ` Leo Liang
  0 siblings, 0 replies; 4+ messages in thread
From: Leo Liang @ 2022-09-22  3:33 UTC (permalink / raw)
  To: Andes
  Cc: u-boot, bmeng.cn, lukas.auer, anup, atishp, xypron.glpk,
	nikita.shubin, seanga2, rick, rickchen36

On Wed, Sep 21, 2022 at 02:34:55PM +0800, Andes wrote:
> From: Rick Chen <rick@andestech.com>
> 
> Disable AVAILABLE_HARTS mechanism to make sure that all harts
> can boot to Kernel shell successfully.
> 
> Signed-off-by: Rick Chen <rick@andestech.com>
> ---
>  configs/ae350_rv32_spl_defconfig | 1 +
>  configs/ae350_rv64_spl_defconfig | 1 +
>  2 files changed, 2 insertions(+)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-22  3:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21  6:34 [PATCH 1/2] riscv: Introduce AVAILABLE_HARTS Andes
2022-09-21  6:34 ` [PATCH 2/2] riscv: ae350: Disable AVAILABLE_HARTS Andes
2022-09-22  3:33   ` Leo Liang
2022-09-22  3:32 ` [PATCH 1/2] riscv: Introduce AVAILABLE_HARTS Leo Liang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.