Commit 1820ffdc authored by Andreas Noever's avatar Andreas Noever Committed by Bjorn Helgaas

PCI: Make sure bus number resources stay within their parents bounds

Right now we use 0xff for busn_res.end when probing and later reduce it to
the value that is actually used. This does not work if a parent bridge has
already a lower subordinate value. For example during hotplug of a new
bridge below an already-configured bridge the following message is printed
from pci_bus_insert_busn_res():

  pci_bus 0000:06: busn_res: can not insert [bus 06-ff] under [bus 05-9b] (conflicts with (null) [bus 05-9b])

This patch clamps the bus range to that of the parent and also ensures that
we do not exceed the parents range when assigning the final subordinate
value.

We also check that busses configured by the firmware fit into their parents
bounds.

[bhelgaas: reword dev_warn() and fix printk format warning]
Signed-off-by: default avatarAndreas Noever <andreas.noever@gmail.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent ced04d15
...@@ -782,7 +782,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) ...@@ -782,7 +782,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
/* Check if setup is sensible at all */ /* Check if setup is sensible at all */
if (!pass && if (!pass &&
(primary != bus->number || secondary <= bus->number || (primary != bus->number || secondary <= bus->number ||
secondary > subordinate)) { secondary > subordinate || subordinate > bus->busn_res.end)) {
dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n",
secondary, subordinate); secondary, subordinate);
broken = 1; broken = 1;
...@@ -854,7 +854,8 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) ...@@ -854,7 +854,8 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
child = pci_add_new_bus(bus, dev, max+1); child = pci_add_new_bus(bus, dev, max+1);
if (!child) if (!child)
goto out; goto out;
pci_bus_insert_busn_res(child, max+1, 0xff); pci_bus_insert_busn_res(child, max+1,
bus->busn_res.end);
} }
max++; max++;
buses = (buses & 0xff000000) buses = (buses & 0xff000000)
...@@ -927,6 +928,11 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) ...@@ -927,6 +928,11 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
/* /*
* Set the subordinate bus number to its real value. * Set the subordinate bus number to its real value.
*/ */
if (max > bus->busn_res.end) {
dev_warn(&dev->dev, "max busn %02x is outside %pR\n",
max, &bus->busn_res);
max = bus->busn_res.end;
}
pci_bus_update_busn_res_end(child, max); pci_bus_update_busn_res_end(child, max);
pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment