Skip to content

Commit 2c62e84

Browse files
Jiang Liurafaeljw
authored andcommitted
x86/PCI/ACPI: Make all resources except [io 0xcf8-0xcff] available on PCI bus
An IO port or MMIO resource assigned to a PCI host bridge may be consumed by the host bridge itself or available to its child bus/devices. The ACPI specification defines a bit (Producer/Consumer) to tell whether the resource is consumed by the host bridge itself, but firmware hasn't used that bit consistently, so we can't rely on it. Before commit 593669c ("x86/PCI/ACPI: Use common ACPI resource interfaces to simplify implementation"), arch/x86/pci/acpi.c ignored all IO port resources defined by acpi_resource_io and acpi_resource_fixed_io to filter out IO ports consumed by the host bridge itself. Commit 593669c ("x86/PCI/ACPI: Use common ACPI resource interfaces to simplify implementation") started accepting all IO port and MMIO resources, which caused a regression that IO port resources consumed by the host bridge itself became available to its child devices. Then commit 63f1789 ("x86/PCI/ACPI: Ignore resources consumed by host bridge itself") ignored resources consumed by the host bridge itself by checking the IORESOURCE_WINDOW flag, which accidently removed MMIO resources defined by acpi_resource_memory24, acpi_resource_memory32 and acpi_resource_fixed_memory32. On x86 and IA64 platforms, all IO port and MMIO resources are assumed to be available to child bus/devices except one special case: IO port [0xCF8-0xCFF] is consumed by the host bridge itself to access PCI configuration space. So explicitly filter out PCI CFG IO ports[0xCF8-0xCFF]. This solution will also ease the way to consolidate ACPI PCI host bridge common code from x86, ia64 and ARM64. Related ACPI table are archived at: https://bugzilla.kernel.org/show_bug.cgi?id=94221 Related discussions at: http://patchwork.ozlabs.org/patch/461633/ https://lkml.org/lkml/2015/3/29/304 Fixes: 63f1789 (Ignore resources consumed by host bridge itself) Reported-by: Bernhard Thaler <bernhard.thaler@wvnet.at> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com> Cc: 4.0+ <stable@vger.kernel.org> # 4.0+ Reviewed-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent b787f68 commit 2c62e84

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

arch/x86/pci/acpi.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,26 @@ static void release_pci_root_info(struct pci_host_bridge *bridge)
325325
kfree(info);
326326
}
327327

328+
/*
329+
* An IO port or MMIO resource assigned to a PCI host bridge may be
330+
* consumed by the host bridge itself or available to its child
331+
* bus/devices. The ACPI specification defines a bit (Producer/Consumer)
332+
* to tell whether the resource is consumed by the host bridge itself,
333+
* but firmware hasn't used that bit consistently, so we can't rely on it.
334+
*
335+
* On x86 and IA64 platforms, all IO port and MMIO resources are assumed
336+
* to be available to child bus/devices except one special case:
337+
* IO port [0xCF8-0xCFF] is consumed by the host bridge itself
338+
* to access PCI configuration space.
339+
*
340+
* So explicitly filter out PCI CFG IO ports[0xCF8-0xCFF].
341+
*/
342+
static bool resource_is_pcicfg_ioport(struct resource *res)
343+
{
344+
return (res->flags & IORESOURCE_IO) &&
345+
res->start == 0xCF8 && res->end == 0xCFF;
346+
}
347+
328348
static void probe_pci_root_info(struct pci_root_info *info,
329349
struct acpi_device *device,
330350
int busnum, int domain,
@@ -346,8 +366,8 @@ static void probe_pci_root_info(struct pci_root_info *info,
346366
"no IO and memory resources present in _CRS\n");
347367
else
348368
resource_list_for_each_entry_safe(entry, tmp, list) {
349-
if ((entry->res->flags & IORESOURCE_WINDOW) == 0 ||
350-
(entry->res->flags & IORESOURCE_DISABLED))
369+
if ((entry->res->flags & IORESOURCE_DISABLED) ||
370+
resource_is_pcicfg_ioport(entry->res))
351371
resource_list_destroy_entry(entry);
352372
else
353373
entry->res->name = info->name;

drivers/acpi/resource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_resources);
573573
* @ares: Input ACPI resource object.
574574
* @types: Valid resource types of IORESOURCE_XXX
575575
*
576-
* This is a hepler function to support acpi_dev_get_resources(), which filters
576+
* This is a helper function to support acpi_dev_get_resources(), which filters
577577
* ACPI resource objects according to resource types.
578578
*/
579579
int acpi_dev_filter_resource_type(struct acpi_resource *ares,

0 commit comments

Comments
 (0)