[PATCH 1/2] PCI: Preserve the initial bus number in pci_dev

From: Mario Limonciello

Date: Mon Oct 19 2026 - 21:46:36 EST


PCI bus numbers can be reassigned after device discovery, for example
during resource reallocation. Preserve the number seen at allocation
time so drivers can match devices using firmware-visible bus numbers.

Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
---
drivers/pci/probe.c | 1 +
include/linux/pci.h | 1 +
2 files changed, 2 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27008e2ea5afc..580b288d5c64f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2508,6 +2508,7 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
INIT_LIST_HEAD(&dev->bus_list);
dev->dev.type = &pci_dev_type;
dev->bus = pci_bus_get(bus);
+ dev->initial_bus_number = bus->number;
dev->driver_exclusive_resource = (struct resource) {
.name = "PCI Exclusive",
.start = 0,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5ffcf5ce8c966..dae68b28ce051 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -363,6 +363,7 @@ struct pci_dev {
struct pci_slot *slot; /* Physical slot this device is in */

unsigned int devfn; /* Encoded device & function index */
+ u8 initial_bus_number; /* Bus number when device was discovered */
unsigned short vendor;
unsigned short device;
unsigned short subsystem_vendor;

--
2.43.0