Revert "resource: fix region_intersects() vs add_memory_driver_managed()"
This reverts commit 29fa0c8808
.
This commit is contained in:
parent
08ae7de936
commit
a8299c44cf
1 changed files with 8 additions and 50 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue