[PATCH master] resource: fix recently broken memory bank fusing

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Oct 17 06:39:00 PDT 2022

barebox will fuse overlapping memory banks to avoid the common issue of
the device tree being modified upstream to contain a minimum RAM size
that would then conflict with a RAM size barebox determines by
querying the memory controller. This was recently broken, because we
changed memory banks to have IORESOURCE_MEM in their flags field,
but resource_contains() used to compare regions won't return true if
memory type differs. Fix this by settings .flags = IORESOURCE_MEM
for the new resource as well.

Reported-by: Ian Abbott <abbotti at mev.co.uk>
Fixes: d0b5f6bde15b ("of: reserved-mem: reserve regions prior to mmu_initcall()")
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
 common/memory.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/memory.c b/common/memory.c
index 7e24ecb2bd03..0ae9e7383cce 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -149,6 +149,7 @@ int barebox_add_memory_bank(const char *name, resource_size_t start,
 	struct resource newres = {
 		.start = start,
 		.end = start + size - 1,
+		.flags = IORESOURCE_MEM,
 	for_each_memory_bank(bank) {

More information about the barebox mailing list