[PATCHv3 2/6] lmb: add LMB_FDT for fdt reserved regions

Simon Glass sjg at chromium.org
Sun Apr 19 05:52:18 CEST 2026


Hi Randolph,

On 2026-04-13T20:35:52, Randolph Sapp <rs at ti.com> wrote:
> lmb: add LMB_FDT for fdt reserved regions
>
> Add an LMB_FDT bit for fdt reserved regions, so we can reclaim them when
> parsing a new device tree and properly warn people when a reservation
> overlaps with an existing allocation.
>
> If we don't at least warn the user of these reservation failures,
> there's a chance that this region could be freed and reallocated for
> something important later.
>
> This useful warning mechanism was broken in:
> 5a6aa7d5913 ("boot: fdt: Handle already reserved memory in boot_fdt_reserve_region()")
>
> Signed-off-by: Randolph Sapp <rs at ti.com>
>
> boot/image-fdt.c |  5 ++++-
>  include/lmb.h    | 14 ++++++++++++++
>  lib/lmb.c        | 33 +++++++++++++++++++++++++++++----
>  3 files changed, 47 insertions(+), 5 deletions(-)

> diff --git a/lib/lmb.c b/lib/lmb.c
> @@ -654,6 +654,31 @@ long lmb_free(phys_addr_t base, phys_size_t size, u32 flags)
> +void lmb_free_fdt_regions(void)
> +{
> +     struct alist *lmb_rgn_lst = &lmb.used_mem;
> +     struct lmb_region *rgn = lmb_rgn_lst->data;
> +     long ret;

Could you move 'ret' into the block which needs it?

> diff --git a/lib/lmb.c b/lib/lmb.c
> @@ -654,6 +654,31 @@ long lmb_free(phys_addr_t base, phys_size_t size, u32 flags)
> +void lmb_free_fdt_regions(void)
> +{
> +     struct alist *lmb_rgn_lst = &lmb.used_mem;
> +     struct lmb_region *rgn = lmb_rgn_lst->data;

Since you are adding a new exported function, please can you add a
test for it in test/lib/lmb.c ?

Regards,
Simon


More information about the U-Boot mailing list