Re: [PATCH 1/5] drm/amdgpu: Fix VFCT bus number matching with soft filter

Alex Deucher <[email protected]>
Newsgroups org.freedesktop.lists.amd-gfx
Message-ID <CADnq5_M_soaFDLBsp-kZFf_AB=Q9erXYHaNvHG-YJVgZa9BbXA@mail.gmail.com>
On Thu, Jul 16, 2026 at 9:21 AM Mario Limonciello
<[email protected]> wrote:
>
>
>
> On 7/16/26 07:41, Uwe Kleine-König wrote:
> > Hello,
> >
> > On Wed, Jul 08, 2026 at 02:35:14PM -0500, Mario Limonciello wrote:
> >> On systems where PCI bus renumbering occurs (e.g. pci=realloc,
> >> resource conflicts), the runtime bus number may differ from the
> >> BIOS POST bus number recorded in the VFCT table. This causes
> >> amdgpu_acpi_vfct_bios() to fail finding the VBIOS even though
> >> the correct device entry exists.
> >>
> >> Introduce amdgpu_acpi_vfct_match() which treats the bus number
> >> as a soft filter: vendor/device/function identity is the hard
> >> requirement, while exact bus match is the preferred path. When
> >> bus numbers disagree but device identity matches, accept the
> >> VFCT entry and log a dev_notice for diagnostics.
> >>
> >> Reported-by: Oz Tiram <[email protected]>
> >> Closes: https://lore.kernel.org/amd-gfx/[email protected]/
> >> Signed-off-by: Mario Limonciello <[email protected]>
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 45 +++++++++++++++++++++---
> >>   1 file changed, 40 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> >> index 3ebdd792feec1..d8fd047295d9d 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> >> @@ -377,6 +377,45 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev)
> >>              false : amdgpu_asic_read_disabled_bios(adev);
> >>   }
> >>
> >> +/**
> >> + * amdgpu_acpi_vfct_match() - Check if a VFCT entry matches the device
> >> + * @adev: AMDGPU device
> >> + * @vhdr: VFCT image header to check
> >> + *
> >> + * 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.
> >> + *
> >> + * Returns: 0 on match, -ENODEV on no match
> >> + */
> >> +static int 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;
> >> +}
> >> +
> >>   #ifdef CONFIG_ACPI
> >>   static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
> >>   {
> >> @@ -413,11 +452,7 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
> >>              }
> >>
> >>              if (vhdr->ImageLength &&
> >> -                vhdr->PCIBus == adev->pdev->bus->number &&
> >> -                vhdr->PCIDevice == PCI_SLOT(adev->pdev->devfn) &&
> >> -                vhdr->PCIFunction == PCI_FUNC(adev->pdev->devfn) &&
> >> -                vhdr->VendorID == adev->pdev->vendor &&
> >> -                vhdr->DeviceID == adev->pdev->device) {
> >> +                !amdgpu_acpi_vfct_match(adev, vhdr)) {
> >>                      adev->bios = kmemdup(&vbios->VbiosContent,
> >>                                           vhdr->ImageLength,
> >>                                           GFP_KERNEL);
> >
> > For the record to hopefully make it easier for others to find the fix:
> >
> > This patch became 33a18ecd2fbf in
> >
> >       https://gitlab.freedesktop.org/agd5f/linux.git drm-next
> >
> > and thus next and it introduces a build failure for !CONFIG_ACPI builds:
> >
> >       drivers/gpu/drm/radeon/radeon_bios.c:614:12: error: ‘radeon_acpi_vfct_match’ defined but not used [-Werror=unused-function]
> >         614 | static int radeon_acpi_vfct_match(struct radeon_device *rdev,
> >             |            ^~~~~~~~~~~~~~~~~~~~~~
> >
> > Patch available at https://lore.kernel.org/all/[email protected]/
> >
> > Best regards
> > Uwe
>
> Thanks.  Alex can you squash that in, or has the merge request already
> gone out?

Already out.  I've picked up Uwe's patch.

Alex
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.