[PATCH] boot: image-fdt: suppress spurious error on expected reservation failures

Balaji Selvanathan via U-Boot <[email protected]>
Newsgroups gmane.comp.boot-loaders.u-boot
Message-ID <20260810-suppress-fdt-res-error-v1-1-e9641eb0aadb__44249.9286074721$1786354520$gmane$org@oss.qualcomm.com>
Before commit 623f6c5b6ab7 ("boot: image-fdt: free old dtb
reservations"), boot_fdt_handle_region() filtered out -EEXIST and
-EINVAL when reserving an FDT memory region, treating both as benign.
That commit added the free/reserve toggle but dropped the filter, so
these now print as errors.

-EINVAL in particular is expected: when a reserved-memory region falls
outside the available memory LMB knows about, _lmb_alloc_addr() returns
-EINVAL. This happens when a carve-out described in the kernel DT lies
in a range the platform does not report as usable RAM, so its
reservation fails with -EINVAL and prints:

  ERROR: reserving fdt memory region failed (addr=91a80000 size=80000 flags=2): -22

on an otherwise clean boot. The region is still described in the
kernel DT and Linux reserves it itself, so U-Boot failing to track it
in LMB is harmless.

Restore the old filter, scoped to the reserve path: print the error
only when freeing, or when a reservation fails with something other
than -EEXIST or -EINVAL. The "free ||" guard keeps free-path failures
always visible.

Fixes: 623f6c5b6ab7 ("boot: image-fdt: free old dtb reservations")
Signed-off-by: Balaji Selvanathan <[email protected]>
---
 boot/image-fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index 9e0e0f93edd..d4a588ec164 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -95,7 +95,7 @@ static void boot_fdt_handle_region(u64 addr, u64 size, u32 flags, bool free)
 		debug("   %s fdt memory region: addr=%llx size=%llx flags=%x\n",
 		      free ? "freed" : "reserved", (unsigned long long)addr,
 		      (unsigned long long)size, flags);
-	} else {
+	} else if (free || (ret != -EEXIST && ret != -EINVAL)) {
 		printf("ERROR: %s fdt memory region failed (addr=%llx size=%llx flags=%x): %ld\n",
 		       free ? "freeing" : "reserving", (unsigned long long)addr,
 		       (unsigned long long)size, flags, ret);

---
base-commit: 28515d7ff5285e0b942f15577e3198f15c667a25
change-id: 20260810-suppress-fdt-res-error-7f7e67d2a91c

Best regards,
-- 
Balaji Selvanathan <[email protected]>
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.