Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH v8 0/3] Fix VFCT matching after PCI bus renumbering
@ 2026-11-19 19:21 Mario Limonciello
  2026-11-19 19:21 ` [PATCH v8 1/3] PCI: Cache bridge firmware secondary bus number Mario Limonciello
                   ` (2 more replies)
  0 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, Reza Nikzad Chaleshori

amdgpu and radeon pick the VFCT image for a GPU by comparing the PCI bus
number recorded by the BIOS at POST with the device's bus number. When
the kernel renumbers buses (e.g. pci=realloc), the runtime number no
longer matches the one in VFCT.

commit 11c141672045f ("drm/amdgpu: Fix VFCT bus number matching with soft
filter") and its radeon counterpart worked around this by accepting an
entry whenever everything but the bus number matched. That picks the
wrong image when a system has two identical GPUs.

Instead, have the PCI core remember the secondary bus number of each
bridge at FW/OS handoff, and make amdgpu and radeon match the VFCT bus
number against it again, using the upstream bridge of the GPU. The
value is captured in pci_read_bridge_windows(), which only runs when the
bridge is first enumerated, so renumbering and later rescans don't
overwrite it.

Patch 1 adds the cached firmware secondary bus number to struct pci_dev.
Patches 2 and 3 convert amdgpu and radeon to use it and drop the soft
filter.

Link: https://lore.kernel.org/linux-pci/20261015124843.203905-1-mario.limonciello@amd.com/
Link: https://lore.kernel.org/amd-gfx/20261019194106.2796150-1-alexander.deucher@amd.com/
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
Changes in v8:
- PCI: Drop fw_sec_bus_sampled; pci_read_bridge_windows() only runs once
  per bridge, so it was dead code (Lijo, Sashiko).
- PCI: Drop fw_sec_bus_valid and the 0/0xff filtering; record the
  secondary bus number exactly as firmware left it at handoff, since
  0xff is a valid bus and that is the only number firmware knows
  about (Bjorn, Sashiko).
- amdgpu/radeon: Use pci_upstream_bridge() instead of bus->self (Bjorn).
- amdgpu/radeon: Use the cached bridge bus number unconditionally, only
  falling back to the current bus number for devices on a root bus
  (Bjorn).
- amdgpu/radeon: Return bool from *_acpi_vfct_match() instead of
  0/-ENODEV (Bjorn).
- radeon: Drop an unintended re-indent of the match function prototype.
- Link to v7: https://patch.msgid.link/20261112-vfct-regression-v7-0-69b1e0cf45c2@amd.com

Changes in v7:
- Reword the cover letter and the PCI patch to describe the current design:
  the firmware secondary bus number is cached on the bridge pci_dev when its
  bridge windows are first read, and amdgpu/radeon match VFCT against it.
- No code changes.
- Link to v6: https://patch.msgid.link/20261111-vfct-regression-v6-0-393797bbb6e3@amd.com

Changes in v6:
- Capture the firmware secondary bus number when reading bridge windows and
  ignore unconfigured values so rescans cannot replace it with runtime data
  (Sashiko).
- No change needed in the VFCT consumers; they continue to read the cached
  value from the upstream bridge.
- Link to v5: https://patch.msgid.link/20261110-vfct-regression-v5-0-f49fae981bf3@amd.com

Changes in v5:
- Record the firmware secondary bus number only on the bridge struct pci_dev,
  guard it with a validity bit, and keep it across rescans (Bjorn, Lijo).
- Drop pci_bus::number_initial and have amdgpu/radeon read the saved bridge
  number when matching VFCT entries.

Changes in v4:
- Retain secondary bus bus number for a bridge across rescans, and the child bus is initialized
  from it during allocation, before registration callbacks run. (Sashiko)
- Rename variable to clarify it's for bridges (Lijo)
- Link to v3: https://patch.msgid.link/20261026-vfct-regression-v3-0-fe9586ed6978@amd.com

Changes in v3:
- Preserve the firmware bus number across bridge renumbering, capturing the
  secondary bus number before pci_scan_bridge_extend() clears it.
- Adjust member name in all patches
- Add tags
- Link to v2: https://patch.msgid.link/20261020-vfct-regression-v2-0-d2394d11450a@amd.com

Changes in v2:
- pci_alloc_dev(NULL) remains safe.
- For buses behind a reassigned bridge, the PCI core now saves the firmware secondary bus
  number before clearing the bridge configuration and carries it into the newly allocated bus.
  Devices discovered there inherit that original number.
- Add changes for radeon too.
- Link to v1: https://patch.msgid.link/20261019-vfct-regression-v1-0-5a63ddd378dd@amd.com

---
Mario Limonciello (3):
      PCI: Cache bridge firmware secondary bus number
      drm/amdgpu: Match VFCT using initial PCI bus number
      drm/radeon: Match VFCT using initial PCI bus number

 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 42 ++++++++++++--------------------
 drivers/gpu/drm/radeon/radeon_bios.c     | 42 ++++++++++++--------------------
 drivers/pci/probe.c                      |  1 +
 include/linux/pci.h                      |  2 ++
 4 files changed, 33 insertions(+), 54 deletions(-)
---
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
change-id: 20261119-vfct-regression-v8-d767fad2d1f2

Best regards,
--  
Mario Limonciello <mario.limonciello@amd.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [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

* [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

* 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 2/3] drm/amdgpu: Match VFCT using initial PCI bus number
  2026-11-19 19:21 ` [PATCH v8 2/3] drm/amdgpu: Match VFCT using initial PCI " Mario Limonciello
@ 2026-11-19 19:28   ` sashiko-bot
  0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-11-19 19:28 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 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>

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=2


^ 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

end of thread, other threads:[~2026-11-19 20:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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:26   ` sashiko-bot
2026-11-19 19:55   ` Bjorn Helgaas
2026-11-19 20:09   ` Alex Deucher
2026-11-19 19:21 ` [PATCH v8 2/3] drm/amdgpu: Match VFCT using initial PCI " Mario Limonciello
2026-11-19 19:28   ` sashiko-bot
2026-11-19 19:21 ` [PATCH v8 3/3] drm/radeon: " Mario Limonciello
2026-11-19 19:26   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox