aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/probe.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/probe.c')
-rw-r--r--drivers/pci/probe.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index e3cf8a2e6292..4170113cde61 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -775,7 +775,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
775 /* Check if setup is sensible at all */ 775 /* Check if setup is sensible at all */
776 if (!pass && 776 if (!pass &&
777 (primary != bus->number || secondary <= bus->number || 777 (primary != bus->number || secondary <= bus->number ||
778 secondary > subordinate || subordinate > bus->busn_res.end)) { 778 secondary > subordinate)) {
779 dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", 779 dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n",
780 secondary, subordinate); 780 secondary, subordinate);
781 broken = 1; 781 broken = 1;
@@ -838,23 +838,18 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
838 goto out; 838 goto out;
839 } 839 }
840 840
841 if (max >= bus->busn_res.end) {
842 dev_warn(&dev->dev, "can't allocate child bus %02x from %pR\n",
843 max, &bus->busn_res);
844 goto out;
845 }
846
847 /* Clear errors */ 841 /* Clear errors */
848 pci_write_config_word(dev, PCI_STATUS, 0xffff); 842 pci_write_config_word(dev, PCI_STATUS, 0xffff);
849 843
850 /* The bus will already exist if we are rescanning */ 844 /* Prevent assigning a bus number that already exists.
845 * This can happen when a bridge is hot-plugged, so in
846 * this case we only re-scan this bus. */
851 child = pci_find_bus(pci_domain_nr(bus), max+1); 847 child = pci_find_bus(pci_domain_nr(bus), max+1);
852 if (!child) { 848 if (!child) {
853 child = pci_add_new_bus(bus, dev, max+1); 849 child = pci_add_new_bus(bus, dev, max+1);
854 if (!child) 850 if (!child)
855 goto out; 851 goto out;
856 pci_bus_insert_busn_res(child, max+1, 852 pci_bus_insert_busn_res(child, max+1, 0xff);
857 bus->busn_res.end);
858 } 853 }
859 max++; 854 max++;
860 buses = (buses & 0xff000000) 855 buses = (buses & 0xff000000)
@@ -913,11 +908,6 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
913 /* 908 /*
914 * Set the subordinate bus number to its real value. 909 * Set the subordinate bus number to its real value.
915 */ 910 */
916 if (max > bus->busn_res.end) {
917 dev_warn(&dev->dev, "max busn %02x is outside %pR\n",
918 max, &bus->busn_res);
919 max = bus->busn_res.end;
920 }
921 pci_bus_update_busn_res_end(child, max); 911 pci_bus_update_busn_res_end(child, max);
922 pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); 912 pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max);
923 } 913 }