PCI: Do not cache Immediate Readiness from a failed config read
PATCH 1/1 PCI: Do not cache Immediate Readiness from a failed config read
pci_imm_ready_init() uses PCI_STATUS even if pci_read_config_word() fails. The failed access leaves an all-ones response, whose Immediate Readiness bit is set. A later FLR then skips the wait even after config space has become accessible again, so early config restoration can be lost.
Leave imm_ready clear when the read fails or returns all ones. Keep the existing fast path for a valid status that advertises Immediate Readiness.
---
An arm64 QEMU kernel used the PCI core enumeration and FLR paths with a synthetic endpoint. With one injected initial PCI_STATUS read failure, the baseline cached imm_ready=1 and restored config immediately; the endpoint dropped the writes. The change kept imm_ready=0, waited 103 ms, and restored the config value. No physical endpoint was tested.
drivers/pci/probe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pci/probe.c +4 -1
@@ -2642,7 +2642,10 @@ static void pci_imm_ready_init(struct pci_dev *dev) {u16 status; -pci_read_config_word (dev,PCI_STATUS , &status); +if (pci_read_config_word (dev,PCI_STATUS , &status) || +PCI_POSSIBLE_ERROR (status)) +return ; +if (status &PCI_STATUS_IMM_READY ) dev->imm_ready =1 ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 10 lines
pci_imm_ready_init()usesPCI_STATUSeven ifpci_read_config_word()fails. The failed access leaves an all-ones response, whose Immediate Readiness bit is set. A later FLR then skips the wait even after config space has become accessible again, so early config restoration can be lost.Leave
imm_readyclear when the read fails or returns all ones. Keep the existing fast path for a valid status that advertises Immediate Readiness.Fixes d6112f8def51 ("PCI: Add support for Immediate Readiness")Signed-off-by Baek Kyu, Kim <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1