diff mbox

[10/21] PCI: checking busn_res in pci_scan_root_bus()

Message ID 1336422606-4244-11-git-send-email-yinghai@kernel.org
State Rejected
Headers show

Commit Message

Yinghai Lu May 7, 2012, 8:29 p.m. UTC
Some callers do not supply the bus number aperture, usually because they do
not know the end.  In this case, we assume the aperture extends from the
root bus number to bus 255, scan the bus, and shrink the bus number
resource so it ends at the largest bus number we found.

This is obviously not correct because the actual end of the aperture may
well be larger than the largest bus number we found.  But I guess it's all
we have for now.

Also print out one info about that, so we could find out which path
does not have busn_res in resources list.

-v4: set found initial value to false.

[bhelgaas: changelog, list _safe iterator unnecessary, use %pR format for bus]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
 drivers/pci/probe.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
diff mbox


diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 59011ce..6258f6f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1788,13 +1788,33 @@  void pci_bus_release_busn_res(struct pci_bus *b)
 struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+	struct pci_host_bridge_window *window;
+	bool found = false;
 	struct pci_bus *b;
+	int max;
+	list_for_each_entry(window, resources, list)
+		if (window->res->flags & IORESOURCE_BUS) {
+			found = true;
+			break;
+		}
 	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
 	if (!b)
 		return NULL;
-	b->busn_res.end = pci_scan_child_bus(b);
+	if (!found) {
+		dev_info(&b->dev,
+		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
+			bus);
+		pci_bus_insert_busn_res(b, bus, 255);
+	}
+	max = pci_scan_child_bus(b);
+	if (!found)
+		pci_bus_update_busn_res_end(b, max);
 	return b;