Skip to content

Commit ff54250

Browse files
committed
Remove 'recurse into child resources' logic from 'reserve_region_with_split()'
This function is not actually used right now, since the original use case for it was done with insert_resource_expand_to_fit() instead. However, we now have another usage case that wants to basically do a "reserve IO resource, splitting around existing resources", however that one doesn't actually want the "recurse into the conflicting resource" logic at all. And since recursing into the conflicting resource was the most complex part, and isn't wanted, just remove it. Maybe we'll some day want both versions, but we can just resurrect the logic then. Tested-by: Yinghai Lu <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8d4ab5d commit ff54250

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

kernel/resource.c

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -533,43 +533,21 @@ static void __init __reserve_region_with_split(struct resource *root,
533533
res->end = end;
534534
res->flags = IORESOURCE_BUSY;
535535

536-
for (;;) {
537-
conflict = __request_resource(parent, res);
538-
if (!conflict)
539-
break;
540-
if (conflict != parent) {
541-
parent = conflict;
542-
if (!(conflict->flags & IORESOURCE_BUSY))
543-
continue;
544-
}
545-
546-
/* Uhhuh, that didn't work out.. */
547-
kfree(res);
548-
res = NULL;
549-
break;
550-
}
551-
552-
if (!res) {
553-
/* failed, split and try again */
554-
555-
/* conflict covered whole area */
556-
if (conflict->start <= start && conflict->end >= end)
557-
return;
536+
conflict = __request_resource(parent, res);
537+
if (!conflict)
538+
return;
558539

559-
if (conflict->start > start)
560-
__reserve_region_with_split(root, start, conflict->start-1, name);
561-
if (!(conflict->flags & IORESOURCE_BUSY)) {
562-
resource_size_t common_start, common_end;
540+
/* failed, split and try again */
541+
kfree(res);
563542

564-
common_start = max(conflict->start, start);
565-
common_end = min(conflict->end, end);
566-
if (common_start < common_end)
567-
__reserve_region_with_split(root, common_start, common_end, name);
568-
}
569-
if (conflict->end < end)
570-
__reserve_region_with_split(root, conflict->end+1, end, name);
571-
}
543+
/* conflict covered whole area */
544+
if (conflict->start <= start && conflict->end >= end)
545+
return;
572546

547+
if (conflict->start > start)
548+
__reserve_region_with_split(root, start, conflict->start-1, name);
549+
if (conflict->end < end)
550+
__reserve_region_with_split(root, conflict->end+1, end, name);
573551
}
574552

575553
void __init reserve_region_with_split(struct resource *root,

0 commit comments

Comments
 (0)