[PATCH] arm: stm32mp: Fix board_get_usable_ram_top() again

Patrick DELAUNAY patrick.delaunay at foss.st.com
Fri Jan 6 17:56:15 CET 2023


Hi Marek,

On 1/5/23 02:22, Marek Vasut wrote:
> Do not access gd->ram_size and assume this is actual valid RAM size. Since commit
> 777aaaa706b ("common/memsize.c: Fix get_effective_memsize() to check for overflow")
> the RAM size may be less than gd->ram_size , call get_effective_memsize() to get
> the limited value instead.
>
> The aforementioned commit makes STM32MP15xx boards with 1 GiB of DRAM
> at 0xc0000000 hang on boot, which is a grave defect.
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> ---
> Cc: Pali Rohar <pali at kernel.org>
> Cc: Patrice Chotard <patrice.chotard at foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay at foss.st.com>
> Cc: Tom Rini <trini at konsulko.com>
> ---
>   arch/arm/mach-stm32mp/dram_init.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c
> index 9346fa8546d..80ba5c27741 100644
> --- a/arch/arm/mach-stm32mp/dram_init.c
> +++ b/arch/arm/mach-stm32mp/dram_init.c
> @@ -51,7 +51,7 @@ phys_size_t board_get_usable_ram_top(phys_size_t total_size)
>   
>   	/* found enough not-reserved memory to relocated U-Boot */
>   	lmb_init(&lmb);
> -	lmb_add(&lmb, gd->ram_base, gd->ram_size);
> +	lmb_add(&lmb, gd->ram_base, get_effective_memsize());
>   	boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
>   	/* add 8M for reserved memory for display, fdt, gd,... */
>   	size = ALIGN(SZ_8M + CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE),


Applied to u-boot-stm/master, thanks!


For my point a view , this patch is an acceptable workaround for master
branch and v2023.01 delivery.

but the initial commit 777aaaa706b ("common/memsize.c: Fix get_effective_memsize() to
check should be revisited or reverted (in master or in next ?).

For details see comments in patch

"arm: stm32mp: Fix board_get_usable_ram_top() again"

http://patchwork.ozlabs.org/project/uboot/patch/20230105012222.238075-1-marex@denx.de/

https://lore.kernel.org/u-boot/20230105012222.238075-1-marex@denx.de/


Regards
Patrick



More information about the U-Boot mailing list