[PATCHv4 2/6] boot_fdt_add_mem_rsv_regions: free old dtb reservations

Simon Glass sjg at chromium.org
Tue Apr 21 22:40:51 CEST 2026


Hi Randolph,

On 2026-04-20T19:25:18, Randolph Sapp <rs at ti.com> wrote:
> boot_fdt_add_mem_rsv_regions: free old dtb reservations
>
> Add a free flag and an initial call to free allocations covered by the
> global FDT. This assumes that all calls to boot_fdt_add_mem_rsv_regions
> occur before the transition to the new device tree, thus we can access
> the currently active device tree through the global data pointer.
>
> This allows us to clearly indicate to the user when a device tree
> reservation fails. How we handle this can still use some improvement.
> Right now we'll keep the default behavior and try to boot anyway.
>
> This functionality was broken in:
> 5a6aa7d ("boot: fdt: Handle already reserved memory in boot_fdt_reserve_region()")
>
> Signed-off-by: Randolph Sapp <rs at ti.com>
>
> arch/mips/lib/bootm.c |  2 +-
>  boot/bootm.c          |  2 +-
>  boot/bootm_os.c       |  2 +-
>  boot/image-board.c    |  2 +-
>  boot/image-fdt.c      | 57 +++++++++++++++++++++++++++++++++++----------------
>  include/image.h       |  2 +-
>  lib/lmb.c             |  2 +-
>  7 files changed, 45 insertions(+), 24 deletions(-)

> diff --git a/boot/image-fdt.c b/boot/image-fdt.c
> @@ -69,35 +69,51 @@ static const struct legacy_img_hdr *image_get_fdt(ulong fdt_addr)
> +static void boot_fdt_reserve_region(u64 addr, u64 size, u32 flags, bool free)
>  {
> -     long ret;
> +     int ret;

nit: perhaps keep this one 'long' since lmb_free() returns long ?

Regards,
Simon


More information about the U-Boot mailing list