[PATCH v2 3/3] boot: image-fdt: Restore suppression of irrelevant ERROR message

Jonas Karlman <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
The commit 623f6c5b6ab7 ("boot: image-fdt: free old dtb reservations")
removed the suppression of ERROR messages when -EINVAL was returned due
to the memory region not being part of the LMB memory map.

This causes an irrelevant ERROR message during boot, e.g.:

  Model: Radxa ROCK 3B
  [...]
  ERROR: reserving fdt memory region failed (addr=10f000 size=100 flags=2): -22

or

  Model: Rockchip RK3288 Asus Tinker Board S
  [...]
  ERROR: reserving fdt memory region failed (addr=fe000000 size=1000000 flags=4): -22

FDT correctly contains reserved-memory for 10f000 or fe000000 and U-Boot
correctly does not make these regions available in the LMB memory map:

  memory[0]      [0x200000-0xefffffff], 0xefe00000 bytes, flags: none
  memory[1]      [0x100000000-0x1ffffffff], 0x100000000 bytes, flags: none

or

  memory[0]      [0x0-0x7fffffff], 0x80000000 bytes, flags: none

With lmb_alloc_mem() and lmb_free() both returning -EFAULT when the
requested memory region is not part of the LMB memory map it should be
safe to ignore these errors when FDT memreserve and reserved-memory is
being processed.

Print -EFAULT errors using a debug message to restore suppression of
this irrelevant ERROR message when memory region is not part of the LMB
memory map.

Fixes: 623f6c5b6ab7 ("boot: image-fdt: free old dtb reservations")
Signed-off-by: Jonas Karlman <[email protected]>
---
 boot/image-fdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index 9e0e0f93edd3..956a3d97c420 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -91,10 +91,10 @@ static void boot_fdt_handle_region(u64 addr, u64 size, u32 flags, bool free)
 		ret = lmb_alloc_mem(LMB_MEM_ALLOC_ADDR, 0, &rsv_addr, size,
 				    flags);
 
-	if (!ret) {
-		debug("   %s fdt memory region: addr=%llx size=%llx flags=%x\n",
-		      free ? "freed" : "reserved", (unsigned long long)addr,
-		      (unsigned long long)size, flags);
+	if (!ret || ret == -EFAULT) {
+		debug("   %s fdt memory region%s: addr=%llx size=%llx flags=%x ret=%ld\n",
+		      free ? "free" : "reserve", ret ? " failed" : "",
+		      (unsigned long long)addr, (unsigned long long)size, flags, ret);
 	} else {
 		printf("ERROR: %s fdt memory region failed (addr=%llx size=%llx flags=%x): %ld\n",
 		       free ? "freeing" : "reserving", (unsigned long long)addr,
-- 
2.55.0
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.