[PATCH] arm: rk3568 boards: call setup_c() before accessing global pointers

Sascha Hauer s.hauer at pengutronix.de
Wed Sep 21 02:13:16 PDT 2022


Global pointers may only be accessed after setup_c() has been called.

In pine-quartz64 and the Radxa Rock3 board the device tree pointer has
been initialized earlier. As a result the pointer points to the address
the device tree would be placed when the binary would run from 0x0. For
some reason it nevertheless seemed to work though.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/pine64-quartz64/lowlevel.c | 26 ++++++++++++----------
 arch/arm/boards/radxa-rock3/lowlevel.c     | 26 ++++++++++++----------
 2 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/arch/arm/boards/pine64-quartz64/lowlevel.c b/arch/arm/boards/pine64-quartz64/lowlevel.c
index b295885522..ae1f0cf920 100644
--- a/arch/arm/boards/pine64-quartz64/lowlevel.c
+++ b/arch/arm/boards/pine64-quartz64/lowlevel.c
@@ -10,18 +10,9 @@
 
 extern char __dtb_rk3566_quartz64_a_start[];
 
-static noinline void start_quartz64(void *fdt)
+static noinline void start_quartz64(void)
 {
-	/*
-	 * Image execution starts at 0x0, but this is used for ATF and
-	 * OP-TEE later, so move away from here.
-	 */
-	if (current_el() == 3)
-		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
-	else
-		relocate_to_current_adr();
-
-	setup_c();
+	void *fdt = __dtb_rk3566_quartz64_a_start;
 
 	if (current_el() == 3) {
 		rk3568_lowlevel_init();
@@ -35,5 +26,16 @@ static noinline void start_quartz64(void *fdt)
 
 ENTRY_FUNCTION(start_quartz64a, r0, r1, r2)
 {
-	start_quartz64(__dtb_rk3566_quartz64_a_start);
+	/*
+	 * Image execution starts at 0x0, but this is used for ATF and
+	 * OP-TEE later, so move away from here.
+	 */
+	if (current_el() == 3)
+		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
+	else
+		relocate_to_current_adr();
+
+	setup_c();
+
+	start_quartz64();
 }
diff --git a/arch/arm/boards/radxa-rock3/lowlevel.c b/arch/arm/boards/radxa-rock3/lowlevel.c
index 00a68889cd..2a449c17ae 100644
--- a/arch/arm/boards/radxa-rock3/lowlevel.c
+++ b/arch/arm/boards/radxa-rock3/lowlevel.c
@@ -10,18 +10,9 @@
 
 extern char __dtb_rk3568_rock_3a_start[];
 
-static noinline void rk3568_start(void *fdt)
+static noinline void rk3568_start(void)
 {
-	/*
-	 * Image execution starts at 0x0, but this is used for ATF and
-	 * OP-TEE later, so move away from here.
-	 */
-	if (current_el() == 3)
-		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
-	else
-		relocate_to_current_adr();
-
-	setup_c();
+	void *fdt = __dtb_rk3568_rock_3a_start;
 
 	/*
 	 * Enable vccio4 1.8V and vccio6 1.8V
@@ -40,5 +31,16 @@ static noinline void rk3568_start(void *fdt)
 
 ENTRY_FUNCTION(start_rock3a, r0, r1, r2)
 {
-	rk3568_start(__dtb_rk3568_rock_3a_start);
+	/*
+	 * Image execution starts at 0x0, but this is used for ATF and
+	 * OP-TEE later, so move away from here.
+	 */
+	if (current_el() == 3)
+		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
+	else
+		relocate_to_current_adr();
+
+	setup_c();
+
+	rk3568_start();
 }
-- 
2.30.2




More information about the barebox mailing list