diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2019-06-19 11:03:47 +1000 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2019-06-24 14:03:57 +1000 |
commit | 5d30365aec0bea943a103742465a41daa3beeddd (patch) | |
tree | 7598f4f97de611d67ae661710d7238813e9dde29 | |
parent | 1f44db2f459dd16c03833af474e5627809789106 (diff) | |
download | pci-5d30365aec0bea943a103742465a41daa3beeddd.tar.gz |
PCI: Add logic to determine whether to claim a start==0 resource
Some architectures will claim resources whose start is 0, some won't,
some will apply "interesting" heuristics.
Create a weak helper to make that decision, with a default choosing
to claim them when doing a probe only pass, and ignore them otherwise.
This behaviour should match the bulk of the existing cases.
Those who do differently will override the weak function.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | drivers/pci/setup-bus.c | 13 | ||||
-rw-r--r-- | include/linux/pci.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index c8464364f0fb83..8b35271edc11ca 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1380,6 +1380,15 @@ void pci_bus_assign_resources(const struct pci_bus *bus) } EXPORT_SYMBOL(pci_bus_assign_resources); +/* Should we claim a resource whose r->start is 0 ? */ +bool __weak pcibios_claim_zero_resource(struct pci_dev *dev, int rsrc_idx) +{ + struct pci_host_bridge *host = pci_find_host_bridge(dev->bus); + + /* By default, we claim it if we are doing a probe only pass */ + return host->rsrc_policy == pci_rsrc_claim_only; +} + static void pci_claim_device_resources(struct pci_dev *dev) { int i; @@ -1389,6 +1398,8 @@ static void pci_claim_device_resources(struct pci_dev *dev) if (!r->flags || r->parent) continue; + if (!r->start && !pcibios_claim_zero_resource(dev, i)) + continue; pci_claim_resource(dev, i); } @@ -1403,6 +1414,8 @@ static void pci_claim_bridge_resources(struct pci_dev *dev) if (!r->flags || r->parent) continue; + if (!r->start && !pcibios_claim_zero_resource(dev, i)) + continue; pci_claim_bridge_resource(dev, i); } diff --git a/include/linux/pci.h b/include/linux/pci.h index da1551696c9b5d..7eefaa0568309c 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1268,6 +1268,8 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx); void pci_bus_assign_resources(const struct pci_bus *bus); void pci_bus_claim_resources(struct pci_bus *bus); void pci_bus_size_bridges(struct pci_bus *bus); +/* Architecture can override this (weak) */ +bool pcibios_claim_zero_resource(struct pci_dev *dev, int rsrc_idx); int pci_claim_resource(struct pci_dev *, int); int pci_claim_bridge_resource(struct pci_dev *bridge, int i); void pci_assign_unassigned_resources(void); |