aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd@collabora.com>2023-02-12 16:07:05 +0100
committerTom Rini <trini@konsulko.com>2023-02-12 11:54:18 -0500
commit0d91c88230fe8bd9f8d39ca2ab69cd6282e9f949 (patch)
treea28713512434fb5ed51b077db69e9edd916f8285 /lib
parent78d1c3949a6f85f64b31ee8ab8240392a67ca30e (diff)
downloadu-boot-0d91c88230fe8bd9f8d39ca2ab69cd6282e9f949.zip
u-boot-0d91c88230fe8bd9f8d39ca2ab69cd6282e9f949.tar.gz
u-boot-0d91c88230fe8bd9f8d39ca2ab69cd6282e9f949.tar.bz2
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. Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/lmb.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/lmb.c b/lib/lmb.c
index f447c63..2444b2a 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;