Subject: [PATCH] x86, pci, acpi: fix root res probing old setup with nehalem got: [ 32.353347] acpi PNP0A08:00: host bridge window expanded to [mem 0x00000000-0xffffffff]; [mem 0x000a0000-0x000bffff] ignored [ 32.362897] acpi PNP0A08:00: host bridge window expanded to [mem 0x00000000-0xffffffff]; [mem 0x000d0000-0x000dffff] ignored [ 32.382862] acpi PNP0A08:00: host bridge window expanded to [mem 0x00000000-0xffffffff]; [mem 0x00000000-0xffffffff] ignored [ 32.402889] acpi PNP0A08:00: host bridge window expanded to [mem 0x00000000-0xffffffff]; [??? 0x00000000-0xffffffff flags 0x0] ignored [ 32.423000] acpi PNP0A08:00: host bridge window expanded to [mem 0x00000000-0xffffffff]; [mem 0x00000000-0xffffffff] ignored [ 32.602921] PCI host bridge to bus 0000:00 [ 32.603158] pci_bus 0000:00: root bus resource [bus 00-3f] [ 32.622782] pci_bus 0000:00: root bus resource [io 0x0000-0x5fff] [ 32.642569] pci_bus 0000:00: root bus resource [mem 0x00000000-0xffffffff] [ 32.642893] pci_bus 0000:00: root bus resource [mem 0xfc000000000-0xfc07fffffff pref] The problem is caused commit e22ce93870de ("x86, PCI, ACPI: Kill private function resource_to_addr() in arch/x86/pci/acpi.c"). as the system has [ 32.395504] acpi PNP0A08:00: addr host bridge window [bus 00-3f] [ 32.412395] acpi PNP0A08:00: addr host bridge window [io 0x0000-0x5fff window] [ 32.412745] acpi PNP0A08:00: addr host bridge window [mem 0x000a0000-0x000bffff window] [ 32.432559] acpi PNP0A08:00: addr host bridge window [mem 0x000d0000-0x000dffff window] [ 32.452432] acpi PNP0A08:00: addr host bridge window [mem 0x00000000-0xffffffff window] [ 32.472303] acpi PNP0A08:00: addr host bridge window [mem 0x90000000-0xafffffff window] [ 32.472653] acpi PNP0A08:00: addr host bridge window [mem 0xfed40000-0xfed44fff window] [ 32.492539] acpi PNP0A08:00: addr host bridge window [mem 0xfc000000000-0xfc07fffffff window] but the one [mem 0x00000000-0xffffffff window] with address_length == 0 that was rejected by old resource_to_addr(). Add that check into acpi_dev_resource_address_space() to fix the problem. Also fixes other problems: 1. need to initialize local r and addr to 0. 2. fix orig_end assigning, as it should be after offset adding. 3. need to do clipping and checking for acpi_dev_resource_memory path. 4. also acpi_dev_resource_memory should & with IORESOURCE_MEM. Fixes: commit e22ce93870de ("x86, PCI, ACPI: Kill private function resource_to_addr() in arch/x86/pci/acpi.c"). Signed-off-by: Yinghai Lu --- arch/x86/pci/acpi.c | 60 +++++++++++++++++++++++------------------------- drivers/acpi/resource.c | 2 - 2 files changed, 30 insertions(+), 32 deletions(-) Index: linux-2.6/arch/x86/pci/acpi.c =================================================================== --- linux-2.6.orig/arch/x86/pci/acpi.c +++ linux-2.6/arch/x86/pci/acpi.c @@ -221,10 +221,9 @@ static void teardown_mcfg_map(struct pci static acpi_status count_resource(struct acpi_resource *acpi_res, void *data) { struct pci_root_info *info = data; - struct resource r = { - .flags = 0 - }; + struct resource r; + memset(&r, 0, sizeof(r)); if (!acpi_dev_resource_memory(acpi_res, &r) && !acpi_dev_resource_address_space(acpi_res, &r)) return AE_OK; @@ -239,20 +238,20 @@ static acpi_status setup_resource(struct { struct pci_root_info *info = data; u64 translation_offset = 0; - struct resource r = { - .flags = 0 - }; + struct resource r; + u64 orig_end; + memset(&r, 0, sizeof(r)); if (acpi_dev_resource_memory(acpi_res, &r)) { - r.flags &= IORESOURCE_MEM | IORESOURCE_IO; + r.flags &= IORESOURCE_MEM; } else if (acpi_dev_resource_address_space(acpi_res, &r)) { - u64 orig_end; struct acpi_resource_address64 addr; r.flags &= IORESOURCE_MEM | IORESOURCE_IO; if (r.flags == 0) return AE_OK; + memset(&addr, 0, sizeof(addr)); if (ACPI_FAILURE(acpi_resource_to_address64(acpi_res, &addr))) return AE_OK; @@ -261,34 +260,33 @@ static acpi_status setup_resource(struct r.flags |= IORESOURCE_PREFETCH; translation_offset = addr.translation_offset; - orig_end = r.end; r.start += translation_offset; r.end += translation_offset; + } else + return AE_OK; - /* Exclude non-addressable range or non-addressable portion of range */ - r.end = min(r.end, iomem_resource.end); - if (r.end <= r.start) { - dev_info(&info->bridge->dev, - "host bridge window [%#llx-%#llx] (ignored, not CPU addressable)\n", - (unsigned long long)r.start, orig_end); - return AE_OK; - } else if (orig_end != r.end) { - dev_info(&info->bridge->dev, - "host bridge window [%#llx-%#llx] ([%#llx-%#llx] ignored, not CPU addressable)\n", - (unsigned long long)r.start, orig_end, - (unsigned long long)r.end + 1, orig_end); - } + /* Exclude non-addressable range or non-addressable portion of range */ + orig_end = r.end; + r.end = min(r.end, iomem_resource.end); + if (r.end <= r.start) { + dev_info(&info->bridge->dev, + "host bridge window [%#llx-%#llx] (ignored, not CPU addressable)\n", + (unsigned long long)r.start, orig_end); + return AE_OK; + } else if (orig_end != r.end) { + dev_info(&info->bridge->dev, + "host bridge window [%#llx-%#llx] ([%#llx-%#llx] ignored, not CPU addressable)\n", + (unsigned long long)r.start, orig_end, + (unsigned long long)r.end + 1, orig_end); } - if (r.flags && resource_size(&r)) { - r.name = info->name; - info->res[info->res_num] = r; - info->res_offset[info->res_num] = translation_offset; - info->res_num++; - if (!pci_use_crs) - dev_printk(KERN_DEBUG, &info->bridge->dev, - "host bridge window %pR (ignored)\n", &r); - } + r.name = info->name; + info->res[info->res_num] = r; + info->res_offset[info->res_num] = translation_offset; + info->res_num++; + if (!pci_use_crs) + dev_printk(KERN_DEBUG, &info->bridge->dev, + "host bridge window %pR (ignored)\n", &r); return AE_OK; } Index: linux-2.6/drivers/acpi/resource.c =================================================================== --- linux-2.6.orig/drivers/acpi/resource.c +++ linux-2.6/drivers/acpi/resource.c @@ -199,7 +199,7 @@ bool acpi_dev_resource_address_space(str } status = acpi_resource_to_address64(ares, &addr); - if (ACPI_FAILURE(status)) + if (ACPI_FAILURE(status) || !addr.address_length) return false; res->start = addr.minimum;