From: Yinghai Lu on
On 04/14/2010 09:55 AM, Bjorn Helgaas wrote:
> On Tuesday 13 April 2010 06:57:54 pm Yinghai wrote:
>
>
>> Subject: [PATCH] x86, resource: Add reserve_region_with_split_check_child()
>>
>> It will cover the whole region to BUSY, except that some regions that have
>> children under them.
>>
>> those children normally is PCI bar but it is falling into E820_RESERVED.
>> We can not put BUSY on them, otherwise driver can not use pci_request_region()
>> later
>>
>> /proc/iomem will have
>> 00010000-00094fff : System RAM
>> 00095000-0009ffff : reserved
>> 000a0000-000bffff : PCI Bus 0000:00
>> 000a0000-000bffff : reserved
>> 000c0000-000cffff : reserved
>> 000d0000-000dffff : PCI Bus 0000:00
>> 000d0000-000dffff : reserved
>> 000e0000-000fffff : reserved
>>
>> Signed-off-by: Yinghai Lu <yinghai(a)kernel.org>
>>
>> ---
>> arch/x86/kernel/e820.c | 10 +++++++---
>> include/linux/ioport.h | 3 +++
>> kernel/resource.c | 24 +++++++++++++++++++-----
>> 3 files changed, 29 insertions(+), 8 deletions(-)
>>
>> Index: linux-2.6/arch/x86/kernel/e820.c
>> ===================================================================
>> --- linux-2.6.orig/arch/x86/kernel/e820.c
>> +++ linux-2.6/arch/x86/kernel/e820.c
>> @@ -1094,7 +1094,7 @@ void __init e820_reserve_resources(void)
>> * pci device BAR resource and insert them later in
>> * pcibios_resource_survey()
>> */
>> - if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20)) {
>> + if (e820.map[i].type != E820_RESERVED) {
>> res->flags |= IORESOURCE_BUSY;
>> insert_resource(&iomem_resource, res);
>> }
>> @@ -1135,8 +1135,12 @@ void __init e820_reserve_resources_late(
>>
>> res = e820_res;
>> for (i = 0; i < e820.nr_map; i++) {
>> - if (!res->parent && res->end)
>> - insert_resource_expand_to_fit(&iomem_resource, res);
>> + if (!res->parent && res->end) {
>> + if (res->start < (1ULL<<20)) {
>> + reserve_region_with_split_check_child(&iomem_resource, res->start, res->end, res->name);
>> + } else
>> + insert_resource_expand_to_fit(&iomem_resource, res);
>>
> I don't like adding all these special-purpose resource interfaces, e.g.,
> insert_resource_expand_to_fit(), reserve_region_with_split(),
> reserve_region_with_split_check_child(), etc. They tend to be only
> used by one caller, which is a clue to me that we're doing something
> wrong.
>
> Sometimes we'd like to print debug information in them (as we do in
> insert_resource_expand_to_fit()), but we don't have enough context,
> so the message isn't very meaningful.
>
print out related resource tree segment ?
> I think it's better to have more generic interfaces that allow us to
> implement this sort of functionality where it's used and where we
> have the context to print useful messages. For example, could the
> reserve_region_with_split_check_child() functionality be implemented
> in e820.c by building on something like request_resource_conflict()?
>
>
>> + }
>> res++;
>> }
>>
>> Index: linux-2.6/include/linux/ioport.h
>> ===================================================================
>> --- linux-2.6.orig/include/linux/ioport.h
>> +++ linux-2.6/include/linux/ioport.h
>> @@ -120,6 +120,9 @@ void release_child_resources(struct reso
>> extern void reserve_region_with_split(struct resource *root,
>> resource_size_t start, resource_size_t end,
>> const char *name);
>> +void reserve_region_with_split_check_child(struct resource *root,
>> + resource_size_t start, resource_size_t end,
>> + const char *name);
>> extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new);
>> extern int insert_resource(struct resource *parent, struct resource *new);
>> extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
>> Index: linux-2.6/kernel/resource.c
>> ===================================================================
>> --- linux-2.6.orig/kernel/resource.c
>> +++ linux-2.6/kernel/resource.c
>> @@ -609,7 +609,7 @@ int adjust_resource(struct resource *res
>>
>> static void __init __reserve_region_with_split(struct resource *root,
>> resource_size_t start, resource_size_t end,
>> - const char *name)
>> + const char *name, bool check_child)
>> {
>> struct resource *parent = root;
>> struct resource *conflict;
>> @@ -631,13 +631,18 @@ static void __init __reserve_region_with
>> kfree(res);
>>
>> /* conflict covered whole area */
>> - if (conflict->start <= start && conflict->end >= end)
>> + if (conflict->start <= start && conflict->end >= end) {
>> + if (check_child && !conflict->child && strstr(conflict->name, "PCI Bus"))
>>
> This is kind of gross, too. Checking the name of a resource for "PCI Bus"?
>
yes, in case some system have device on BUS 0 directly. but have device
have pci BAR below 1M and fall into E820_RESERVED.

YH
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Andy Isaacson on
On Tue, Apr 13, 2010 at 05:57:54PM -0700, Yinghai wrote:
> On 04/13/2010 02:58 PM, H. Peter Anvin wrote:
> > That's not good (in general - for devices in this particular range it's
> > not such a big deal, but it is potentially really bad for devices marked
> > reserved for them not to be moved.)
> >
> > We have talked about a need to resolve this before.
>
> this one should make both cases work.
>
> Andy, can you check this one together with
> v3: x86: Reserve [0xa0000, 0x100000] in e820 map

I've booted successfully with the patch below, on top of the patch in
Message-ID: <4BC4E09F.9000608(a)oracle.com>

I'll attach the dmesg to bug 15744.

-andy

> Guenter, can you try the two patches on the system with special device?
>
> Thanks
>
> Yinghai
>
> --------
>
> Subject: [PATCH] x86, resource: Add reserve_region_with_split_check_child()
>
> It will cover the whole region to BUSY, except that some regions that have
> children under them.
>
> those children normally is PCI bar but it is falling into E820_RESERVED.
> We can not put BUSY on them, otherwise driver can not use pci_request_region()
> later
>
> /proc/iomem will have
> 00010000-00094fff : System RAM
> 00095000-0009ffff : reserved
> 000a0000-000bffff : PCI Bus 0000:00
> 000a0000-000bffff : reserved
> 000c0000-000cffff : reserved
> 000d0000-000dffff : PCI Bus 0000:00
> 000d0000-000dffff : reserved
> 000e0000-000fffff : reserved
>
> Signed-off-by: Yinghai Lu <yinghai(a)kernel.org>
>
> ---
> arch/x86/kernel/e820.c | 10 +++++++---
> include/linux/ioport.h | 3 +++
> kernel/resource.c | 24 +++++++++++++++++++-----
> 3 files changed, 29 insertions(+), 8 deletions(-)
>
> Index: linux-2.6/arch/x86/kernel/e820.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/e820.c
> +++ linux-2.6/arch/x86/kernel/e820.c
> @@ -1094,7 +1094,7 @@ void __init e820_reserve_resources(void)
> * pci device BAR resource and insert them later in
> * pcibios_resource_survey()
> */
> - if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20)) {
> + if (e820.map[i].type != E820_RESERVED) {
> res->flags |= IORESOURCE_BUSY;
> insert_resource(&iomem_resource, res);
> }
> @@ -1135,8 +1135,12 @@ void __init e820_reserve_resources_late(
>
> res = e820_res;
> for (i = 0; i < e820.nr_map; i++) {
> - if (!res->parent && res->end)
> - insert_resource_expand_to_fit(&iomem_resource, res);
> + if (!res->parent && res->end) {
> + if (res->start < (1ULL<<20)) {
> + reserve_region_with_split_check_child(&iomem_resource, res->start, res->end, res->name);
> + } else
> + insert_resource_expand_to_fit(&iomem_resource, res);
> + }
> res++;
> }
>
> Index: linux-2.6/include/linux/ioport.h
> ===================================================================
> --- linux-2.6.orig/include/linux/ioport.h
> +++ linux-2.6/include/linux/ioport.h
> @@ -120,6 +120,9 @@ void release_child_resources(struct reso
> extern void reserve_region_with_split(struct resource *root,
> resource_size_t start, resource_size_t end,
> const char *name);
> +void reserve_region_with_split_check_child(struct resource *root,
> + resource_size_t start, resource_size_t end,
> + const char *name);
> extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new);
> extern int insert_resource(struct resource *parent, struct resource *new);
> extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
> Index: linux-2.6/kernel/resource.c
> ===================================================================
> --- linux-2.6.orig/kernel/resource.c
> +++ linux-2.6/kernel/resource.c
> @@ -609,7 +609,7 @@ int adjust_resource(struct resource *res
>
> static void __init __reserve_region_with_split(struct resource *root,
> resource_size_t start, resource_size_t end,
> - const char *name)
> + const char *name, bool check_child)
> {
> struct resource *parent = root;
> struct resource *conflict;
> @@ -631,13 +631,18 @@ static void __init __reserve_region_with
> kfree(res);
>
> /* conflict covered whole area */
> - if (conflict->start <= start && conflict->end >= end)
> + if (conflict->start <= start && conflict->end >= end) {
> + if (check_child && !conflict->child && strstr(conflict->name, "PCI Bus"))
> + __reserve_region_with_split(conflict, start, end, name, false);
> return;
> + }
>
> if (conflict->start > start)
> - __reserve_region_with_split(root, start, conflict->start-1, name);
> + __reserve_region_with_split(root, start, conflict->start-1, name, check_child);
> if (conflict->end < end)
> - __reserve_region_with_split(root, conflict->end+1, end, name);
> + __reserve_region_with_split(root, conflict->end+1, end, name, check_child);
> + if (check_child && !conflict->child && strstr(conflict->name, "PCI Bus"))
> + __reserve_region_with_split(conflict, conflict->start, conflict->end, name, false);
> }
>
> void __init reserve_region_with_split(struct resource *root,
> @@ -645,7 +650,16 @@ void __init reserve_region_with_split(st
> const char *name)
> {
> write_lock(&resource_lock);
> - __reserve_region_with_split(root, start, end, name);
> + __reserve_region_with_split(root, start, end, name, false);
> + write_unlock(&resource_lock);
> +}
> +
> +void __init reserve_region_with_split_check_child(struct resource *root,
> + resource_size_t start, resource_size_t end,
> + const char *name)
> +{
> + write_lock(&resource_lock);
> + __reserve_region_with_split(root, start, end, name, true);
> write_unlock(&resource_lock);
> }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Yinghai on
On 04/14/2010 12:25 PM, Andy Isaacson wrote:
> On Tue, Apr 13, 2010 at 05:57:54PM -0700, Yinghai wrote:
>> On 04/13/2010 02:58 PM, H. Peter Anvin wrote:
>>> That's not good (in general - for devices in this particular range it's
>>> not such a big deal, but it is potentially really bad for devices marked
>>> reserved for them not to be moved.)
>>>
>>> We have talked about a need to resolve this before.
>>
>> this one should make both cases work.
>>
>> Andy, can you check this one together with
>> v3: x86: Reserve [0xa0000, 0x100000] in e820 map
>
> I've booted successfully with the patch below, on top of the patch in
> Message-ID: <4BC4E09F.9000608(a)oracle.com>
>
> I'll attach the dmesg to bug 15744.

thanks. please put /proc/iomem there too.

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Andy Isaacson on
On Wed, Apr 14, 2010 at 12:27:40PM -0700, Yinghai wrote:
> > I'll attach the dmesg to bug 15744.
>
> thanks. please put /proc/iomem there too.

I attached it to the bug.

-andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Yinghai on
On 04/14/2010 12:43 PM, Andy Isaacson wrote:
> On Wed, Apr 14, 2010 at 12:27:40PM -0700, Yinghai wrote:
>>> I'll attach the dmesg to bug 15744.
>>
>> thanks. please put /proc/iomem there too.
>
> I attached it to the bug.

looks good.

000a0000-000bffff : PCI Bus 0000:00
000a0000-000bffff : reserved
000c0000-000effff : PCI Bus 0000:00
000c0000-000effff : reserved
000f0000-000fffff : PCI Bus 0000:00
000f0000-000fffff : reserved

Thanks

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