Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1160752

Re: [PATCH 1/2] kernel/resource: Add new flag IORESOURCE_SHARED

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] kernel/resource: Add new flag IORESOURCE_SHARED
Date Mon, 08 Jun 2015 22:10:01 +0200
Message-ID <pzbwR-QJ-1@gated-at.bofh.it> (permalink)
References <pxXvX-6f8-7@gated-at.bofh.it> <pz9Y6-6UC-13@gated-at.bofh.it>
X-Original-To Grant Likely <grant.likely@linaro.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=wNLSw50tEjVwJBq5MjBguWwy07IzTFS0sMTYwpRVvKo=; b=PW9KNrBccJMscad/qqbsDDdC+hYJGz8gzyBnEQ5k0knOvunTLprYMnoIjL8qZ0utkf 9jTVDdXavQupDHQ8jxWOLNvcW8+M16K0tCjhno7mgZXu1Jqzg4T1JQl41TIGp22mXLQ6 I8RTEQRPIfs7sBP3sHwTJuVpuQHYLoehFimxHcOnA320YPe5cj2+FWmwHvQe4/kVBTfM C2Su9am8oE/8k4z9ab0i6LdcZdCVLnxuwEBB93Me9w+i0y+Vh79E/k+XRoTzr6Vf00sf XpbLny+4W+097kYJeRsIZaqjNCEXrmPIJDYrO/hQ71Oy0tpEwbcFjpuExi1Ey3KalRZX +nzg==
X-Received by 10.152.23.38 with SMTP id j6mr18310918laf.47.1433793747075; Mon, 08 Jun 2015 13:02:27 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 97
Organization linux.* mail to news gateway
X-Original-Cc Rob Herring <robherring2@gmail.com>, Rob Herring <robh+dt@kernel.org>, Andrew Morton <akpm@linux-foundation.org>, Bjorn Helgaas <bhelgaas@google.com>, Vivek Goyal <vgoyal@redhat.com>, Jakub Sitnicki <jsitnicki@gmail.com>, Mike Travis <travis@sgi.com>, Jiang Liu <jiang.liu@linux.intel.com>, Thierry Reding <treding@nvidia.com>, "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Tejun Heo <tj@kernel.org>, Cliff Wickman <cpw@sgi.com>
X-Original-Date Mon, 8 Jun 2015 22:02:06 +0200
X-Original-Message-ID <CAPybu_2-EZoMEkWR9BoRfzGBevxCp-sd+CiVK2DhRjLoy5Pfyg@mail.gmail.com>
X-Original-References <1433501478-15164-1-git-send-email-ricardo.ribalda@gmail.com> <20150608182310.1F13FC406AA@trevor.secretlab.ca>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1160752

Show key headers only | View raw


Hello Grant

On Mon, Jun 8, 2015 at 8:23 PM, Grant Likely <grant.likely@linaro.org> wrote:
> On Fri,  5 Jun 2015 12:51:17 +0200
> , Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
>  wrote:
>> Some device tree platforms have not defined correctly their memory
>> resources (i.e. Overlapping or duplication of resources).
>> To avoid this issue we have historically avoided to add their resources to
>> the resource tree. This leads to code duplication and oops when trying to
>> unload dynamically a device tree (feature introduced recently).
>>
>> This new flag tells the resource system that a resource can be shared by
>> multiple owners, so we can support device trees with problems at the
>> same time that we do not duplicate code or crash when unloading the
>> device tree.
>>
>> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
>> ---
>
> I'm really not comfortable with this change. The resource tree code is
> complicated enough as is. Adding this exception case quite probably adds
> corner cases that aren't property dealt with. If two regions overlay,
> and then request_region is called? Which region does it become a child
> of? And that's just off the top of my head. I don't want to hack in
> changes to the resource code for what is a corner case.

I see your concern, perhaps you could provide a testcase and we can
find out if it fails or not. So far I have tested a device tree with
two devices on the same memory region, each device managed by a
driver.

I can load and unload the device tree perfectly.

>
> g.
>
>>  include/linux/ioport.h | 1 +
>>  kernel/resource.c      | 6 ++++--
>>  2 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
>> index 388e3ae94f7a..f4d992381529 100644
>> --- a/include/linux/ioport.h
>> +++ b/include/linux/ioport.h
>> @@ -49,6 +49,7 @@ struct resource {
>>  #define IORESOURCE_WINDOW    0x00200000      /* forwarded by bridge */
>>  #define IORESOURCE_MUXED     0x00400000      /* Resource is software muxed */
>>
>> +#define IORESOURCE_SHARED    0x04000000      /* Resource can be shared */
>>  #define IORESOURCE_EXCLUSIVE 0x08000000      /* Userland may not map this resource */
>>  #define IORESOURCE_DISABLED  0x10000000
>>  #define IORESOURCE_UNSET     0x20000000      /* No address assigned yet */
>> diff --git a/kernel/resource.c b/kernel/resource.c
>> index 90552aab5f2d..4a3626489b62 100644
>> --- a/kernel/resource.c
>> +++ b/kernel/resource.c
>> @@ -210,6 +210,7 @@ static struct resource * __request_resource(struct resource *root, struct resour
>>       resource_size_t start = new->start;
>>       resource_size_t end = new->end;
>>       struct resource *tmp, **p;
>> +     bool root_shared = root && root->flags & IORESOURCE_SHARED;
>>
>>       if (end < start)
>>               return root;
>> @@ -220,14 +221,15 @@ static struct resource * __request_resource(struct resource *root, struct resour
>>       p = &root->child;
>>       for (;;) {
>>               tmp = *p;
>> -             if (!tmp || tmp->start > end) {
>> +             if (!tmp || tmp->start > end ||
>> +                     (root_shared && tmp->start > start)) {
>>                       new->sibling = tmp;
>>                       *p = new;
>>                       new->parent = root;
>>                       return NULL;
>>               }
>>               p = &tmp->sibling;
>> -             if (tmp->end < start)
>> +             if (tmp->end < start || root_shared)
>>                       continue;
>>               return tmp;
>>       }
>> --
>> 2.1.4
>>
>



-- 
Ricardo Ribalda
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: [PATCH 1/2] kernel/resource: Add new flag IORESOURCE_SHARED Grant Likely <grant.likely@linaro.org> - 2015-06-08 20:30 +0200
  Re: [PATCH 1/2] kernel/resource: Add new flag IORESOURCE_SHARED Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> - 2015-06-08 22:10 +0200

csiph-web