Skip to contentSkip to conversation

rockchip: fix ordering of DRAM init

PATCH New Thomas Hebb 2 participants 6 messages Nov 15, 2019 – Nov 17, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 rockchip: fix ordering of DRAM init

b7abef2ecbcc ("rockchip: rk3399: Migrate to use common spl board file") removed SoC-specific code for RK3399's SPL and in the process reordered the DRAM initialization before rockchip_stimer_init(), which as far as I can tell causes the RK3399 to lock up completely.

Fix this issue in the common code by putting the DRAM init back after timer init. I have only tested this on the RK3399, but it wouldn't make any sense for the timer init to require DRAM be set up on any system.

---
 arch/arm/mach-rockchip/spl.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-rockchip/spl.c +7 -7
index 92102b39e7..5570bb1339 100644
@@ -128,6 +128,13 @@ void board_init_f(ulong dummy)
 		hang();
 	}
 	arch_cpu_init();
+#if !defined(CONFIG_ROCKCHIP_RK3188)
+	rockchip_stimer_init();
+#endif
+#ifdef CONFIG_SYS_ARCH_TIMER
+	/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
+	timer_init();
+#endif
 #if !defined(CONFIG_SUPPORT_TPL) || defined(CONFIG_SPL_OS_BOOT)
 	debug("\nspl:init dram\n");
 	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
@@ -135,13 +142,6 @@ void board_init_f(ulong dummy)
 		printf("DRAM init failed: %d\n", ret);
 		return;
 	}
-#endif
-#if !defined(CONFIG_ROCKCHIP_RK3188)
-	rockchip_stimer_init();
-#endif
-#ifdef CONFIG_SYS_ARCH_TIMER
-	/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
-	timer_init();
 #endif
 	preloader_console_init();
 }
Signature · 1 line
2.23.0
#1 lore raw

PATCH v2 2/3 rockchip: allow DRAM init in SPL

b7abef2ecbcc ("rockchip: rk3399: Migrate to use common spl board file") removed SoC-specific code for RK3399's SPL and in the process caused the previously-unconditional DRAM initialization in board_init_f() to only happen when compiling a configuration that does not support TPL, meaning DRAM never gets initialized if TPL is supported but disabled.

Fix this by omitting the DRAM init in SPL only when we are configured to also build a TPL. This fixes custom configurations that have disabled TPL, and it should also unbreak the "ficus-rk3399", "rock960-rk3399", and "chromebook_bob" defconfigs, although since I don't have any of those devices I can't confirm they're broken now.

---
 arch/arm/mach-rockchip/spl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/spl.c +2 -2
