[PATCH v2 1/1] lmb: Treat a region which is a subset as equal

Sjoerd Simons sjoerd at collabora.com
Tue Feb 14 11:23:15 CET 2023


Hey,

On Tue, 2023-02-14 at 07:57 +0000, Soma, Ashok Reddy wrote:
> Hi Sjoerd Simons,
> 
> Thanks for you patches.
> 
> However even after your patches, I still see below error.
> 
> ERROR: reserving fdt memory region failed (addr=800000000
> size=180000000 flags=4)
> ERROR: reserving fdt memory region failed (addr=50000000000
> size=200000000 flags=4)

Annoyingly it's hard to tell why the reservation has failed; It could
for example be a difference in mapping flags (making them
incompatible); looking at bdinfo could help a bit here but otherwise
it'll need slightly more debugging

> My DT has extra reserved memory nodes which are reserved as below.
> Any idea what may be wrong ?
> 
> Reserved memory nodes in DT:
> 
>         memory at 0 {
>                 device_type = "memory";
>                 reg = <0x00 0x00 0x00 0x80000000 0x08 0x00 0x01
> 0x80000000>;
>         };
> 
>         memory at 50000000000 {
>                 device_type = "memory";
>                 reg = <0x500 0x00 0x02 0x00>;
>         };
> 
>         reserved-memory {
>                 #address-cells = <0x02>;
>                 #size-cells = <0x02>;
>                 ranges;
> 
>                 buffer at 0 {
>                         no-map;
>                         reg = <0x08 0x00 0x01 0x80000000>;
>                 };
> 
>                 buffer at 1 {
>                         no-map;
>                         reg = <0x500 0x00 0x02 0x00>;
>                 };
>         };
> 
> Boot log:
> 
> ## Loading init Ramdisk from Legacy Image at 04000000 ...
>    Image Name:   petalinux-image-minimal-xlnx-zyn
>    Created:      2011-04-05  23:00:00 UTC
>    Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
>    Data Size:    59194022 Bytes = 56.5 MiB
>    Load Address: 00000000
>    Entry Point:  00000000
>    Verifying Checksum ... OK
> ## Flattened Device Tree blob at 00100000
>    Booting using the fdt blob at 0x100000
> Working FDT set to 100000
> Host not halted after 16000 microseconds.
>    Loading Ramdisk to 74575000, end 77de8aa6 ... OK
> ERROR: reserving fdt memory region failed (addr=800000000
> size=180000000 flags=4)
> ERROR: reserving fdt memory region failed (addr=50000000000
> size=200000000 flags=4)
>    Loading Device Tree to 0000000074564000, end 0000000074574603 ...
> OK
> Working FDT set to 74564000
> 
> Starting kernel ...
> 
> 
> Thanks,
> Ashok
> 
> 
> > -----Original Message-----
> > From: Sjoerd Simons <sjoerd at collabora.com>
> > Sent: Sunday, February 12, 2023 8:37 PM
> > To: Tom Rini <trini at konsulko.com>
> > Cc: Ashok Reddy Soma <ashok.reddy.soma at xilinx.com>; Heinrich
> > Schuchardt <xypron.glpk at gmx.de>; Simek, Michal
> > <michal.simek at amd.com>; Patrice Chotard
> > <patrice.chotard at foss.st.com>;
> > u-boot at lists.denx.de
> > Subject: [PATCH v2 1/1] lmb: Treat a region which is a subset as
> > equal
> > 
> > CAUTION: This message has originated from an External Source.
> > Please use
> > proper judgment and caution when opening attachments, clicking
> > links, or
> > responding to this email.
> > 
> > 
> > In various cases logical memory blocks are coalesced; As a result
> > doing a
> > strict check whether memory blocks are the same doesn't necessarily
> > work as
> > a previous addition of a given block might have been merged into a
> > bigger
> > block.
> > 
> > Fix this by considering a block is already registered if it's a
> > pure subset of one
> > of the existing blocks.
> > 
> > Signed-off-by: Sjoerd Simons <sjoerd at collabora.com>
> > 
> > ---
> > 
> > Changes in v2:
> > - Adjust calculation to prevent integer overview (fixes lmb tests)
> > 
> >  lib/lmb.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/lmb.c b/lib/lmb.c
> > index f447c639a60..2444b2a6212 100644
> > --- a/lib/lmb.c
> > +++ b/lib/lmb.c
> > @@ -247,8 +247,10 @@ static long lmb_add_region_flags(struct
> > lmb_region
> > *rgn, phys_addr_t base,
> >                 phys_addr_t rgnbase = rgn->region[i].base;
> >                 phys_size_t rgnsize = rgn->region[i].size;
> >                 phys_size_t rgnflags = rgn->region[i].flags;
> > +               phys_addr_t end = base + size - 1;
> > +               phys_addr_t rgnend = rgnbase + rgnsize - 1;
> > 
> > -               if (rgnbase == base && rgnsize == size) {
> > +               if (rgnbase <= base && end <= rgnend) {
> >                         if (flags == rgnflags)
> >                                 /* Already have this region, so
> > we're done */
> >                                 return 0;
> > --
> > 2.39.1
> 

-- 
Sjoerd Simons
Collabora Ltd.


More information about the U-Boot mailing list