* [PATCH v2 0/3] boot: image-fdt: Restore suppression of irrelevant ERROR message
@ 2026-08-11 23:16 Jonas Karlman
2026-08-11 23:16 ` [PATCH v2 1/3] lmb: Return -EFAULT when requested region is not part of memory map Jonas Karlman
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Jonas Karlman @ 2026-08-11 23:16 UTC (permalink / raw)
To: Tom Rini, Randolph Sapp, Simon Glass, Ilias Apalodimas
Cc: Joseph Guo, Emanuele Ghidoli, Balaji Selvanathan, u-boot,
Jonas Karlman
This series changes the returned error code for lmb_alloc_mem() and
lmb_free() may return to help restore suppression of the verbose ERROR
messages when FDT memreserve and reserved-memory is being processed.
Changes in v2:
- Change lmb_alloc_mem() to return -EFAULT when region is not part of
the LMB memory map
- Change lmb_free() to return -EFAULT when the region is not allocated
- Change to use a debug message when -EFAULT is returned
Two similar patches to suppress this ERROR message can be found at [1]
and [2].
[1] https://patch.msgid.link/20260713-downgrade-v1-1-183a2300741b@nxp.com/
[2] https://patch.msgid.link/20260810-suppress-fdt-res-error-v1-1-e9641eb0aadb@oss.qualcomm.com/
Jonas Karlman (3):
lmb: Return -EFAULT when requested region is not part of memory map
lmb: Return -EFAULT when freeing unallocated memory regions
boot: image-fdt: Restore suppression of irrelevant ERROR message
boot/image-fdt.c | 8 ++++----
include/lmb.h | 4 +++-
lib/lmb.c | 6 ++++--
test/lib/lmb.c | 12 ++++++++++--
4 files changed, 21 insertions(+), 9 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/3] lmb: Return -EFAULT when requested region is not part of memory map
2026-08-11 23:16 [PATCH v2 0/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
@ 2026-08-11 23:16 ` Jonas Karlman
2026-08-12 21:12 ` Randolph Sapp
2026-08-11 23:16 ` [PATCH v2 2/3] lmb: Return -EFAULT when freeing unallocated memory regions Jonas Karlman
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Jonas Karlman @ 2026-08-11 23:16 UTC (permalink / raw)
To: Tom Rini, Randolph Sapp, Simon Glass, Ilias Apalodimas
Cc: Joseph Guo, Emanuele Ghidoli, Balaji Selvanathan, u-boot,
Jonas Karlman
lmb_alloc_addr() is documented to return -EINVAL when the requested
memory region is not part of the LMB memory map. However, -EINVAL is
also used to e.g. indicate that a NULL pointer is passed as the addr
parameter or when the requested memory region partially overlaps an
existing region.
Change lmb_alloc_addr() to return -EFAULT when the requested memory
region is not part of the LMB memory map to make the type of error known
to callers. Also extend unit tests to validate that the return code has
stay the same when the requested memory region partially overlaps.
No caller of lmb_alloc_addr() is checking what type of error code is
returned, so this change has no intended behavior change.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
include/lmb.h | 2 +-
lib/lmb.c | 4 +++-
test/lib/lmb.c | 10 +++++++++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/lmb.h b/include/lmb.h
index ed472e9ef2e1..028dabb19e86 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -124,7 +124,7 @@ struct lmb {
* Return: 0 on success, -ve value on failure
*
* When the allocation is of type @LMB_MEM_ALLOC_ADDR, the return value can
- * be -EINVAL if the requested memory region is not part of the LMB memory
+ * be -EFAULT if the requested memory region is not part of the LMB memory
* map, and -EEXIST if the requested region is already allocated.
*/
int lmb_alloc_mem(enum lmb_mem_type type, u64 align, phys_addr_t *addr,
diff --git a/lib/lmb.c b/lib/lmb.c
index 77440a48486c..f7c2e826d067 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -752,9 +752,11 @@ static int _lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags)
base + size - 1, 1))
/* ok, reserve the memory */
return lmb_reserve(base, size, flags);
+
+ return -EINVAL;
}
- return -EINVAL;
+ return -EFAULT;
}
int lmb_alloc_mem(enum lmb_mem_type type, u64 align, phys_addr_t *addr,
diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index b6259bef4426..b93b903f99f9 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -779,11 +779,19 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
/* check that allocating outside memory fails */
if (ram_end != 0) {
ret = lmb_alloc_addr(ram_end, 1, LMB_NONE);
+ ut_asserteq(ret, -EFAULT);
+ ret = lmb_alloc_addr(ram_end - 1, 2, LMB_NOMAP);
+ ut_asserteq(ret, -EINVAL);
+ ret = lmb_alloc_addr(ram_end - 1, 2, LMB_NOOVERWRITE);
ut_asserteq(ret, -EINVAL);
}
if (ram != 0) {
ret = lmb_alloc_addr(ram - 1, 1, LMB_NONE);
- ut_asserteq(ret, -EINVAL);
+ ut_asserteq(ret, -EFAULT);
+ ret = lmb_alloc_addr(ram - 1, 2, LMB_NOMAP);
+ ut_asserteq(ret, -EEXIST);
+ ret = lmb_alloc_addr(ram - 1, 2, LMB_NOOVERWRITE);
+ ut_asserteq(ret, -EEXIST);
}
lmb_pop(&store);
--
2.55.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] lmb: Return -EFAULT when freeing unallocated memory regions
2026-08-11 23:16 [PATCH v2 0/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
2026-08-11 23:16 ` [PATCH v2 1/3] lmb: Return -EFAULT when requested region is not part of memory map Jonas Karlman
@ 2026-08-11 23:16 ` Jonas Karlman
2026-08-12 21:13 ` Randolph Sapp
2026-08-11 23:16 ` [PATCH v2 3/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
2026-08-25 0:46 ` [PATCH v2 0/3] " Tom Rini
3 siblings, 1 reply; 8+ messages in thread
From: Jonas Karlman @ 2026-08-11 23:16 UTC (permalink / raw)
To: Tom Rini, Randolph Sapp, Simon Glass, Ilias Apalodimas
Cc: Joseph Guo, Emanuele Ghidoli, Balaji Selvanathan, u-boot,
Jonas Karlman
Make lmb_free() return -EFAULT when the requested memory region is not
allocated, instead of the generic -1 error value.
Document the updated error code in the public API comment and change the
LMB unit test to check for the new -EFAULT errno value.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
include/lmb.h | 2 ++
lib/lmb.c | 2 +-
test/lib/lmb.c | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/lmb.h b/include/lmb.h
index 028dabb19e86..157a24baf978 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -168,6 +168,8 @@ int lmb_is_reserved_flags(phys_addr_t addr, int flags);
* @flags: Memory region attributes
*
* Return: 0 on success, negative error code on failure.
+ *
+ * The return value can be -EFAULT when the region has not been allocated.
*/
long lmb_free(phys_addr_t base, phys_size_t size, u32 flags);
diff --git a/lib/lmb.c b/lib/lmb.c
index f7c2e826d067..ca00047f6242 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -286,7 +286,7 @@ static long _lmb_free(struct alist *lmb_rgn_lst, phys_addr_t base,
/* Didn't find the region */
if (i == lmb_rgn_lst->count)
- return -1;
+ return -EFAULT;
/* Check to see if we are removing entire region */
if (rgnbegin == base && rgnend == end) {
diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index b93b903f99f9..168c66ae6499 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -477,7 +477,7 @@ static int lib_test_lmb_at_0(struct unit_test_state *uts)
0, 0, 0, 0);
/* check that this was an error by freeing b */
ret = lmb_free(b, 4, LMB_NONE);
- ut_asserteq(ret, -1);
+ ut_asserteq(ret, -EFAULT);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, a, ram_size - 4,
0, 0, 0, 0);
--
2.55.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] boot: image-fdt: Restore suppression of irrelevant ERROR message
2026-08-11 23:16 [PATCH v2 0/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
2026-08-11 23:16 ` [PATCH v2 1/3] lmb: Return -EFAULT when requested region is not part of memory map Jonas Karlman
2026-08-11 23:16 ` [PATCH v2 2/3] lmb: Return -EFAULT when freeing unallocated memory regions Jonas Karlman
@ 2026-08-11 23:16 ` Jonas Karlman
2026-08-12 21:14 ` Randolph Sapp
2026-08-25 0:46 ` [PATCH v2 0/3] " Tom Rini
3 siblings, 1 reply; 8+ messages in thread
From: Jonas Karlman @ 2026-08-11 23:16 UTC (permalink / raw)
To: Tom Rini, Randolph Sapp, Simon Glass, Ilias Apalodimas
Cc: Joseph Guo, Emanuele Ghidoli, Balaji Selvanathan, u-boot,
Jonas Karlman
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 <jonas@kwiboo.se>
---
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] lmb: Return -EFAULT when requested region is not part of memory map
2026-08-11 23:16 ` [PATCH v2 1/3] lmb: Return -EFAULT when requested region is not part of memory map Jonas Karlman
@ 2026-08-12 21:12 ` Randolph Sapp
0 siblings, 0 replies; 8+ messages in thread
From: Randolph Sapp @ 2026-08-12 21:12 UTC (permalink / raw)
To: Jonas Karlman, Tom Rini, Randolph Sapp, Simon Glass,
Ilias Apalodimas
Cc: Joseph Guo, Emanuele Ghidoli, Balaji Selvanathan, u-boot
On Tue Aug 11, 2026 at 6:16 PM CDT, Jonas Karlman wrote:
> lmb_alloc_addr() is documented to return -EINVAL when the requested
> memory region is not part of the LMB memory map. However, -EINVAL is
> also used to e.g. indicate that a NULL pointer is passed as the addr
> parameter or when the requested memory region partially overlaps an
> existing region.
>
> Change lmb_alloc_addr() to return -EFAULT when the requested memory
> region is not part of the LMB memory map to make the type of error known
> to callers. Also extend unit tests to validate that the return code has
> stay the same when the requested memory region partially overlaps.
>
> No caller of lmb_alloc_addr() is checking what type of error code is
> returned, so this change has no intended behavior change.
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> ---
> include/lmb.h | 2 +-
> lib/lmb.c | 4 +++-
> test/lib/lmb.c | 10 +++++++++-
> 3 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/include/lmb.h b/include/lmb.h
> index ed472e9ef2e1..028dabb19e86 100644
> --- a/include/lmb.h
> +++ b/include/lmb.h
> @@ -124,7 +124,7 @@ struct lmb {
> * Return: 0 on success, -ve value on failure
> *
> * When the allocation is of type @LMB_MEM_ALLOC_ADDR, the return value can
> - * be -EINVAL if the requested memory region is not part of the LMB memory
> + * be -EFAULT if the requested memory region is not part of the LMB memory
> * map, and -EEXIST if the requested region is already allocated.
> */
This doc string may need to be updated a little more to indicate that -EINVAL is
now used to report partial overlaps.
Reviewed-by: Randolph Sapp <rs@ti.com>
> int lmb_alloc_mem(enum lmb_mem_type type, u64 align, phys_addr_t *addr,
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 77440a48486c..f7c2e826d067 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -752,9 +752,11 @@ static int _lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags)
> base + size - 1, 1))
> /* ok, reserve the memory */
> return lmb_reserve(base, size, flags);
> +
> + return -EINVAL;
> }
>
> - return -EINVAL;
> + return -EFAULT;
> }
>
> int lmb_alloc_mem(enum lmb_mem_type type, u64 align, phys_addr_t *addr,
> diff --git a/test/lib/lmb.c b/test/lib/lmb.c
> index b6259bef4426..b93b903f99f9 100644
> --- a/test/lib/lmb.c
> +++ b/test/lib/lmb.c
> @@ -779,11 +779,19 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
> /* check that allocating outside memory fails */
> if (ram_end != 0) {
> ret = lmb_alloc_addr(ram_end, 1, LMB_NONE);
> + ut_asserteq(ret, -EFAULT);
> + ret = lmb_alloc_addr(ram_end - 1, 2, LMB_NOMAP);
> + ut_asserteq(ret, -EINVAL);
> + ret = lmb_alloc_addr(ram_end - 1, 2, LMB_NOOVERWRITE);
> ut_asserteq(ret, -EINVAL);
> }
> if (ram != 0) {
> ret = lmb_alloc_addr(ram - 1, 1, LMB_NONE);
> - ut_asserteq(ret, -EINVAL);
> + ut_asserteq(ret, -EFAULT);
> + ret = lmb_alloc_addr(ram - 1, 2, LMB_NOMAP);
> + ut_asserteq(ret, -EEXIST);
> + ret = lmb_alloc_addr(ram - 1, 2, LMB_NOOVERWRITE);
> + ut_asserteq(ret, -EEXIST);
> }
>
> lmb_pop(&store);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] lmb: Return -EFAULT when freeing unallocated memory regions
2026-08-11 23:16 ` [PATCH v2 2/3] lmb: Return -EFAULT when freeing unallocated memory regions Jonas Karlman
@ 2026-08-12 21:13 ` Randolph Sapp
0 siblings, 0 replies; 8+ messages in thread
From: Randolph Sapp @ 2026-08-12 21:13 UTC (permalink / raw)
To: Jonas Karlman, Tom Rini, Randolph Sapp, Simon Glass,
Ilias Apalodimas
Cc: Joseph Guo, Emanuele Ghidoli, Balaji Selvanathan, u-boot
On Tue Aug 11, 2026 at 6:16 PM CDT, Jonas Karlman wrote:
> Make lmb_free() return -EFAULT when the requested memory region is not
> allocated, instead of the generic -1 error value.
>
> Document the updated error code in the public API comment and change the
> LMB unit test to check for the new -EFAULT errno value.
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> ---
> include/lmb.h | 2 ++
> lib/lmb.c | 2 +-
> test/lib/lmb.c | 2 +-
> 3 files changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Randolph Sapp <rs@ti.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] boot: image-fdt: Restore suppression of irrelevant ERROR message
2026-08-11 23:16 ` [PATCH v2 3/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
@ 2026-08-12 21:14 ` Randolph Sapp
0 siblings, 0 replies; 8+ messages in thread
From: Randolph Sapp @ 2026-08-12 21:14 UTC (permalink / raw)
To: Jonas Karlman, Tom Rini, Randolph Sapp, Simon Glass,
Ilias Apalodimas
Cc: Joseph Guo, Emanuele Ghidoli, Balaji Selvanathan, u-boot
On Tue Aug 11, 2026 at 6:16 PM CDT, Jonas Karlman wrote:
> 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 <jonas@kwiboo.se>
> ---
> boot/image-fdt.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Looked this series over and ran it locally to verify. It resolves the issues I
raised about error verbosity well. Thanks Jonas.
Reviewed-by: Randolph Sapp <rs@ti.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] boot: image-fdt: Restore suppression of irrelevant ERROR message
2026-08-11 23:16 [PATCH v2 0/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
` (2 preceding siblings ...)
2026-08-11 23:16 ` [PATCH v2 3/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
@ 2026-08-25 0:46 ` Tom Rini
3 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2026-08-25 0:46 UTC (permalink / raw)
To: Randolph Sapp, Simon Glass, Ilias Apalodimas, Jonas Karlman
Cc: Joseph Guo, Emanuele Ghidoli, Balaji Selvanathan, u-boot
On Tue, 11 Aug 2026 23:16:46 +0000, Jonas Karlman wrote:
> This series changes the returned error code for lmb_alloc_mem() and
> lmb_free() may return to help restore suppression of the verbose ERROR
> messages when FDT memreserve and reserved-memory is being processed.
>
> Changes in v2:
> - Change lmb_alloc_mem() to return -EFAULT when region is not part of
> the LMB memory map
> - Change lmb_free() to return -EFAULT when the region is not allocated
> - Change to use a debug message when -EFAULT is returned
>
> [...]
Applied to u-boot/main, thanks!
[1/3] lmb: Return -EFAULT when requested region is not part of memory map
commit: 93e5e5f4cbefccab206a79f86e98c2c39a9d2440
[2/3] lmb: Return -EFAULT when freeing unallocated memory regions
commit: 480644c06e202abec58543aec502f218939fff1e
[3/3] boot: image-fdt: Restore suppression of irrelevant ERROR message
commit: 94a09715bf4c8dfdefbefcd341d0c9da04c5a6c1
--
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-08-25 0:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 23:16 [PATCH v2 0/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
2026-08-11 23:16 ` [PATCH v2 1/3] lmb: Return -EFAULT when requested region is not part of memory map Jonas Karlman
2026-08-12 21:12 ` Randolph Sapp
2026-08-11 23:16 ` [PATCH v2 2/3] lmb: Return -EFAULT when freeing unallocated memory regions Jonas Karlman
2026-08-12 21:13 ` Randolph Sapp
2026-08-11 23:16 ` [PATCH v2 3/3] boot: image-fdt: Restore suppression of irrelevant ERROR message Jonas Karlman
2026-08-12 21:14 ` Randolph Sapp
2026-08-25 0:46 ` [PATCH v2 0/3] " Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox