From: Ilpo Järvinen Date: Fri, 19 Dec 2025 17:40:35 +0000 (+0200) Subject: PCI: Add pbus_validate_busn() for Bus Number validation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cbb40c3d46415bff4ba4b75ccc96007217112f0;p=thirdparty%2Fkernel%2Flinux.git PCI: Add pbus_validate_busn() for Bus Number validation 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 Signed-off-by: Bjorn Helgaas Link: https://patch.msgid.link/20251219174036.16738-23-ilpo.jarvinen@linux.intel.com --- diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index dbea5db07959..b20ff7ef20ff 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -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); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 53ec1879fb99..388bcf3a41f1 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -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 */