From a8299c44cf278b675677ef81cc08e24be9024eb2 Mon Sep 17 00:00:00 2001 From: Ksawlii Date: Sun, 24 Nov 2024 00:22:55 +0100 Subject: [PATCH] Revert "resource: fix region_intersects() vs add_memory_driver_managed()" This reverts commit 29fa0c88086e60fb520510eece6ad18c615ec080. --- kernel/resource.c | 58 +++++++---------------------------------------- 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 1087f33d7..100253d49 100755 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -539,63 +539,21 @@ EXPORT_SYMBOL_GPL(page_is_ram); int region_intersects(resource_size_t start, size_t size, unsigned long flags, unsigned long desc) { - resource_size_t ostart, oend; - int type = 0; int other = 0; - struct resource *p, *dp; - bool is_type, covered; struct resource res; + int type = 0; int other = 0; + struct resource *p; res.start = start; res.end = start + size - 1; read_lock(&resource_lock); for (p = iomem_resource.child; p ; p = p->sibling) { - if (!resource_overlaps(p, &res)) - continue; - is_type = (p->flags & flags) == flags && - (desc == IORES_DESC_NONE || desc == p->desc); - if (is_type) { - type++; - continue; - } - /* - * Continue to search in descendant resources as if the - * matched descendant resources cover some ranges of 'p'. - * - * |------------- "CXL Window 0" ------------| - * |-- "System RAM" --| - * - * will behave similar as the following fake resource - * tree when searching "System RAM". - * - * |-- "System RAM" --||-- "CXL Window 0a" --| - */ - covered = false; - ostart = max(res.start, p->start); - oend = min(res.end, p->end); - for (dp = p->child; dp; dp = next_resource(dp, false)) { - if (!resource_overlaps(dp, &res)) - continue; - is_type = (dp->flags & flags) == flags && - (desc == IORES_DESC_NONE || desc == dp->desc); - if (is_type) { - type++; - /* - * Range from 'ostart' to 'dp->start' - * isn't covered by matched resource. - */ - if (dp->start > ostart) - break; - if (dp->end >= oend) { - covered = true; - break; - } - /* Remove covered range */ - ostart = max(ostart, dp->end + 1); - } - } - if (!covered) - other++; + bool is_type = (((p->flags & flags) == flags) && + ((desc == IORES_DESC_NONE) || + (desc == p->desc))); + + if (resource_overlaps(p, &res)) + is_type ? type++ : other++; } read_unlock(&resource_lock);