[PATCH 7/7] arm: mediatek: mt8512: fix gd->bd->bi_dram[0].size

David Lechner dlechner at baylibre.com
Thu Jun 11 22:31:06 CEST 2026


Use board_get_usable_ram_top() instead of get_effective_memsize() to
limit gd->ram_top.

Both board_get_usable_ram_top() and get_effective_memsize() are used to
set gd->ram_top in setup_dest_addr(). However, get_effective_memsize()
also sets gd->bd->bi_dram[0].size in dram_init_banksize(), which is
undesirable.

Prior to commit b9e6281632a8 ("arm: mediatek: mt8512:
drop dram_init_banksize()"), gd->bd->bi_dram[0].size was overridden in
a board-specific dram_init_banksize() implementation.

We can just use board_get_usable_ram_top() now to set gd->ram_top to the
correct value instead. Overriding gd->bd->bi_dram[0].size was a bit
confusing since it isn't easily apparent which order the functions that
set it are called.

Fixes: b9e6281632a8 ("arm: mediatek: mt8512: drop dram_init_banksize()")
Signed-off-by: David Lechner <dlechner at baylibre.com>
---
 arch/arm/mach-mediatek/mt8512/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mediatek/mt8512/init.c b/arch/arm/mach-mediatek/mt8512/init.c
index bc1d515fcca..6a9ae776794 100644
--- a/arch/arm/mach-mediatek/mt8512/init.c
+++ b/arch/arm/mach-mediatek/mt8512/init.c
@@ -29,10 +29,10 @@ int dram_init(void)
 	return fdtdec_setup_mem_size_base();
 }
 
-phys_size_t  get_effective_memsize(void)
+phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
 {
 	/* limit stack below tee reserve memory */
-	return gd->ram_size - 6 * SZ_1M;
+	return gd->ram_base + gd->ram_size - 6 * SZ_1M;
 }
 
 void reset_cpu(void)

-- 
2.43.0



More information about the U-Boot mailing list