]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm: mediatek: mt8195: fix gd->bd->bi_dram[0].size
authorDavid Lechner <dlechner@baylibre.com>
Mon, 15 Jun 2026 19:23:37 +0000 (14:23 -0500)
committerDavid Lechner <dlechner@baylibre.com>
Wed, 24 Jun 2026 15:06:16 +0000 (10:06 -0500)
Use board_get_usable_ram_top() instead of get_effective_memsize() to
set gd->ram_top to something <= 4GiB.

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 d83bd9729d75 ("arm: mediatek: mt8195:
drop dram_init_banksize()"), gd->bd->bi_dram[0].size was overridden in
a board-specific dram_init_banksize() implementation. When that was
removed get_effective_memsize() set gd->bd->bi_dram[0].size to the wrong
value because of get_effective_memsize() being overridden in commit
af4cba9a05aa ("arm: mediatek: mt8195: fix gd->ram_top limit")

We can just use board_get_usable_ram_top() now to set gd->ram_top to the
correct value instead. This is possible now, thanks to
LMB_LIMIT_DMA_BELOW_RAM_TOP being set by default for 64-bit Mediatek
ARM SoCs.

Fixes: d83bd9729d75 ("arm: mediatek: mt8195: drop dram_init_banksize()")
Link: https://patch.msgid.link/20260615-mtk-fix-ram-size-v2-7-f72cfc52ce58@baylibre.com
Signed-off-by: David Lechner <dlechner@baylibre.com>
arch/arm/mach-mediatek/mt8195/init.c

index e31d4eec0fb68ad3d33d9cc6eff69bafd0003871..83cac9d01d694f07299be58b045fbf56cc75fe22 100644 (file)
@@ -20,13 +20,13 @@ 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 gd->ram_top not exceeding SZ_4G. Because some peripherals like
         * MMC requires DMA buffer allocated below SZ_4G.
         */
-       return min(SZ_4G - gd->ram_base, gd->ram_size);
+       return min(gd->ram_top, SZ_4G);
 }
 
 int mtk_soc_early_init(void)