[PATCH master 02/14] RISC-V: board-dt-2nd: fix hang in startup

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Apr 11 00:14:24 PDT 2023

relocate_to_current_adr() will do a sync_caches_for_execution() after
concluding. The method used for icache synchronization depends on the
CPU being used. Allwinner D1 support added the assumption that any
code running in S-Mode will have populated sscratch with the flags
before calling riscv_vendor_id(). This is not the case for
barebox-dt-2nd, which does relocation before riscv_set_flags().

Quick fix this by calling riscv_set_flags manually.

Cc: Marco Felsch <m.felsch at pengutronix.de>
Fixes: c986c565b023 ("RISC-V: use m/sscratch registers for barebox_riscv_pbl_flags")
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
 arch/riscv/boot/board-dt-2nd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/riscv/boot/board-dt-2nd.c b/arch/riscv/boot/board-dt-2nd.c
index 8b78e1b11d31..f1479d834615 100644
--- a/arch/riscv/boot/board-dt-2nd.c
+++ b/arch/riscv/boot/board-dt-2nd.c
@@ -50,6 +50,12 @@ static void noinline __noreturn start_dt_2nd_nonnaked(unsigned long hartid,
 	if (!fdt)
+	/*
+	 * We need to call this here, as a multiplatform build
+	 * depends on querying mode for riscv_vendor_id()
+	 */
+	riscv_set_flags(RISCV_S_MODE);

More information about the barebox mailing list