index 5570bb1339..089f0a5258 100644
@@ -103,7 +103,7 @@ __weak int arch_cpu_init(void)
 void board_init_f(ulong dummy)
 {
 	int ret;
-#if !defined(CONFIG_SUPPORT_TPL) || defined(CONFIG_SPL_OS_BOOT)
+#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
 	struct udevice *dev;
 #endif
 
@@ -135,7 +135,7 @@ void board_init_f(ulong dummy)
 	/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
 	timer_init();
 #endif
-#if !defined(CONFIG_SUPPORT_TPL) || defined(CONFIG_SPL_OS_BOOT)
+#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
 	debug("\nspl:init dram\n");
 	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
 	if (ret) {
Signature · 1 line
2.23.0
#2 lore raw

PATCH v2 2/3 rockchip: allow DRAM init in SPL

Quoted 6 lines · Thomas Hebb

b7abef2ecbcc ("rockchip: rk3399: Migrate to use common spl board file") removed SoC-specific code for RK3399's SPL and in the process caused the previously-unconditional DRAM initialization in board_init_f() to only happen when compiling a configuration that does not support TPL, meaning DRAM never gets initialized if TPL is supported but disabled.

Quoted 7 lines

Fix this by omitting the DRAM init in SPL only when we are configured to also build a TPL. This fixes custom configurations that have disabled TPL, and it should also unbreak the "ficus-rk3399", "rock960-rk3399", and "chromebook_bob" defconfigs, although since I don't have any of those devices I can't confirm they're broken now.

Thanks,
- Kever

Quoted 26 lines
---
  arch/arm/mach-rockchip/spl.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/spl.c +2 -2
index 5570bb1339..089f0a5258 100644
@@ -103,7 +103,7 @@ __weak int arch_cpu_init(void)
  void board_init_f(ulong dummy)
  {
  	int ret;
-#if !defined(CONFIG_SUPPORT_TPL) || defined(CONFIG_SPL_OS_BOOT)
+#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
  	struct udevice *dev;
  #endif
 
@@ -135,7 +135,7 @@ void board_init_f(ulong dummy)
  	/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
  	timer_init();
  #endif
-#if !defined(CONFIG_SUPPORT_TPL) || defined(CONFIG_SPL_OS_BOOT)
+#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
  	debug("\nspl:init dram\n");
  	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
  	if (ret) {
#3 lore raw

PATCH v2 3/3 rockchip: imply instead of selecting SPL_SYS_MALLOC_SIMPLE

In reply to Thomas Hebb

We shouldn't force which allocator the SPL uses, since there's no platform requirement for one over the other: in fact, we currently allow selection of the TPL allocator but not the SPL one!

---
 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
index 7b80630aa1..f96841c777 100644
@@ -1604,7 +1604,6 @@ config ARCH_ROCKCHIP
 	select OF_CONTROL
 	select SPI
 	select SPL_DM if SPL
-	select SPL_SYS_MALLOC_SIMPLE if SPL
 	select SYS_MALLOC_F
 	select SYS_THUMB_BUILD if !ARM64
 	imply ADC
@@ -1614,6 +1613,7 @@ config ARCH_ROCKCHIP
 	imply FAT_WRITE
 	imply SARADC_ROCKCHIP
 	imply SPL_SYSRESET
+	imply SPL_SYS_MALLOC_SIMPLE
 	imply SYS_NS16550
 	imply TPL_SYSRESET
 	imply USB_FUNCTION_FASTBOOT
Signature · 1 line
2.23.0
#4 lore raw

PATCH v2 3/3 rockchip: imply instead of selecting SPL_SYS_MALLOC_SIMPLE

Quoted 5 lines · Thomas Hebb

We shouldn't force which allocator the SPL uses, since there's no platform requirement for one over the other: in fact, we currently allow selection of the TPL allocator but not the SPL one!

Thanks,
- Kever

Quoted 24 lines
---
  arch/arm/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
index 7b80630aa1..f96841c777 100644
@@ -1604,7 +1604,6 @@ config ARCH_ROCKCHIP
  	select OF_CONTROL
  	select SPI
  	select SPL_DM if SPL
-	select SPL_SYS_MALLOC_SIMPLE if SPL
  	select SYS_MALLOC_F
  	select SYS_THUMB_BUILD if !ARM64
  	imply ADC
@@ -1614,6 +1613,7 @@ config ARCH_ROCKCHIP
  	imply FAT_WRITE
  	imply SARADC_ROCKCHIP
  	imply SPL_SYSRESET
+	imply SPL_SYS_MALLOC_SIMPLE
  	imply SYS_NS16550
  	imply TPL_SYSRESET
  	imply USB_FUNCTION_FASTBOOT
#5 lore raw

PATCH v2 1/3 rockchip: fix ordering of DRAM init

In reply to Thomas Hebb
Quoted 10 lines · Thomas Hebb

b7abef2ecbcc ("rockchip: rk3399: Migrate to use common spl board file") removed SoC-specific code for RK3399's SPL and in the process reordered the DRAM initialization before rockchip_stimer_init(), which as far as I can tell causes the RK3399 to lock up completely.

Fix this issue in the common code by putting the DRAM init back after timer init. I have only tested this on the RK3399, but it wouldn't make any sense for the timer init to require DRAM be set up on any system.

Thanks,
- Kever

Quoted 36 lines
---
  arch/arm/mach-rockchip/spl.c | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-rockchip/spl.c +7 -7
index 92102b39e7..5570bb1339 100644
@@ -128,6 +128,13 @@ void board_init_f(ulong dummy)
  		hang();
  	}
  	arch_cpu_init();
+#if !defined(CONFIG_ROCKCHIP_RK3188)
+	rockchip_stimer_init();
+#endif
+#ifdef CONFIG_SYS_ARCH_TIMER
+	/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
+	timer_init();
+#endif
  #if !defined(CONFIG_SUPPORT_TPL) || defined(CONFIG_SPL_OS_BOOT)
  	debug("\nspl:init dram\n");
  	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
@@ -135,13 +142,6 @@ void board_init_f(ulong dummy)
  		printf("DRAM init failed: %d\n", ret);
  		return;
  	}
-#endif
-#if !defined(CONFIG_ROCKCHIP_RK3188)
-	rockchip_stimer_init();
-#endif
-#ifdef CONFIG_SYS_ARCH_TIMER
-	/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
-	timer_init();
  #endif
  	preloader_console_init();
  }