* [PATCH v3 1/3] PCI: Preserve the initial bus number in pci_bus
2026-10-26 15:48 [PATCH v3 0/3] Fix amdgpu detection of pci=realloc Mario Limonciello
@ 2026-10-26 15:48 ` Mario Limonciello
2026-10-26 15:48 ` [PATCH v3 2/3] drm/amdgpu: Match VFCT using initial PCI bus number Mario Limonciello
2026-10-26 15:48 ` [PATCH v3 3/3] drm/radeon: " Mario Limonciello
2 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2026-10-26 15:48 UTC (permalink / raw)
To: Bjorn Helgaas, Alex Deucher, Christian König
Cc: Oz Tiram, linux-pci, linux-kernel, amd-gfx, dri-devel, Mario Limonciello
Bridges that need bus reassignment are scanned in two passes. Save
the firmware secondary bus number during the first pass, before the
bridge is disabled, and carry it to the bus created in the second
pass. Drivers can then match firmware records against the bus number
from before PCI bus renumbering.
The initial number belongs to the bus, so consumers can use the
pci_bus value directly without copying it into every pci_dev.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pci/probe.c | 9 +++++++++
include/linux/pci.h | 2 ++
2 files changed, 11 insertions(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27008e2ea5afc..9950a9dd1db1f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1012,6 +1012,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
bus->sysdata = bridge->sysdata;
bus->ops = bridge->ops;
bus->number = bus->busn_res.start = bridge->busnr;
+ bus->number_initial = bus->number;
#ifdef CONFIG_PCI_DOMAINS_GENERIC
if (bridge->domain_nr == PCI_DOMAIN_NR_NOT_SET)
bus->domain_nr = pci_bus_find_domain_nr(bus, parent);
@@ -1232,6 +1233,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
/* Set up the primary, secondary and subordinate bus numbers */
child->number = child->busn_res.start = busnr;
+ child->number_initial = busnr;
child->primary = parent->busn_res.start;
child->busn_res.end = 0xff;
@@ -1470,6 +1472,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
child = pci_add_new_bus(bus, dev, secondary);
if (!child)
goto out;
+ child->number_initial = secondary;
child->primary = primary;
pci_bus_insert_busn_res(child, secondary, subordinate);
child->bridge_ctl = bctl;
@@ -1491,6 +1494,8 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
* do in the second pass.
*/
if (!pass) {
+ if (!dev->secondary_busnr)
+ dev->secondary_busnr = secondary;
if (pcibios_assign_all_busses() || broken)
/*
@@ -1529,6 +1534,10 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
pci_bus_insert_busn_res(child, next_busnr,
bus->busn_res.end);
}
+ if (dev->secondary_busnr) {
+ child->number_initial = dev->secondary_busnr;
+ dev->secondary_busnr = 0;
+ }
max++;
if (available_buses)
available_buses--;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5ffcf5ce8c966..75a5fd2374acb 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 secondary_busnr; /* Original secondary bus number */
unsigned short vendor;
unsigned short device;
unsigned short subsystem_vendor;
@@ -724,6 +725,7 @@ struct pci_bus {
struct proc_dir_entry *procdir; /* Directory entry in /proc/bus/pci */
unsigned char number; /* Bus number */
+ unsigned char number_initial; /* Bus number before reassignment */
unsigned char primary; /* Number of primary bridge */
unsigned char max_bus_speed; /* enum pci_bus_speed */
unsigned char cur_bus_speed; /* enum pci_bus_speed */
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 2/3] drm/amdgpu: Match VFCT using initial PCI bus number
2026-10-26 15:48 [PATCH v3 0/3] Fix amdgpu detection of pci=realloc Mario Limonciello
2026-10-26 15:48 ` [PATCH v3 1/3] PCI: Preserve the initial bus number in pci_bus Mario Limonciello
@ 2026-10-26 15:48 ` Mario Limonciello
2026-10-26 15:51 ` Mario Limonciello
2026-10-26 15:48 ` [PATCH v3 3/3] drm/radeon: " Mario Limonciello
2 siblings, 1 reply; 6+ messages in thread
From: Mario Limonciello @ 2026-10-26 15:48 UTC (permalink / raw)
To: Bjorn Helgaas, Alex Deucher, Christian König
Cc: Oz Tiram, linux-pci, linux-kernel, amd-gfx, dri-devel,
Mario Limonciello, Reza Nikzad Chaleshori
VFCT records the PCI bus number from BIOS POST. The current bus number
can change after PCI core renumbers the bus, while accepting a mismatch
based only on device identity can select the wrong VFCT image when
matching devices are present. Compare against the bus number captured
from the firmware bus assignment before bridge renumbering.
Reported-by: Reza Nikzad Chaleshori <rezanikzadch@gmail.com>
Closes: https://lore.kernel.org/amd-gfx/20261014080523.186533-1-rezanikzadch@gmail.com/
Fixes: 11c141672045f ("drm/amdgpu: Fix VFCT bus number matching with soft filter")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
index 08ed1eb695586..051be1905e296 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
@@ -386,10 +386,8 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev)
* VFCT entries contain the PCI bus number as recorded during BIOS POST.
* On systems where the kernel renumbers PCI buses (e.g. pci=realloc or
* resource conflicts), the runtime bus number may differ from the POST
- * value. Match by device identity (vendor + device + function) and use
- * the bus number as a preference: exact bus match is preferred, but when
- * the bus numbers disagree we accept the entry if the device identity
- * matches.
+ * value. Match using the bus number captured when the device was
+ * discovered, before any bus renumbering.
*
* Returns: 0 on match, -ENODEV on no match
*/
@@ -405,16 +403,7 @@ static int amdgpu_acpi_vfct_match(struct amdgpu_device *adev,
vhdr->PCIFunction != PCI_FUNC(adev->pdev->devfn))
return -ENODEV;
- /* Exact bus number match - preferred */
- if (vhdr->PCIBus == adev->pdev->bus->number)
- return 0;
-
- /* Bus mismatch but device identity matches (PCI renumbering case) */
- dev_notice(adev->dev,
- "VFCT bus number mismatch: table %u != runtime %u, matching by device identity (vendor 0x%04x device 0x%04x)\n",
- vhdr->PCIBus, adev->pdev->bus->number,
- adev->pdev->vendor, adev->pdev->device);
- return 0;
+ return vhdr->PCIBus == adev->pdev->bus->number_initial ? 0 : -ENODEV;
}
static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3 2/3] drm/amdgpu: Match VFCT using initial PCI bus number
2026-10-26 15:48 ` [PATCH v3 2/3] drm/amdgpu: Match VFCT using initial PCI bus number Mario Limonciello
@ 2026-10-26 15:51 ` Mario Limonciello
0 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2026-10-26 15:51 UTC (permalink / raw)
To: Bjorn Helgaas, Alex Deucher, Christian König
Cc: Oz Tiram, linux-pci, linux-kernel, amd-gfx, dri-devel,
Reza Nikzad Chaleshori
On 10/26/26 10:48, Mario Limonciello wrote:
> VFCT records the PCI bus number from BIOS POST. The current bus number
> can change after PCI core renumbers the bus, while accepting a mismatch
> based only on device identity can select the wrong VFCT image when
> matching devices are present. Compare against the bus number captured
> from the firmware bus assignment before bridge renumbering.
>
> Reported-by: Reza Nikzad Chaleshori <rezanikzadch@gmail.com>
> Closes: https://lore.kernel.org/amd-gfx/20261014080523.186533-1-rezanikzadch@gmail.com/
> Fixes: 11c141672045f ("drm/amdgpu: Fix VFCT bus number matching with soft filter")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Accidentally lost Alex's tag when I rebased.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 17 +++--------------
> 1 file changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> index 08ed1eb695586..051be1905e296 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> @@ -386,10 +386,8 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev)
> * VFCT entries contain the PCI bus number as recorded during BIOS POST.
> * On systems where the kernel renumbers PCI buses (e.g. pci=realloc or
> * resource conflicts), the runtime bus number may differ from the POST
> - * value. Match by device identity (vendor + device + function) and use
> - * the bus number as a preference: exact bus match is preferred, but when
> - * the bus numbers disagree we accept the entry if the device identity
> - * matches.
> + * value. Match using the bus number captured when the device was
> + * discovered, before any bus renumbering.
> *
> * Returns: 0 on match, -ENODEV on no match
> */
> @@ -405,16 +403,7 @@ static int amdgpu_acpi_vfct_match(struct amdgpu_device *adev,
> vhdr->PCIFunction != PCI_FUNC(adev->pdev->devfn))
> return -ENODEV;
>
> - /* Exact bus number match - preferred */
> - if (vhdr->PCIBus == adev->pdev->bus->number)
> - return 0;
> -
> - /* Bus mismatch but device identity matches (PCI renumbering case) */
> - dev_notice(adev->dev,
> - "VFCT bus number mismatch: table %u != runtime %u, matching by device identity (vendor 0x%04x device 0x%04x)\n",
> - vhdr->PCIBus, adev->pdev->bus->number,
> - adev->pdev->vendor, adev->pdev->device);
> - return 0;
> + return vhdr->PCIBus == adev->pdev->bus->number_initial ? 0 : -ENODEV;
> }
>
> static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] drm/radeon: Match VFCT using initial PCI bus number
2026-10-26 15:48 [PATCH v3 0/3] Fix amdgpu detection of pci=realloc Mario Limonciello
2026-10-26 15:48 ` [PATCH v3 1/3] PCI: Preserve the initial bus number in pci_bus Mario Limonciello
2026-10-26 15:48 ` [PATCH v3 2/3] drm/amdgpu: Match VFCT using initial PCI bus number Mario Limonciello
@ 2026-10-26 15:48 ` Mario Limonciello
2026-10-26 15:51 ` Mario Limonciello
2 siblings, 1 reply; 6+ messages in thread
From: Mario Limonciello @ 2026-10-26 15:48 UTC (permalink / raw)
To: Bjorn Helgaas, Alex Deucher, Christian König
Cc: Oz Tiram, linux-pci, linux-kernel, amd-gfx, dri-devel, Mario Limonciello
VFCT records the PCI bus number from BIOS POST. The current bus number
can change after PCI core renumbers the bus, while accepting a mismatch
based only on device identity can select the wrong VFCT image when
matching devices are present. Compare against the bus number captured
from the firmware bus assignment before bridge renumbering.
Fixes: 4059e2f02c8a ("drm/radeon: Fix VFCT bus number matching with soft filter")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/gpu/drm/radeon/radeon_bios.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 1da6bf1c17ff3..bdbca4fad6b8c 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -609,10 +609,8 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
* VFCT entries contain the PCI bus number as recorded during BIOS POST.
* On systems where the kernel renumbers PCI buses (e.g. pci=realloc or
* resource conflicts), the runtime bus number may differ from the POST
- * value. Match by device identity (vendor + device + function) and use
- * the bus number as a preference: exact bus match is preferred, but when
- * the bus numbers disagree we accept the entry if the device identity
- * matches.
+ * value. Match using the bus number captured when the device was
+ * discovered, before any bus renumbering.
*
* Returns: 0 on match, -ENODEV on no match
*/
@@ -628,16 +626,7 @@ static int radeon_acpi_vfct_match(struct radeon_device *rdev,
vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn))
return -ENODEV;
- /* Exact bus number match - preferred */
- if (vhdr->PCIBus == rdev->pdev->bus->number)
- return 0;
-
- /* Bus mismatch but device identity matches (PCI renumbering case) */
- dev_notice(&rdev->pdev->dev,
- "VFCT bus number mismatch: table %u != runtime %u, matching by device identity (vendor 0x%04x device 0x%04x)\n",
- vhdr->PCIBus, rdev->pdev->bus->number,
- rdev->pdev->vendor, rdev->pdev->device);
- return 0;
+ return vhdr->PCIBus == rdev->pdev->bus->number_initial ? 0 : -ENODEV;
}
static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3 3/3] drm/radeon: Match VFCT using initial PCI bus number
2026-10-26 15:48 ` [PATCH v3 3/3] drm/radeon: " Mario Limonciello
@ 2026-10-26 15:51 ` Mario Limonciello
0 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2026-10-26 15:51 UTC (permalink / raw)
To: Bjorn Helgaas, Alex Deucher, Christian König
Cc: Oz Tiram, linux-pci, linux-kernel, amd-gfx, dri-devel
On 10/26/26 10:48, Mario Limonciello wrote:
> VFCT records the PCI bus number from BIOS POST. The current bus number
> can change after PCI core renumbers the bus, while accepting a mismatch
> based only on device identity can select the wrong VFCT image when
> matching devices are present. Compare against the bus number captured
> from the firmware bus assignment before bridge renumbering.
>
> Fixes: 4059e2f02c8a ("drm/radeon: Fix VFCT bus number matching with soft filter")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Lost alex's tag on the rebase.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_bios.c | 17 +++--------------
> 1 file changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
> index 1da6bf1c17ff3..bdbca4fad6b8c 100644
> --- a/drivers/gpu/drm/radeon/radeon_bios.c
> +++ b/drivers/gpu/drm/radeon/radeon_bios.c
> @@ -609,10 +609,8 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
> * VFCT entries contain the PCI bus number as recorded during BIOS POST.
> * On systems where the kernel renumbers PCI buses (e.g. pci=realloc or
> * resource conflicts), the runtime bus number may differ from the POST
> - * value. Match by device identity (vendor + device + function) and use
> - * the bus number as a preference: exact bus match is preferred, but when
> - * the bus numbers disagree we accept the entry if the device identity
> - * matches.
> + * value. Match using the bus number captured when the device was
> + * discovered, before any bus renumbering.
> *
> * Returns: 0 on match, -ENODEV on no match
> */
> @@ -628,16 +626,7 @@ static int radeon_acpi_vfct_match(struct radeon_device *rdev,
> vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn))
> return -ENODEV;
>
> - /* Exact bus number match - preferred */
> - if (vhdr->PCIBus == rdev->pdev->bus->number)
> - return 0;
> -
> - /* Bus mismatch but device identity matches (PCI renumbering case) */
> - dev_notice(&rdev->pdev->dev,
> - "VFCT bus number mismatch: table %u != runtime %u, matching by device identity (vendor 0x%04x device 0x%04x)\n",
> - vhdr->PCIBus, rdev->pdev->bus->number,
> - rdev->pdev->vendor, rdev->pdev->device);
> - return 0;
> + return vhdr->PCIBus == rdev->pdev->bus->number_initial ? 0 : -ENODEV;
> }
>
> static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
>
^ permalink raw reply [flat|nested] 6+ messages in thread