Fix boot regressions on at least TI am62x
v2 cover Fix boot regressions on at least TI am62x
When booting a recent u-boot master on TI am62x with the distro boot sequence it fails loading the FDT:
Booting using the fdt blob at 0x88000000
Working FDT set to 88000000
Loading Ramdisk to 8d711000, end 8ffffd95 ... OK
ERROR: reserving fdt memory region failed (addr=9e780000 size=80000 flags=4)
ERROR: reserving fdt memory region failed (addr=9e800000 size=1800000 flags=4)
ERROR: reserving fdt memory region failed (addr=9db00000 size=c00000 flags=4)
ERROR: Failed to allocate 0x8f58 bytes below 0x90000000.
device tree - allocation error
FDT creation failed!
resetting ...
It turns out that this is caused by commit 06d514d77c37 ("lmb: consider EFI memory map") due to injecting both extra and some similar memory regions via a different path into the lmb. The following series fixes the apparent fallout from that ;)
Changes in v2:
- Adjust calculation to prevent integer overview (fixes lmb tests)
- Drop first 2 patches as they were applied already
Sjoerd Simons (1):
lmb: Treat a region which is a subset as equal
lib/lmb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.39.1
PATCH v2 1/1 lmb: Treat a region which is a subset as equal
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.
---
Changes in v2:
- Adjust calculation to prevent integer overview (fixes lmb tests)
lib/lmb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/lmb.c +3 -1
@@ -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 ;
Signature · 1 line
2.39.1
Re: [PATCH v2 1/1] lmb: Treat a region which is a subset as equal
Quoted 10 lines · Sjoerd Simons
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 <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
RE: [PATCH v2 1/1] lmb: Treat a region which is a subset as equal
In reply to Sjoerd SimonsHi 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)
My DT has extra reserved memory nodes which are reserved as below. Any idea what may be wrong ?
Reserved memory nodes in DT:
memory@0 {
device_type = "memory";
reg = <0x00 0x00 0x00 0x80000000 0x08 0x00 0x01 0x80000000>;
};
memory@50000000000 {
device_type = "memory";
reg = <0x500 0x00 0x02 0x00>;
};
reserved-memory {
#address-cells = <0x02>;
#size-cells = <0x02>;
ranges;
buffer@0 {
no-map;
reg = <0x08 0x00 0x01 0x80000000>;
};
buffer@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
Quoted 52 lines
-----Original Message-----
From: Sjoerd Simons <[email protected]>
Sent: Sunday, February 12, 2023 8:37 PM
To: Tom Rini <[email protected]>
Cc: Ashok Reddy Soma <[email protected]>; Heinrich Schuchardt <[email protected]>; Simek, Michal <[email protected]>; Patrice Chotard <[email protected]>; [email protected]
Subject: [PATCH v2 1/1] lmb: Treat a region which is a subset as equalCAUTION: 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 <[email protected]>---
Changes in v2:
- Adjust calculation to prevent integer overview (fixes lmb tests)lib/lmb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/lmb.c +3
-1@@ -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
Re: [PATCH v2 1/1] lmb: Treat a region which is a subset as equal
Hey,
Quoted 10 lines · Ashok Reddy
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
Quoted 125 lines
My DT has extra reserved memory nodes which are reserved as below. Any idea what may be wrong ?
Reserved memory nodes in DT:
memory@0 {
device_type= "memory";
reg = <0x000x000x000x800000000x080x000x010x80000000>;
};memory@50000000000 {
device_type= "memory";
reg = <0x5000x000x020x00>;
};reserved-memory {
#address-cells = <0x02>;
#size-cells = <0x02>;
ranges;buffer@0 {
no-map;
reg = <0x080x000x010x80000000>; };buffer@1 {
no-map;
reg = <0x5000x000x020x00>; };
};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 at0x100000
Working FDT set to 100000
Host not halted after 16000 microseconds.
Loading Ramdisk to 74575000, end77de8aa6... 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 74564000Starting kernel ...
Thanks,
AshokQuoted 62 lines
-----Original Message-----
From: Sjoerd Simons <[email protected]>
Sent: Sunday, February 12, 2023 8:37 PM
To: Tom Rini <[email protected]>
Cc: Ashok Reddy Soma <[email protected]>; Heinrich Schuchardt <[email protected]>; Simek, Michal <[email protected]>; Patrice Chotard <[email protected]>;
[email protected]
Subject: [PATCH v2 1/1] lmb: Treat a region which is a subset as equalCAUTION: 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 <[email protected]>---
Changes in v2:
- Adjust calculation to prevent integer overview (fixes lmb tests)lib/lmb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)lib/lmb.c +0
-0@@ -247,8 +247,10 @@ static long lmb_add_region_flags(struct
lmb_region
*rgn,phys_addr_tbase,
phys_addr_trgnbase = rgn->region[i].base;phys_size_trgnsize = rgn->region[i].size;phys_size_trgnflags = rgn->region[i].flags; +phys_addr_tend = base + size - 1; +phys_addr_trgnend = 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
Signature · 2 lines
Sjoerd Simons Collabora Ltd.