@@ -2081,20 +2081,54 @@ static bool __init_memblock memsize_update_nomap_region(const char *name, phys_a
for (i = 0; i < memsize_rgn_count; i++) {
rmem_rgn = &memsize_rgn[i];
+ /* skip either !nomap, !unknown, !overlap */
if (!rmem_rgn->nomap)
continue;
if (strcmp(rmem_rgn->name, "unknown"))
continue;
- if (base < rmem_rgn->base)
+ if (base + size <= rmem_rgn->base)
continue;
- if (base + size > rmem_rgn->base + rmem_rgn->size)
+ if (base >= rmem_rgn->base + rmem_rgn->size)
continue;
+ /* exactly same */
if (base == rmem_rgn->base && size == rmem_rgn->size) {
memsize_get_valid_name(rmem_rgn->name, name);
return true;
}
+ /* bigger */
+ if (base <= rmem_rgn->base &&
+ base + size >= rmem_rgn->base + rmem_rgn->size) {
+ memsize_get_valid_name(rmem_rgn->name, name);
+ rmem_rgn->base = base;
+ rmem_rgn->size = size;
+ return true;
+ }
+
+ /* intersect */
+ if (base < rmem_rgn->base ||
+ base + size > rmem_rgn->base + rmem_rgn->size) {
+ new_rgn = memsize_get_new_rgn();
+ if (!new_rgn)
+ return true;
+ new_rgn->base = base;
+ new_rgn->size = size;
+ new_rgn->nomap = nomap;
+ new_rgn->reusable = false;
+ memsize_get_valid_name(new_rgn->name, name);
+
+ if (base < rmem_rgn->base) {
+ rmem_rgn->size -= base + size - rmem_rgn->base;
+ rmem_rgn->base = base + size;
+ } else {
+ rmem_rgn->size -= rmem_rgn->base
+ + rmem_rgn->size - base;
+ }
+ return true;
+ }
+
+ /* smaller */
new_rgn = memsize_get_new_rgn();
if (!new_rgn)
return true;
There is case where reserved regions overlapped with already checked as unknown regions. To get more information of the name, size, so far we allowed only regions which are exactly matching with or located within the unknown region. For a region intersecting an unknown region, we did not take and just showed that duplicated information. So total size was not perfect. To fix this, let's allow to take even the intersecting region. Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com> --- mm/memblock.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)