* [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number
2026-11-19 19:21 [PATCH v8 0/3] Fix VFCT matching after PCI bus renumbering Mario Limonciello
@ 2026-11-19 19:21 ` Mario Limonciello
2026-11-19 19:26 ` sashiko-bot
` (2 more replies)
2026-11-19 19:21 ` [PATCH v8 2/3] drm/amdgpu: Match VFCT using initial PCI " Mario Limonciello
2026-11-19 19:21 ` [PATCH v8 3/3] drm/radeon: " Mario Limonciello
2 siblings, 3 replies; 9+ messages in thread
From: Mario Limonciello @ 2026-11-19 19:21 UTC (permalink / raw)
To: Bjorn Helgaas, Alex Deucher
Cc: Christian König, Lijo Lazar, linux-pci, amd-gfx,
Mario Limonciello
Drivers such as amdgpu and radeon need the bus number firmware assigned
to a device to match it against firmware tables like VFCT. The PCI core
may renumber buses (e.g. with pci=realloc), after which the runtime
number no longer reflects what firmware programmed.
Record the bridge's secondary bus number in its struct pci_dev when
pci_read_bridge_windows() reads the bus number register. This happens
once, when the bridge is first enumerated and before any renumbering,
so the value is what firmware left at FW/OS handoff. Devices behind the
bridge can then retrieve their firmware bus number via their upstream
bridge.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pci/probe.c | 1 +
include/linux/pci.h | 2 ++
2 files changed, 3 insertions(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 9a178e0e5f7f4..89a7c52ac3e5b 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -513,6 +513,7 @@ static void pci_read_bridge_windows(struct pci_dev *bridge)
res.flags = IORESOURCE_BUS;
res.start = FIELD_GET(PCI_SECONDARY_BUS_MASK, buses);
res.end = FIELD_GET(PCI_SUBORDINATE_BUS_MASK, buses);
+ bridge->fw_sec_busnr = res.start;
pci_info(bridge, "PCI bridge to %pR%s\n", &res,
bridge->transparent ? " (subtractive decode)" : "");
diff --git a/include/linux/pci.h b/include/linux/pci.h
index aa3765a20a96c..4c1b1e557a607 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -363,6 +363,8 @@ struct pci_dev {
struct pci_slot *slot; /* Physical slot this device is in */
unsigned int devfn; /* Encoded device & function index */
+ /* Bridge secondary bus number at FW/OS handoff */
+ unsigned char fw_sec_busnr;
unsigned short vendor;
unsigned short device;
unsigned short subsystem_vendor;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number
2026-11-19 19:21 ` [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number Mario Limonciello
@ 2026-11-19 19:26 ` sashiko-bot
2026-11-19 19:55 ` Bjorn Helgaas
2026-11-19 20:09 ` Alex Deucher
2 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-11-19 19:26 UTC (permalink / raw)
To: Mario Limonciello; +Cc: linux-pci
> Drivers such as amdgpu and radeon need the bus number firmware assigned
> to a device to match it against firmware tables like VFCT. The PCI core
> may renumber buses (e.g. with pci=realloc), after which the runtime
> number no longer reflects what firmware programmed.
>
> Record the bridge's secondary bus number in its struct pci_dev when
> pci_read_bridge_windows() reads the bus number register. This happens
> once, when the bridge is first enumerated and before any renumbering,
> so the value is what firmware left at FW/OS handoff. Devices behind the
> bridge can then retrieve their firmware bus number via their upstream
> bridge.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-vfct-regression-v8-v8-0-12463194e457@amd.com?part=1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number
2026-11-19 19:21 ` [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number Mario Limonciello
2026-11-19 19:26 ` sashiko-bot
@ 2026-11-19 19:55 ` Bjorn Helgaas
2026-11-19 20:09 ` Alex Deucher
2 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2026-11-19 19:55 UTC (permalink / raw)
To: Mario Limonciello
Cc: Bjorn Helgaas, Alex Deucher, Christian König, Lijo Lazar,
linux-pci, amd-gfx
On Thu, Nov 19, 2026 at 01:21:19PM -0600, Mario Limonciello wrote:
> Drivers such as amdgpu and radeon need the bus number firmware assigned
> to a device to match it against firmware tables like VFCT. The PCI core
> may renumber buses (e.g. with pci=realloc), after which the runtime
> number no longer reflects what firmware programmed.
>
> Record the bridge's secondary bus number in its struct pci_dev when
> pci_read_bridge_windows() reads the bus number register. This happens
> once, when the bridge is first enumerated and before any renumbering,
> so the value is what firmware left at FW/OS handoff. Devices behind the
> bridge can then retrieve their firmware bus number via their upstream
> bridge.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
I assume you'll merge via DRM?
> ---
> drivers/pci/probe.c | 1 +
> include/linux/pci.h | 2 ++
> 2 files changed, 3 insertions(+)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 9a178e0e5f7f4..89a7c52ac3e5b 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -513,6 +513,7 @@ static void pci_read_bridge_windows(struct pci_dev *bridge)
> res.flags = IORESOURCE_BUS;
> res.start = FIELD_GET(PCI_SECONDARY_BUS_MASK, buses);
> res.end = FIELD_GET(PCI_SUBORDINATE_BUS_MASK, buses);
> + bridge->fw_sec_busnr = res.start;
> pci_info(bridge, "PCI bridge to %pR%s\n", &res,
> bridge->transparent ? " (subtractive decode)" : "");
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index aa3765a20a96c..4c1b1e557a607 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -363,6 +363,8 @@ struct pci_dev {
> struct pci_slot *slot; /* Physical slot this device is in */
>
> unsigned int devfn; /* Encoded device & function index */
> + /* Bridge secondary bus number at FW/OS handoff */
> + unsigned char fw_sec_busnr;
> unsigned short vendor;
> unsigned short device;
> unsigned short subsystem_vendor;
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number
2026-11-19 19:21 ` [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number Mario Limonciello
2026-11-19 19:26 ` sashiko-bot
2026-11-19 19:55 ` Bjorn Helgaas
@ 2026-11-19 20:09 ` Alex Deucher
2 siblings, 0 replies; 9+ messages in thread
From: Alex Deucher @ 2026-11-19 20:09 UTC (permalink / raw)
To: Mario Limonciello
Cc: Bjorn Helgaas, Alex Deucher, Christian König, Lijo Lazar,
linux-pci, amd-gfx
On Thu, Nov 19, 2026 at 2:46 PM Mario Limonciello
<mario.limonciello@amd.com> wrote:
>
> Drivers such as amdgpu and radeon need the bus number firmware assigned
> to a device to match it against firmware tables like VFCT. The PCI core
> may renumber buses (e.g. with pci=realloc), after which the runtime
> number no longer reflects what firmware programmed.
>
> Record the bridge's secondary bus number in its struct pci_dev when
> pci_read_bridge_windows() reads the bus number register. This happens
> once, when the bridge is first enumerated and before any renumbering,
> so the value is what firmware left at FW/OS handoff. Devices behind the
> bridge can then retrieve their firmware bus number via their upstream
> bridge.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Series is:
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/pci/probe.c | 1 +
> include/linux/pci.h | 2 ++
> 2 files changed, 3 insertions(+)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 9a178e0e5f7f4..89a7c52ac3e5b 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -513,6 +513,7 @@ static void pci_read_bridge_windows(struct pci_dev *bridge)
> res.flags = IORESOURCE_BUS;
> res.start = FIELD_GET(PCI_SECONDARY_BUS_MASK, buses);
> res.end = FIELD_GET(PCI_SUBORDINATE_BUS_MASK, buses);
> + bridge->fw_sec_busnr = res.start;
> pci_info(bridge, "PCI bridge to %pR%s\n", &res,
> bridge->transparent ? " (subtractive decode)" : "");
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index aa3765a20a96c..4c1b1e557a607 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -363,6 +363,8 @@ struct pci_dev {
> struct pci_slot *slot; /* Physical slot this device is in */
>
> unsigned int devfn; /* Encoded device & function index */
> + /* Bridge secondary bus number at FW/OS handoff */
> + unsigned char fw_sec_busnr;
> unsigned short vendor;
> unsigned short device;
> unsigned short subsystem_vendor;
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v8 2/3] drm/amdgpu: Match VFCT using initial PCI bus number
2026-11-19 19:21 [PATCH v8 0/3] Fix VFCT matching after PCI bus renumbering Mario Limonciello
2026-11-19 19:21 ` [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number Mario Limonciello
@ 2026-11-19 19:21 ` Mario Limonciello
2026-11-19 19:28 ` sashiko-bot
2026-11-19 19:21 ` [PATCH v8 3/3] drm/radeon: " Mario Limonciello
2 siblings, 1 reply; 9+ messages in thread
From: Mario Limonciello @ 2026-11-19 19:21 UTC (permalink / raw)
To: Bjorn Helgaas, Alex Deucher
Cc: Christian König, Lijo Lazar, linux-pci, amd-gfx,
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 secondary bus number of the upstream bridge at
FW/OS handoff, which the PCI core caches before any renumbering. Fall
back to the current bus number for devices on a root bus, which is
never renumbered.
While here, return a bool from amdgpu_acpi_vfct_match() so callers
read naturally.
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 | 42 ++++++++++++--------------------
1 file changed, 15 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
index f9315e0472fe9..ec5509e36f848 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
@@ -436,35 +436,23 @@ 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 against the secondary bus number of the upstream bridge
+ * at FW/OS handoff, which the PCI core caches before any renumbering.
*
- * Returns: 0 on match, -ENODEV on no match
+ * Returns: true if @vhdr describes this device, false otherwise
*/
-static int amdgpu_acpi_vfct_match(struct amdgpu_device *adev,
- VFCT_IMAGE_HEADER *vhdr)
+static bool amdgpu_acpi_vfct_match(struct amdgpu_device *adev,
+ VFCT_IMAGE_HEADER *vhdr)
{
- /* Vendor and device IDs must always match */
- if (vhdr->VendorID != adev->pdev->vendor ||
- vhdr->DeviceID != adev->pdev->device)
- return -ENODEV;
-
- if (vhdr->PCIDevice != PCI_SLOT(adev->pdev->devfn) ||
- 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;
+ struct pci_dev *pdev = adev->pdev;
+ struct pci_dev *bridge = pci_upstream_bridge(pdev);
+ u8 bus = bridge ? bridge->fw_sec_busnr : pdev->bus->number;
+
+ return vhdr->VendorID == pdev->vendor &&
+ vhdr->DeviceID == pdev->device &&
+ vhdr->PCIBus == bus &&
+ vhdr->PCIDevice == PCI_SLOT(pdev->devfn) &&
+ vhdr->PCIFunction == PCI_FUNC(pdev->devfn);
}
static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
@@ -503,7 +491,7 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
}
if (vhdr->ImageLength &&
- !amdgpu_acpi_vfct_match(adev, vhdr)) {
+ amdgpu_acpi_vfct_match(adev, vhdr)) {
adev->bios = kmemdup(&vbios->VbiosContent,
vhdr->ImageLength,
GFP_KERNEL);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v8 3/3] drm/radeon: Match VFCT using initial PCI bus number
2026-11-19 19:21 [PATCH v8 0/3] Fix VFCT matching after PCI bus renumbering Mario Limonciello
2026-11-19 19:21 ` [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number Mario Limonciello
2026-11-19 19:21 ` [PATCH v8 2/3] drm/amdgpu: Match VFCT using initial PCI " Mario Limonciello
@ 2026-11-19 19:21 ` Mario Limonciello
2026-11-19 19:26 ` sashiko-bot
2 siblings, 1 reply; 9+ messages in thread
From: Mario Limonciello @ 2026-11-19 19:21 UTC (permalink / raw)
To: Bjorn Helgaas, Alex Deucher
Cc: Christian König, Lijo Lazar, linux-pci, amd-gfx,
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 secondary bus number of the upstream bridge at
FW/OS handoff, which the PCI core caches before any renumbering. Fall
back to the current bus number for devices on a root bus, which is
never renumbered.
While here, return a bool from radeon_acpi_vfct_match() so callers
read naturally.
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 | 42 +++++++++++++-----------------------
1 file changed, 15 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 1da6bf1c17ff3..869240588eb31 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -609,35 +609,23 @@ 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 against the secondary bus number of the upstream bridge
+ * at FW/OS handoff, which the PCI core caches before any renumbering.
*
- * Returns: 0 on match, -ENODEV on no match
+ * Returns: true if @vhdr describes this device, false otherwise
*/
-static int radeon_acpi_vfct_match(struct radeon_device *rdev,
- VFCT_IMAGE_HEADER *vhdr)
+static bool radeon_acpi_vfct_match(struct radeon_device *rdev,
+ VFCT_IMAGE_HEADER *vhdr)
{
- /* Vendor and device IDs must always match */
- if (vhdr->VendorID != rdev->pdev->vendor ||
- vhdr->DeviceID != rdev->pdev->device)
- return -ENODEV;
-
- if (vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
- 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;
+ struct pci_dev *pdev = rdev->pdev;
+ struct pci_dev *bridge = pci_upstream_bridge(pdev);
+ u8 bus = bridge ? bridge->fw_sec_busnr : pdev->bus->number;
+
+ return vhdr->VendorID == pdev->vendor &&
+ vhdr->DeviceID == pdev->device &&
+ vhdr->PCIBus == bus &&
+ vhdr->PCIDevice == PCI_SLOT(pdev->devfn) &&
+ vhdr->PCIFunction == PCI_FUNC(pdev->devfn);
}
static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
@@ -676,7 +664,7 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
}
if (vhdr->ImageLength &&
- !radeon_acpi_vfct_match(rdev, vhdr)) {
+ radeon_acpi_vfct_match(rdev, vhdr)) {
rdev->bios = kmemdup(&vbios->VbiosContent,
vhdr->ImageLength,
GFP_KERNEL);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v8 3/3] drm/radeon: Match VFCT using initial PCI bus number
2026-11-19 19:21 ` [PATCH v8 3/3] drm/radeon: " Mario Limonciello
@ 2026-11-19 19:26 ` sashiko-bot
0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-11-19 19:26 UTC (permalink / raw)
To: Mario Limonciello; +Cc: linux-pci
> 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 secondary bus number of the upstream bridge at
> FW/OS handoff, which the PCI core caches before any renumbering. Fall
> back to the current bus number for devices on a root bus, which is
> never renumbered.
>
> While here, return a bool from radeon_acpi_vfct_match() so callers
> read naturally.
>
> Fixes: 4059e2f02c8a ("drm/radeon: Fix VFCT bus number matching with soft filter")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-vfct-regression-v8-v8-0-12463194e457@amd.com?part=3
^ permalink raw reply [flat|nested] 9+ messages in thread