]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
stm32mp: correctly handle board_get_usable_ram_top(0)
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Mon, 26 Jul 2021 09:55:27 +0000 (11:55 +0200)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Mon, 16 Aug 2021 08:49:35 +0000 (10:49 +0200)
The function board_get_usable_ram_top can be called after relocation
with total_size = 0 to get the uppermost pointer that is valid to access
in U-Boot.

When total_size = 0, the reserved memory should be not take in account
with lmb library and 'gd->ram_base + gd->ram_size' can be used.

It is the case today in lib/efi_loader/efi_memory.c:efi_add_known_memory()
and this patch avoids that the reserved memory for OP-TEE is not part of
the EFI available memory regions.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
arch/arm/mach-stm32mp/dram_init.c

index 3c097029bda0be128112df0cadce4e7753bccf5d..94f25f34e03452cc13e590b109fdb4b409a1aa52 100644 (file)
@@ -46,6 +46,9 @@ ulong board_get_usable_ram_top(ulong total_size)
        phys_addr_t reg;
        struct lmb lmb;
 
+       if (!total_size)
+               return gd->ram_base + gd->ram_size;
+
        /* found enough not-reserved memory to relocated U-Boot */
        lmb_init(&lmb);
        lmb_add(&lmb, gd->ram_base, gd->ram_size);