From b4fa246a1565aa63375de06b732c6d1eb1f82d27 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 15 Jun 2026 14:23:38 -0500 Subject: [PATCH] arm: mediatek: mt8512: fix gd->bd->bi_dram[0].size 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()") Link: https://patch.msgid.link/20260615-mtk-fix-ram-size-v2-8-f72cfc52ce58@baylibre.com Signed-off-by: David Lechner --- 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)