diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2019-06-24 11:24:08 +1000 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2019-06-24 11:55:04 +1000 |
commit | 9c672eda23ac8a9d7104a3133bdec381627e0987 (patch) | |
tree | f269d7f1bc48fc03a21f21b800616ac7d270efb9 | |
parent | dc6dc7d43750e4a8ee82f2e35159a0f48d6801c5 (diff) | |
download | pci-9c672eda23ac8a9d7104a3133bdec381627e0987.tar.gz |
PCI: Add generic function to perform PCI resource survey
This function will honor the policy set in the host bridge
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | drivers/pci/setup-bus.c | 21 | ||||
-rw-r--r-- | include/linux/pci.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index bf622bdadd21ed..df35d605563848 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -2168,3 +2168,24 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus) BUG_ON(!list_empty(&add_list)); } EXPORT_SYMBOL_GPL(pci_assign_unassigned_bus_resources); + +void pci_host_resource_survey(struct pci_bus *bus) +{ + struct pci_host_bridge *host = pci_find_host_bridge(bus); + + /* Claim existing resources if required */ + if (host->rsrc_policy <= pci_rsrc_claim_assign) + pci_bus_claim_resources(bus); + + /* If we do any kind of assignment, do it now */ + if (host->rsrc_policy >= pci_rsrc_claim_assign_restricted) { + struct pci_bus *child; + + pci_assign_unassigned_root_bus_resources(bus); + + /* Handle PCIe settings */ + list_for_each_entry(child, &bus->children, node) + pcie_bus_configure_settings(child); + } +} +EXPORT_SYMBOL(pci_host_resource_survey); diff --git a/include/linux/pci.h b/include/linux/pci.h index 6fa6df074ceebf..da1551696c9b5d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -579,6 +579,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge); +void pci_host_resource_survey(struct pci_bus *bus); + /* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for |