[PATCH] PCI: Report configuration access errors when requesting FLR

From: Baek Kyu, Kim

Date: Sat Oct 31 2026 - 03:17:14 EST


PCIe and AF FLR requests can fail after pci_dev_reset_iommu_prepare()
succeeds. pcie_flr() and pci_af_flr() ignore the config access result.
A failed request can then be reported as a successful reset when an
Immediate Readiness device skips the wait or a later config read works.

Check the request access in both paths and convert PCIBIOS_* errors to
negative errno values. Use the existing done path so IOMMU cleanup still
runs after a successful prepare. Leave successful requests and readiness
handling unchanged.

Fixes: 8dd7f8036c12 ("PCI: add support for function level reset")
Fixes: 1ca887970a39 ("PCI: Extend pci_reset_function() to support PCI Advanced Features")
Signed-off-by: Baek Kyu, Kim <pocj8ur4in@xxxxxxxxx>
---
An arm64 QEMU/KVM kernel used a synthetic PCI host with the normal PCI
enumeration and sysfs reset paths. A one-shot Device Control read
failure (PCIBIOS_DEVICE_NOT_FOUND) after IOMMU prepare issued no FLR,
but the original sysfs reset returned success. The change returned
-ENODEV while preserving the IOMMU cleanup path. No physical endpoint
or ATS/IOMMU domain restoration was tested.

drivers/pci/pci.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d79d2ee4ac69b..41fae1b1050c7 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4429,7 +4429,12 @@ int pcie_flr(struct pci_dev *dev)
return ret;
}

- pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
+ ret = pcie_capability_set_word(dev, PCI_EXP_DEVCTL,
+ PCI_EXP_DEVCTL_BCR_FLR);
+ if (ret) {
+ ret = pcibios_err_to_errno(ret);
+ goto done;
+ }

if (dev->imm_ready)
goto done;
@@ -4506,7 +4511,11 @@ static int pci_af_flr(struct pci_dev *dev, bool probe)
return ret;
}

- pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
+ ret = pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
+ if (ret) {
+ ret = pcibios_err_to_errno(ret);
+ goto done;
+ }

if (dev->imm_ready)
goto done;
--
2.55.0