diff mbox

[05/21] resource: adjust_resource handle resource without parent

Message ID 1336422606-4244-6-git-send-email-yinghai@kernel.org
State Rejected
Headers show

Commit Message

Yinghai Lu May 7, 2012, 8:29 p.m. UTC
for no parent no siling case.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 kernel/resource.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

Comments

Bjorn Helgaas May 18, 2012, 5:12 p.m. UTC | #1
On Mon, May 7, 2012 at 2:29 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> for no parent no siling case.
>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> ---
>  kernel/resource.c |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/resource.c b/kernel/resource.c
> index 7e8ea66..51ade23 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -722,14 +722,12 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t
>
>        write_lock(&resource_lock);
>
> +       if (!parent)
> +               goto skip;
> +
>        if ((start < parent->start) || (end > parent->end))
>                goto out;
>
> -       for (tmp = res->child; tmp; tmp = tmp->sibling) {
> -               if ((tmp->start < start) || (tmp->end > end))
> -                       goto out;
> -       }
> -
>        if (res->sibling && (res->sibling->start <= end))
>                goto out;
>
> @@ -741,6 +739,11 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t
>                        goto out;
>        }
>
> +skip:
> +       for (tmp = res->child; tmp; tmp = tmp->sibling)
> +               if ((tmp->start < start) || (tmp->end > end))
> +                       goto out;
> +
>        res->start = start;
>        res->end = end;
>        result = 0;

Where does this case occur?  When do you need to adjust a resource
that has no parent?
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yinghai Lu May 18, 2012, 5:54 p.m. UTC | #2
On Fri, May 18, 2012 at 10:12 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Mon, May 7, 2012 at 2:29 PM, Yinghai Lu <yinghai@kernel.org> wrote:

> Where does this case occur?  When do you need to adjust a resource
> that has no parent?

for unassigned pci bridge from BIOS, before scan busn_res.end is 0xff,
so you can not insert them, because the bridge could in the middle.
Have to update the busn_res.end and insert after the bridge is scanned

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas May 18, 2012, 6:06 p.m. UTC | #3
On Fri, May 18, 2012 at 11:54 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, May 18, 2012 at 10:12 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> On Mon, May 7, 2012 at 2:29 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>
>> Where does this case occur?  When do you need to adjust a resource
>> that has no parent?
>
> for unassigned pci bridge from BIOS, before scan busn_res.end is 0xff,
> so you can not insert them, because the bridge could in the middle.
> Have to update the busn_res.end and insert after the bridge is scanned

Does the resource have children in this case?  If it has no parent,
it's not in the resource tree at all, is it?  Is there any reason to
use adjust_resource() rather than just updating res->start and
res->end directly?
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/kernel/resource.c b/kernel/resource.c
index 7e8ea66..51ade23 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -722,14 +722,12 @@  int adjust_resource(struct resource *res, resource_size_t start, resource_size_t
 
 	write_lock(&resource_lock);
 
+	if (!parent)
+		goto skip;
+
 	if ((start < parent->start) || (end > parent->end))
 		goto out;
 
-	for (tmp = res->child; tmp; tmp = tmp->sibling) {
-		if ((tmp->start < start) || (tmp->end > end))
-			goto out;
-	}
-
 	if (res->sibling && (res->sibling->start <= end))
 		goto out;
 
@@ -741,6 +739,11 @@  int adjust_resource(struct resource *res, resource_size_t start, resource_size_t
 			goto out;
 	}
 
+skip:
+	for (tmp = res->child; tmp; tmp = tmp->sibling)
+		if ((tmp->start < start) || (tmp->end > end))
+			goto out;
+
 	res->start = start;
 	res->end = end;
 	result = 0;