[U-Boot] [PATCH] image: fdt: handle coalesced reserve region

Patrick Delaunay patrick.delaunay at st.com
Wed Mar 6 13:23:52 UTC 2019


Handle in boot_fdt_reserve_region
any return value > 0 of lmb_reserve() function;
it occurs when coalesced region are found:
adjacent reserved region are merged.

This patch avoid the error trace:
  ERROR: reserving fdt memory region failed..
when reserved region are merged (return value = 1).

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
---

Tested on stm32mp1 board v2019.04-rc2

with reserved memory in device tree:

reserved-memory {
	#address-cells = <1>;
	#size-cells = <1>;
	ranges;
	retram: retram at 0x38000000 {
		compatible = "shared-dma-pool";
		reg = <0x38000000 0x10000>;
		no-map;
	};
	mcuram: mcuram at 0x30000000 {
		compatible = "shared-dma-pool";
		reg = <0x30000000 0x40000>;
		no-map;
	};
	mcuram2: mcuram2 at 0x10000000 {
		compatible = "shared-dma-pool";
		reg = <0x10000000 0x40000>;
		no-map;
	};
	vdev0vring0: vdev0vring0 at 10040000 {
		compatible = "shared-dma-pool";
		reg = <0x10040000 0x2000>;
		no-map;
	};

	vdev0vring1: vdev0vring1 at 10042000 {
		compatible = "shared-dma-pool";
		reg = <0x10042000 0x2000>;
		no-map;
	};

	vdev0buffer: vdev0buffer at 10044000 {
		compatible = "shared-dma-pool";
		reg = <0x10044000 0x4000>;
		no-map;
	};
};

we have several adjacent reserved memory (0x10000000...0x10046000)

Without the patch I have the ERROR:

ERROR: reserving fdt memory region failed (addr=10040000 size=2000)
ERROR: reserving fdt memory region failed (addr=10042000 size=2000)
ERROR: reserving fdt memory region failed (addr=10044000 size=2000)
lmb_dump_all:
    memory.cnt		   = 0x1
    memory.size		   = 0x0
    memory.reg[0x0].base   = 0xc0000000
		   .size   = 0x40000000

    reserved.cnt	   = 0x4
    reserved.size	   = 0x0
    reserved.reg[0x0].base = 0x10000000
		     .size = 0x46000
    reserved.reg[0x1].base = 0x30000000
		     .size = 0x40000
    reserved.reg[0x2].base = 0x38000000
		     .size = 0x10000
    reserved.reg[0x3].base = 0xfdc38a98
		     .size = 0x23c7568

with the patch not more issue...


 common/image-fdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/image-fdt.c b/common/image-fdt.c
index 94089b2..01186ae 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -71,10 +71,10 @@ static const image_header_t *image_get_fdt(ulong fdt_addr)
 static void boot_fdt_reserve_region(struct lmb *lmb, uint64_t addr,
 				    uint64_t size)
 {
-	int ret;
+	long ret;
 
 	ret = lmb_reserve(lmb, addr, size);
-	if (!ret) {
+	if (ret >= 0) {
 		debug("   reserving fdt memory region: addr=%llx size=%llx\n",
 		      (unsigned long long)addr, (unsigned long long)size);
 	} else {
-- 
2.7.4



More information about the U-Boot mailing list