[PATCH v2 2/3] rockchip: sdram: Limit usable ram_top to max 4G

Jonas Karlman jonas at kwiboo.se
Sun Jan 26 23:49:41 CET 2025


U-Boot only works correctly when it uses RAM below the 4G address
boundary on Rockchip SoCs. Limit usable gd->ram_top to max 4G.

Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
---
v2: New patch
---
 arch/arm/mach-rockchip/sdram.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c
index 3d3fc327234f..08deebb765f0 100644
--- a/arch/arm/mach-rockchip/sdram.c
+++ b/arch/arm/mach-rockchip/sdram.c
@@ -488,7 +488,10 @@ int dram_init(void)
 
 phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
 {
-	unsigned long top = CFG_SYS_SDRAM_BASE + SDRAM_MAX_SIZE;
+	unsigned long top;
+
+	/* Make sure U-Boot only uses the space below the 4G address boundary */
+	top = min_t(ulong, CFG_SYS_SDRAM_BASE + SDRAM_MAX_SIZE, (ulong)SZ_4G);
 
 	return (gd->ram_top > top) ? top : gd->ram_top;
 }
-- 
2.48.1



More information about the U-Boot mailing list