Re: [PATCH] boot: image-fdt: downgrade -EINVAL reservation failure to debug

Simon Glass <[email protected]>
Newsgroups gmane.comp.boot-loaders.u-boot
Message-ID <CAFLszTiQ-P_BV+9_-f-_pc8fa+k4C5KQS87agVLHoZ7sF9E-Eg@mail.gmail.com>
Hi Joseph,

On 2026-07-13T08:45:48, Joseph Guo <[email protected]> wrote:
> boot: image-fdt: downgrade -EINVAL reservation failure to debug
>
> When boot_fdt_handle_region() attempts to reserve a DTS reserved-memory
> region via lmb_alloc_mem(), it may receive -EINVAL if the region's
> physical address falls outside the LMB-managed memory range (i.e.
> below PHYS_SDRAM on platforms where U-Boot does not manage the lower
> DRAM window).
>
> A typical example is platforms like i.MX95 where PHYS_SDRAM starts at
> 0x90000000, but remoteproc/rpmsg carveouts (vdev vrings, vdev buffer,
> resource table) are placed at 0x88xxxxxx by hardware convention. Those
> addresses are unreachable by U-Boot's allocator anyway, so failing to
> mark them reserved has no practical consequence -- U-Boot will never
> accidentally place the initrd or FDT blob there.
>
> Printing ERROR for a condition that is harmless and expected on many
> platforms is misleading. Downgrade the -EINVAL case to debug() to
> suppress the spurious output while preserving full visibility under
> DEBUG/log builds.
>
> [...]
>
> boot/image-fdt.c | 3 +++
>  1 file changed, 3 insertions(+)

> diff --git a/boot/image-fdt.c b/boot/image-fdt.c
> @@ -95,6 +95,9 @@ static void boot_fdt_handle_region(u64 addr, u64 size, u32 flags, bool free)
> +     } else if (ret == -EINVAL) {
> +             debug("   skipping fdt memory region outside LMB range (addr=%llx size=%llx flags=%x)\n",
> +                   (unsigned long long)addr, (unsigned long long)size, flags);

Just to note, -EINVAL from _lmb_alloc_addr() is also returned when the
region only partially overlaps available memory, e.g. a reserved-memory
node that straddles the start of PHYS_SDRAM or spans a hole between
banks. Part of such a region is reachable by U-Boot's allocator, so
silently skipping it means the initrd or FDT could still be placed
there - exactly what the commit message says cannot happen.

I see this patch is being dropped in favour of Jonas's version, but the
same applies there: perhaps only downgrade the message when the region
has no overlap at all with LMB memory, or clamp the reservation to the
overlapping portion.

Regards,
Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.