Fix amdgpu detection of pci=realloc
Subsystems (3)
v3 cover Fix amdgpu detection of pci=realloc
amdgpu needs to know the bus number the platform assigned a device to be able to match firmware images against the right device.
This was previously adjusted to be a soft filter due to
commit 11c141672045f ("drm/amdgpu: Fix VFCT bus number matching with soft filter") where if everything but the number matched to take a device.
This however fails when there are two identical devices. Instead save the initial bus number to the PCI device structure and then match that.
---
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/[email protected]
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/[email protected]
---
Mario Limonciello (3):
PCI: Preserve the initial bus number in pci_bus 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 | 17 +++-------------- drivers/gpu/drm/radeon/radeon_bios.c | 17 +++-------------- drivers/pci/probe.c | 9 +++++++++ include/linux/pci.h | 2 ++ 4 files changed, 17 insertions(+), 28 deletions(-)
---
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
change-id: 20261019-vfct-regression-2142fc52852a
Best regards,
Signature · 1 line
Mario Limonciello <[email protected]>
PATCH v3 1/3 PCI: Preserve the initial bus number in pci_bus
Bridges that need bus reassignment are scanned in two passes. Save the firmware secondary bus number during the first pass, before the bridge is disabled, and carry it to the bus created in the second pass. Drivers can then match firmware records against the bus number from before PCI bus renumbering.
The initial number belongs to the bus, so consumers can use the pci_bus value directly without copying it into every pci_dev.
--- drivers/pci/probe.c | 9 +++++++++ include/linux/pci.h | 2 ++ 2 files changed, 11 insertions(+)
drivers/pci/probe.c +9 -0
@@ -1012,6 +1012,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) bus->sysdata = bridge->sysdata; bus->ops = bridge->ops; bus->number = bus->busn_res.start = bridge->busnr; + bus->number_initial = bus->number;#ifdef CONFIG_PCI_DOMAINS_GENERIC if (bridge->domain_nr ==PCI_DOMAIN_NR_NOT_SET ) bus->domain_nr =pci_bus_find_domain_nr (bus, parent);
@@ -1232,6 +1233,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,/* Set up the primary, secondary and subordinate bus numbers */ child->number = child->busn_res.start = busnr; + child->number_initial = busnr; child->primary = parent->busn_res.start; child->busn_res.end =0xff ;
@@ -1470,6 +1472,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, child =pci_add_new_bus (bus, dev, secondary);if (!child) goto out; + child->number_initial = secondary; child->primary = primary;pci_bus_insert_busn_res (child, secondary, subordinate); child->bridge_ctl = bctl;
@@ -1491,6 +1494,8 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,* do in the second pass. */ if (!pass) { +if (!dev->secondary_busnr) + dev->secondary_busnr = secondary;if (pcibios_assign_all_busses () || broken)/*
@@ -1529,6 +1534,10 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,pci_bus_insert_busn_res (child, next_busnr, bus->busn_res.end); } +if (dev->secondary_busnr) { + child->number_initial = dev->secondary_busnr; + dev->secondary_busnr =0 ; + } max++;if (available_buses) available_buses--;
include/linux/pci.h +2 -0
@@ -363,6 +363,7 @@ struct pci_dev {struct pci_slot *slot;/* Physical slot this device is in */ unsigned int devfn;/* Encoded device & function index */ +u8 secondary_busnr;/* Original secondary bus number */ unsigned short vendor;unsigned short device;unsigned short subsystem_vendor;
@@ -724,6 +725,7 @@ struct pci_bus {struct proc_dir_entry *procdir;/* Directory entry in /proc/bus/pci */ unsigned char number;/* Bus number */ +unsigned char number_initial;/* Bus number before reassignment */ unsigned char primary;/* Number of primary bridge */ unsigned char max_bus_speed;/* enum pci_bus_speed */ unsigned char cur_bus_speed;/* enum pci_bus_speed */
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 1/3] PCI: Preserve the initial bus number in pci_bus
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] PCI: number_initial clobbered on bus rescan in pci_scan_bridge_extend() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] PCI: number_initial clobbered on bus rescan in pci_scan_bridge_extend() --
commit 66abeabff58a043b28934ad23308d764456e9fa4
Author: Mario Limonciello <[email protected]>
PCI: Preserve the initial bus number in pci_bus
This commit saves the firmware-assigned secondary bus number before PCI bus renumbering and stores it in pci_bus->number_initial so drivers can match firmware records against the initial bus number.
Quoted 4 lines
drivers/pci/probe.c +0
-0
[ ... ]
Quoted 26 lines
drivers/pci/probe.c +4
-0@@ -1232,6 +1233,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,/* Set up the primary, secondary and subordinate bus numbers */ child->number = child->busn_res.start = busnr; + child->number_initial = busnr; child->primary = parent->busn_res.start; child->busn_res.end =0xff ;@@ -1470,6 +1472,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, child =pci_add_new_bus (bus, dev, secondary);if (!child) goto out; + child->number_initial = secondary; child->primary = primary;pci_bus_insert_busn_res (child, secondary, subordinate); child->bridge_ctl = bctl;@@ -1491,6 +1494,8 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,* do in the second pass. */ if (!pass) { +if (!dev->secondary_busnr) + dev->secondary_busnr = secondary;if (pcibios_assign_all_busses () || broken)/*
drivers/pci/probe.c static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, · line 1540
Quoted 7 lines
drivers/pci/probe.c +4
-0@@ -1529,6 +1534,10 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,pci_bus_insert_busn_res (child, next_busnr, bus->busn_res.end); } +if (dev->secondary_busnr) { + child->number_initial = dev->secondary_busnr; + dev->secondary_busnr =0 ; + }
[Severity: Medium]
Can this overwrite child->number_initial with the reassigned runtime bus number during a subsequent PCI bus rescan when pcibios_assign_all_busses() is enabled?
During the initial scan of a bridge taking the bus reassignment branch in pci_scan_bridge_extend(), pass 0 saves the firmware secondary bus number in dev->secondary_busnr. Pass 1 then transfers it to child->number_initial, resets dev->secondary_busnr to 0, and writes the newly assigned bus number (next_busnr) into the bridge's PCI_PRIMARY_BUS register:
drivers/pci/probe.c:pci_scan_bridge_extend() {
...
buses = (buses & PCI_SEC_LATENCY_TIMER_MASK) |
FIELD_PREP(PCI_PRIMARY_BUS_MASK, child->primary) |
FIELD_PREP(PCI_SECONDARY_BUS_MASK, child->busn_res.start) |
FIELD_PREP(PCI_SUBORDINATE_BUS_MASK, child->busn_res.end);
/* We need to blast all three values with a single write */
pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses);
...
}When a later bus rescan occurs (for example via pci_rescan_bus(), /sys/bus/pci/rescan, pci_rescan_bus_bridge_resize(), or hotplug), pass 0 reads PCI_PRIMARY_BUS again, where secondary is now the reassigned bus number. Because dev->secondary_busnr was reset to 0 in the first scan, !dev->secondary_busnr is true and dev->secondary_busnr is set to the reassigned bus number.
In pass 1 of the rescan, pci_find_bus(pci_domain_nr(bus), next_busnr) finds the existing child bus, and the block after if (!child) overwrites child->number_initial with the reassigned bus number. A similar overwrite can occur if pci_find_bus() finds an already-existing bus during hotplug.
Also, in the new-bus case, pci_add_new_bus() calls pci_alloc_child_bus(), which sets child->number_initial = busnr (next_busnr) before calling device_register(&child->dev), pcibios_add_bus(child), and child->ops->add_bus(child), so those callbacks see the reassigned bus number in child->number_initial before pci_scan_bridge_extend() updates it from dev->secondary_busnr.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v3 1/3] PCI: Preserve the initial bus number in pci_bus
Quoted 89 lines · On 10/26/26 11:01, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] PCI:number_initialclobbered on bus rescan inpci_scan_bridge_extend()--commit
66abeabff58a043b28934ad23308d764456e9fa4
Author: Mario Limonciello <[email protected]>PCI: Preserve the initial bus number in
pci_busThis commit saves the firmware-assigned secondary bus number before PCI bus renumbering and stores it in
pci_bus->number_initialso drivers can match firmware records against the initial bus number.Quoted 4 lines
drivers/pci/probe.c +0
-0[ ... ]
Quoted 26 lines
drivers/pci/probe.c +4
-0@@ -1232,6 +1233,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,/* Set up the primary, secondary and subordinate bus numbers */ child->number = child->busn_res.start = busnr; + child->number_initial = busnr; child->primary = parent->busn_res.start; child->busn_res.end =0xff ;@@ -1470,6 +1472,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, child =pci_add_new_bus (bus, dev, secondary);if (!child) goto out; + child->number_initial = secondary; child->primary = primary;pci_bus_insert_busn_res (child, secondary, subordinate); child->bridge_ctl = bctl;@@ -1491,6 +1494,8 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,* do in the second pass. */ if (!pass) { +if (!dev->secondary_busnr) + dev->secondary_busnr = secondary;if (pcibios_assign_all_busses () || broken)/* drivers/pci/probe.c static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, · line 1540
Quoted 7 lines
drivers/pci/probe.c +4
-0@@ -1529,6 +1534,10 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,pci_bus_insert_busn_res (child, next_busnr, bus->busn_res.end); } +if (dev->secondary_busnr) { + child->number_initial = dev->secondary_busnr; + dev->secondary_busnr =0 ; + }[Severity: Medium]
Can this overwritechild->number_initialwith the reassigned runtime bus number during a subsequent PCI bus rescan whenpcibios_assign_all_busses()is enabled?During the initial scan of a bridge taking the bus reassignment branch in
pci_scan_bridge_extend(), pass 0 saves the firmware secondary bus number indev->secondary_busnr. Pass 1 then transfers it tochild->number_initial, resetsdev->secondary_busnrto 0, and writes the newly assigned bus number (next_busnr) into the bridge'sPCI_PRIMARY_BUSregister:drivers/pci/probe.c:pci_scan_bridge_extend() { ... buses = (buses & PCI_SEC_LATENCY_TIMER_MASK) | FIELD_PREP(PCI_PRIMARY_BUS_MASK, child->primary) | FIELD_PREP(PCI_SECONDARY_BUS_MASK, child->busn_res.start) | FIELD_PREP(PCI_SUBORDINATE_BUS_MASK, child->busn_res.end); /* We need to blast all three values with a single write */ pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); ... }When a later bus rescan occurs (for example via
pci_rescan_bus(),/sys/bus/pci/rescan,pci_rescan_bus_bridge_resize(), or hotplug), pass 0 readsPCI_PRIMARY_BUSagain, where secondary is now the reassigned bus number. Becausedev->secondary_busnrwas reset to 0 in the first scan, !dev->secondary_busnr is true anddev->secondary_busnris set to the reassigned bus number.In pass 1 of the rescan,
pci_find_bus(pci_domain_nr(bus), next_busnr)finds the existing child bus, and the block after if (!child) overwriteschild->number_initialwith the reassigned bus number. A similar overwrite can occur ifpci_find_bus()finds an already-existing bus during hotplug.
Quoted 7 lines
Also, in the new-bus case,
pci_add_new_bus()callspci_alloc_child_bus(), which setschild->number_initial= busnr (next_busnr) before callingdevice_register(&child->dev),pcibios_add_bus(child), andchild->ops->add_bus(child), so those callbacks see the reassigned bus number inchild->number_initialbeforepci_scan_bridge_extend()updates it fromdev->secondary_busnr.
I'll dig in. I initially think this one is true.
Re: [PATCH v3 1/3] PCI: Preserve the initial bus number in pci_bus
In reply to Mario LimoncielloQuoted 68 lines · Mario Limonciello
Bridges that need bus reassignment are scanned in two passes. Save the firmware secondary bus number during the first pass, before the bridge is disabled, and carry it to the bus created in the second pass. Drivers can then match firmware records against the bus number from before PCI bus renumbering.
The initial number belongs to the bus, so consumers can use the
pci_busvalue directly without copying it into everypci_dev.Signed-off-by Mario Limonciello <[email protected]>--- drivers/pci/probe.c | 9 +++++++++ include/linux/pci.h | 2 ++ 2 files changed, 11 insertions(+)drivers/pci/probe.c +9
-0@@ -1012,6 +1012,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) bus->sysdata = bridge->sysdata; bus->ops = bridge->ops; bus->number = bus->busn_res.start = bridge->busnr; + bus->number_initial = bus->number;#ifdef CONFIG_PCI_DOMAINS_GENERIC if (bridge->domain_nr ==PCI_DOMAIN_NR_NOT_SET ) bus->domain_nr =pci_bus_find_domain_nr (bus, parent);@@ -1232,6 +1233,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,/* Set up the primary, secondary and subordinate bus numbers */ child->number = child->busn_res.start = busnr; + child->number_initial = busnr; child->primary = parent->busn_res.start; child->busn_res.end =0xff ;@@ -1470,6 +1472,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, child =pci_add_new_bus (bus, dev, secondary);if (!child) goto out; + child->number_initial = secondary; child->primary = primary;pci_bus_insert_busn_res (child, secondary, subordinate); child->bridge_ctl = bctl;@@ -1491,6 +1494,8 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,* do in the second pass. */ if (!pass) { +if (!dev->secondary_busnr) + dev->secondary_busnr = secondary;if (pcibios_assign_all_busses () || broken)/* @@ -1529,6 +1534,10 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,pci_bus_insert_busn_res (child, next_busnr, bus->busn_res.end); } +if (dev->secondary_busnr) { + child->number_initial = dev->secondary_busnr; + dev->secondary_busnr =0 ; + } max++;if (available_buses) available_buses--;include/linux/pci.h +0
-0
include/linux/pci.h struct pci_dev { · line 366
Quoted 4 lines
include/linux/pci.h +1
-0@@ -363,6 +363,7 @@ struct pci_dev {struct pci_slot *slot;/* Physical slot this device is in */ unsigned int devfn;/* Encoded device & function index */ +u8 secondary_busnr;/* Original secondary bus number */
This doesn't make sense for end point devices. Is it possible to keep under bus itself?
Thanks,
Lijo
Quoted 12 lines
include/linux/pci.h +1
-0unsigned short vendor;unsigned short device;unsigned short subsystem_vendor;@@ -724,6 +725,7 @@ struct pci_bus {struct proc_dir_entry *procdir;/* Directory entry in /proc/bus/pci */ unsigned char number;/* Bus number */ +unsigned char number_initial;/* Bus number before reassignment */ unsigned char primary;/* Number of primary bridge */ unsigned char max_bus_speed;/* enum pci_bus_speed */ unsigned char cur_bus_speed;/* enum pci_bus_speed */
PATCH v3 2/3 drm/amdgpu: Match VFCT using initial PCI bus number
In reply to Mario LimoncielloVFCT 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +3 -14
@@ -386,10 +386,8 @@ 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 */
@@ -405,16 +403,7 @@ 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 ; - -/* 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 == adev->pdev->bus->number_initial ?0 : -ENODEV ; }static bool amdgpu_acpi_vfct_bios (struct amdgpu_device *adev)
Signature · 1 line
2.43.0
Re: [PATCH v3 2/3] drm/amdgpu: Match VFCT using initial PCI bus number
Quoted 10 lines · 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 bus number captured from the firmware bus assignment before bridge renumbering.
Reported-by Reza Nikzad Chaleshori <[email protected]>Fixes 11c141672045f ("drm/amdgpu: Fix VFCT bus number matching with soft filter")Signed-off-by Mario Limonciello <[email protected]>
Accidentally lost Alex's tag when I rebased.
Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +3
-14@@ -386,10 +386,8 @@ 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 */ @@ -405,16 +403,7 @@ 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 ; - -/* 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 == adev->pdev->bus->number_initial ?0 : -ENODEV ; }static bool amdgpu_acpi_vfct_bios (struct amdgpu_device *adev)
[email protected]
AI reviewRe: [PATCH v3 2/3] drm/amdgpu: Match VFCT using initial PCI bus number
In reply to Mario LimoncielloSashiko has reviewed this patch and found no issues.
Quoted 10 lines
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 <[email protected]>Fixes 11c141672045f ("drm/amdgpu: Fix VFCT bus number matching with soft filter")Signed-off-by Mario Limonciello <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v3 3/3 drm/radeon: Match VFCT using initial PCI bus number
In reply to Mario LimoncielloVFCT 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.
--- drivers/gpu/drm/radeon/radeon_bios.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +3 -14
@@ -609,10 +609,8 @@ 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 using the bus number captured when the device was +* discovered, before any bus renumbering. * * Returns: 0 on match, -ENODEV on no match */
@@ -628,16 +626,7 @@ static int radeon_acpi_vfct_match(struct radeon_device *rdev, 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 ; +return vhdr->PCIBus == rdev->pdev->bus->number_initial ?0 : -ENODEV ; }static bool radeon_acpi_vfct_bios (struct radeon_device *rdev)
Signature · 1 line
2.43.0
Re: [PATCH v3 3/3] drm/radeon: Match VFCT using initial PCI bus number
Quoted 8 lines · 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 bus number captured from the firmware bus assignment before bridge renumbering.
Fixes 4059e2f02c8a ("drm/radeon: Fix VFCT bus number matching with soft filter")Signed-off-by Mario Limonciello <[email protected]>
Lost alex's tag on the rebase.
Quoted 40 lines
--- drivers/gpu/drm/radeon/radeon_bios.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)drivers/gpu/drm/radeon/radeon_bios.c +3
-14@@ -609,10 +609,8 @@ 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 using the bus number captured when the device was +* discovered, before any bus renumbering. * * Returns: 0 on match, -ENODEV on no match */ @@ -628,16 +626,7 @@ static int radeon_acpi_vfct_match(struct radeon_device *rdev, 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 ; +return vhdr->PCIBus == rdev->pdev->bus->number_initial ?0 : -ENODEV ; }static bool radeon_acpi_vfct_bios (struct radeon_device *rdev)
[email protected]
AI reviewRe: [PATCH v3 3/3] drm/radeon: Match VFCT using initial PCI bus number
In reply to Mario LimoncielloSashiko has reviewed this patch and found no issues.
Quoted 8 lines
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.
Fixes 4059e2f02c8a ("drm/radeon: Fix VFCT bus number matching with soft filter")Signed-off-by Mario Limonciello <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3