[PATCH 4/4] arm64: pci: acpi: Preserve PCI resources configuration when asked by ACPI

Benjamin Herrenschmidt
2019-06-15T00:30:10Z

When _DSM #5 returns 0 for a host bridge, we need to claim the existing
resources rather than reassign everything.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/arm64/kernel/pci.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index 1419b1b4e9b9..a2c608a3fc41 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -168,6 +168,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
struct acpi_pci_generic_root_info *ri;
struct pci_bus *bus, *child;
struct acpi_pci_root_ops *root_ops;
+ struct pci_host_bridge *hb;

ri = kzalloc(sizeof(*ri), GFP_KERNEL);
if (!ri)
@@ -193,6 +194,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
if (!bus)
return NULL;

+ hb = pci_find_host_bridge(bus);
+
+ /* If ACPI tells us to preserve the resource configuration, claim now */
+ if (hb->preserve_config)
+ pci_bus_claim_resources(bus);
+
+ /*
+ * Assign whatever was left unassigned. If we didn't claim above, this will
+ * reassign everything.
+ */
pci_assign_unassigned_root_bus_resources(bus);

list_for_each_entry(child, &bus->children, node)
--
2.17.1