Re: [PATCH v7 2/3] drm/amdgpu: Match VFCT using initial PCI bus number
From: Bjorn Helgaas
Date: Thu Nov 19 2026 - 11:54:05 EST
[+cc Lijo]
On Thu, Nov 12, 2026 at 03:54:54PM -0600, 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@xxxxxxxxx>
> Closes: https://lore.kernel.org/amd-gfx/20261014080523.186533-1-rezanikzadch@xxxxxxxxx/
> Fixes: 11c141672045f ("drm/amdgpu: Fix VFCT bus number matching with soft filter")
> Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 23 ++++++++++-------------
> 1 file changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> index 08ed1eb695586..0ee4c6462c4d0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> @@ -386,16 +386,17 @@ 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
> */
> static int amdgpu_acpi_vfct_match(struct amdgpu_device *adev,
> VFCT_IMAGE_HEADER *vhdr)
> {
> + struct pci_dev *bridge = adev->pdev->bus->self;
pci_upstream_bridge() does this and handles the case where pdev is an
SR-IOV VF (that case probably never applies here, but we can still
avoid that assumption).
> + unsigned char initial_bus;
> +
> /* Vendor and device IDs must always match */
> if (vhdr->VendorID != adev->pdev->vendor ||
> vhdr->DeviceID != adev->pdev->device)
> @@ -405,16 +406,12 @@ 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;
> + if (bridge && bridge->fw_sec_bus_valid)
> + initial_bus = bridge->fw_sec_busnr;
> + else
> + initial_bus = adev->pdev->bus->number;
Why can't we use bridge->fw_sec_busnr unconditionally? The bus number
at FW/OS handoff is the only bus number firmware could possibly know
about.
It seems like this should just be:
if (vhdr->PCIBus == bridge->fw_sec_busnr &&
vhdr->PCIDevice == PCI_SLOT(adev->pdev->devfn) &&
vhdr->PCIFunction == PCI_FUNC(adev->pdev->devfn))
return 0; /* match */
return -ENODEV; /* no match */
It seems like the bus/device/function match should be solid by itself,
so I don't know why you need to check Vendor/Device IDs (but I don't
object if you do).
Maybe this boolean style is typical in DRM, and it does match the
strcmp() style, but it seems weird to me to write
if (!amdgpu_acpi_vfct_match(...))
/* do the matching case */
> - /* 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 == initial_bus ? 0 : -ENODEV;
> }
>
> static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
>
> --
> 2.43.0
>