Skip to contentSkip to conversation

Revert "drm/amdgpu: Fix VFCT bus number matching with soft filter"

PATCH In review Alex Deucher 3 participants 4 messages Oct 19

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/2 Revert "drm/amdgpu: Fix VFCT bus number matching with soft filter"

This reverts commit 11c141672045ffc0187aa604f2c0f597bc334fb2.

This was added to work around systems where the user specified pci=realloc on the kernel command line. The firmware specifies the BDF to match, but those may not be the same with pci=realloc. This causes mismatches when there are multiple cards of the same type in the system and failure of the cards to initialize. pci=realloc is not the most common case so let's revert for now to fix the regression. We probably need to store the original BDF in the PCI subsystem so we can use it match later if the BDF has changed. This can be properly reinstated once we have a general solution.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 45 +++---------------------
 1 file changed, 5 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +5 -40
index f9315e0472fe9..6bbca70a4e2eb 100644
@@ -428,45 +428,6 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev)
 }
 
 #ifdef CONFIG_ACPI
-/**
- * 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;
-}
-
 static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
 {
 	struct acpi_table_header *hdr;
@@ -503,7 +464,11 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
 		}
 
 		if (vhdr->ImageLength &&
-		    !amdgpu_acpi_vfct_match(adev, vhdr)) {
+		    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) {
 			adev->bios = kmemdup(&vbios->VbiosContent,
 					     vhdr->ImageLength,
 					     GFP_KERNEL);
Signature · 1 line
2.56.0
author maintainer
#1 lore raw

PATCH 2/2 Revert "drm/radeon: Fix VFCT bus number matching with soft filter"

This reverts commit 4059e2f02c8a2a51ba78860775877d721df6a055.

This was added to work around systems where the user specified pci=realloc on the kernel command line. The firmware specifies the BDF to match, but those may not be the same with pci=realloc. This causes mismatches when there are multiple cards of the same type in the system and failure of the cards to initialize. pci=realloc is not the most common case so let's revert for now to fix the regression. We probably need to store the original BDF in the PCI subsystem so we can use it match later if the BDF has changed.

---
 drivers/gpu/drm/radeon/radeon_bios.c | 45 ++++------------------------
 1 file changed, 5 insertions(+), 40 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +5 -40
index 1da6bf1c17ff3..23db87155e778 100644
@@ -601,45 +601,6 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
 }
 
 #ifdef CONFIG_ACPI
-/**
- * radeon_acpi_vfct_match() - Check if a VFCT entry matches the device
- * @rdev: Radeon 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 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;
-}
-
 static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
 {
 	struct acpi_table_header *hdr;
@@ -676,7 +637,11 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
 		}
 
 		if (vhdr->ImageLength &&
-		    !radeon_acpi_vfct_match(rdev, vhdr)) {
+		    vhdr->PCIBus == rdev->pdev->bus->number &&
+		    vhdr->PCIDevice == PCI_SLOT(rdev->pdev->devfn) &&
+		    vhdr->PCIFunction == PCI_FUNC(rdev->pdev->devfn) &&
+		    vhdr->VendorID == rdev->pdev->vendor &&
+		    vhdr->DeviceID == rdev->pdev->device) {
 			rdev->bios = kmemdup(&vbios->VbiosContent,
 					     vhdr->ImageLength,
 					     GFP_KERNEL);
Signature · 1 line
2.56.0
#2 lore raw
In reply to Alex Deucher

+Bjorn
+linux-pci

Quoted 12 lines · Alex Deucher

This reverts commit 11c141672045ffc0187aa604f2c0f597bc334fb2.

This was added to work around systems where the user specified pci=realloc on the kernel command line. The firmware specifies the BDF to match, but those may not be the same with pci=realloc. This causes mismatches when there are multiple cards of the same type in the system and failure of the cards to initialize. pci=realloc is not the most common case so let's revert for now to fix the regression. We probably need to store the original BDF in the PCI subsystem so we can use it match later if the BDF has changed. This can be properly reinstated once we have a general solution.

Quoted 5 lines

---

I hate to trade one regression for another; but arguably pci=realloc is the less common than the case of two identical GPUs.

Bjorn,

You open to storing the original BDF in the device somewhere and letting drivers access it?

That's what I suggested here in response to the other way (let driver detect pci=realloc).

https://lore.kernel.org/linux-pci/[email protected]/

Quoted 66 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 45 +++---------------------
  1 file changed, 5 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +5 -40
index f9315e0472fe9..6bbca70a4e2eb 100644
@@ -428,45 +428,6 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev)
  }
 
  #ifdef CONFIG_ACPI
-/**
- * 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;
-}
-
  static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
  {
  	struct acpi_table_header *hdr;
@@ -503,7 +464,11 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
  		}
 
  		if (vhdr->ImageLength &&
-		    !amdgpu_acpi_vfct_match(adev, vhdr)) {
+		    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) {
  			adev->bios = kmemdup(&vbios->VbiosContent,
  					     vhdr->ImageLength,
  					     GFP_KERNEL);
#3 lore raw
Quoted 22 lines · Mario Limonciello
(quoted diff) +2 -0
+Bjorn
+linux-pci
Quoted 12 lines · Alex Deucher

This reverts commit 11c141672045ffc0187aa604f2c0f597bc334fb2.

This was added to work around systems where the user specified pci=realloc on the kernel command line. The firmware specifies the BDF to match, but those may not be the same with pci=realloc. This causes mismatches when there are multiple cards of the same type in the system and failure of the cards to initialize. pci=realloc is not the most common case so let's revert for now to fix the regression. We probably need to store the original BDF in the PCI subsystem so we can use it match later if the BDF has changed. This can be properly reinstated once we have a general solution.

Quoted 5 lines

---

Quoted 7 lines

I hate to trade one regression for another; but arguably pci=realloc is the less common than the case of two identical GPUs.

Bjorn,

You open to storing the original BDF in the device somewhere and letting drivers access it?

I mentioned in the other thread that saving the original bus number in a struct pci_bus or similar might be practical?

Quoted 69 lines

That's what I suggested here in response to the other way (let driver detect pci=realloc).

https://lore.kernel.org/linux-pci/[email protected]/

Quoted 64 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 45 +++---------------------
  1 file changed, 5 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +5 -40
index f9315e0472fe9..6bbca70a4e2eb 100644
@@ -428,45 +428,6 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev)
  }
  #ifdef CONFIG_ACPI
-/**
- * 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;
-}
-
  static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
  {
  	struct acpi_table_header *hdr;
@@ -503,7 +464,11 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)
  		}
  		if (vhdr->ImageLength &&
-		    !amdgpu_acpi_vfct_match(adev, vhdr)) {
+		    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) {
  			adev->bios = kmemdup(&vbios->VbiosContent,
  					     vhdr->ImageLength,
  					     GFP_KERNEL);