Skip to contentSkip to conversation

ddr: imx: keep ddrmix_initialized out of .bss

PATCH In review Dario Binacchi 3 participants 3 messages Oct 29 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ddr: imx: keep ddrmix_initialized out of .bss

ddr_init() is called from board_init_f(), before .bss is cleared, so ddrmix_initialized may already be non-zero on the first call. The DDRMIX cold reset is then run on a DDRMIX that has never been initialized and the SPL hangs (with DEBUG enabled in ddr_init.c):

DDRINFO: start DRAM init
DDRINFO: cold reset the DDRMIX

Move ddrmix_initialized to .data, so that it is zero on the first call.

Fixes ae03528affd3 ("ddr: imx: Recreate the power-on state before repeating ddr_init()")

---

 drivers/ddr/imx/imx8m/ddr_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/imx/imx8m/ddr_init.c +1 -1
index b2873ab439d7..154e9d887465 100644
@@ -48,7 +48,7 @@
 #define CCGR_DDRMIX			CCGR_DDR1
 #endif
 
-static bool ddrmix_initialized;
+static bool ddrmix_initialized __section(".data");
 
 static unsigned int g_cdd_rr_max[4];
 static unsigned int g_cdd_rw_max[4];

---
base-commit: 03e45557e1f38a39a0c80fe30483130ff376cf92
branch: imx8m-ddrmix-initialized-data

Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Dario,

Quoted 5 lines · Dario Binacchi

ddr_init() is called from board_init_f(), before .bss is cleared, so ddrmix_initialized may already be non-zero on the first call. The DDRMIX cold reset is then run on a DDRMIX that has never been initialized and the SPL hangs (with DEBUG enabled in ddr_init.c):

Quoted 7 lines

DDRINFO: start DRAM init
DDRINFO: cold reset the DDRMIX

Move ddrmix_initialized to .data, so that it is zero on the first call.

Fixes ae03528affd3 ("ddr: imx: Recreate the power-on state before repeating ddr_init()")

This issue didn't show up in my tests on i.MX8MM and i.MX8MP, but it looks correct to me.

Thanks for fixing this!

Best regards
Frieder

Quoted 23 lines

---

 drivers/ddr/imx/imx8m/ddr_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/imx/imx8m/ddr_init.c +1 -2
index b2873ab439d7..154e9d887465 100644
@@ -48,7 +48,7 @@
 #define CCGR_DDRMIX			CCGR_DDR1
 #endif
 
-static bool ddrmix_initialized;
+static bool ddrmix_initialized __section(".data");
 
 static unsigned int g_cdd_rr_max[4];
 static unsigned int g_cdd_rw_max[4];
---

base-commit: 03e45557e1f38a39a0c80fe30483130ff376cf92
branch: imx8m-ddrmix-initialized-data

Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Dario Binacchi
Quoted 5 lines · Dario Binacchi

ddr_init() is called from board_init_f(), before .bss is cleared, so ddrmix_initialized may already be non-zero on the first call. The DDRMIX cold reset is then run on a DDRMIX that has never been initialized and the SPL hangs (with DEBUG enabled in ddr_init.c):

Quoted 8 lines

DDRINFO: start DRAM init
DDRINFO: cold reset the DDRMIX

Move ddrmix_initialized to .data, so that it is zero on the first call.

Fixes ae03528affd3 ("ddr: imx: Recreate the power-on state before repeating ddr_init()")

[...]

3 out of 6 Verdin iMX8M Plus and the SMARC iMX8M Plus SoMs in our CI farm were hanging in SPL, this patch fixes it.

Thanks!

Emanuele