]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: Add pbus_validate_busn() for Bus Number validation
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 19 Dec 2025 17:40:35 +0000 (19:40 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 27 Jan 2026 22:36:53 +0000 (16:36 -0600)
pci_scan_bridge_extend() validates bus numbers but upcoming changes that
separate CardBus code into own function need to call that the same
validation.

Thus, add pbus_validate_busn for validating the Bus Numbers.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20251219174036.16738-23-ilpo.jarvinen@linux.intel.com
drivers/pci/pci.h
drivers/pci/probe.c

index dbea5db0795989c0e11b1b3d882db176f95a4278..b20ff7ef20ff263bee16b740723d47da629373b0 100644 (file)
@@ -501,6 +501,7 @@ static inline int pci_resource_num(const struct pci_dev *dev,
        return resno;
 }
 
+void pbus_validate_busn(struct pci_bus *bus);
 struct resource *pbus_select_window(struct pci_bus *bus,
                                    const struct resource *res);
 void pci_reassigndev_resource_alignment(struct pci_dev *dev);
index 53ec1879fb9969969930082796e4157a74741548..388bcf3a41f14ee34f392f1859b0577d8f6b5980 100644 (file)
@@ -1312,6 +1312,26 @@ static void pci_enable_rrs_sv(struct pci_dev *pdev)
 
 static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
                                              unsigned int available_buses);
+
+void pbus_validate_busn(struct pci_bus *bus)
+{
+       struct pci_bus *upstream = bus->parent;
+       struct pci_dev *bridge = bus->self;
+
+       /* Check that all devices are accessible */
+       while (upstream->parent) {
+               if ((bus->busn_res.end > upstream->busn_res.end) ||
+                   (bus->number > upstream->busn_res.end) ||
+                   (bus->number < upstream->number) ||
+                   (bus->busn_res.end < upstream->number)) {
+                       pci_info(bridge, "devices behind bridge are unusable because %pR cannot be assigned for them\n",
+                                &bus->busn_res);
+                       break;
+               }
+               upstream = upstream->parent;
+       }
+}
+
 /**
  * pci_ea_fixed_busnrs() - Read fixed Secondary and Subordinate bus
  * numbers from EA capability.
@@ -1577,18 +1597,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
                  (is_cardbus ? "PCI CardBus %04x:%02x" : "PCI Bus %04x:%02x"),
                  pci_domain_nr(bus), child->number);
 
-       /* Check that all devices are accessible */
-       while (bus->parent) {
-               if ((child->busn_res.end > bus->busn_res.end) ||
-                   (child->number > bus->busn_res.end) ||
-                   (child->number < bus->number) ||
-                   (child->busn_res.end < bus->number)) {
-                       dev_info(&dev->dev, "devices behind bridge are unusable because %pR cannot be assigned for them\n",
-                                &child->busn_res);
-                       break;
-               }
-               bus = bus->parent;
-       }
+       pbus_validate_busn(child);
 
 out:
        /* Clear errors in the Secondary Status Register */