Skip to contentSkip to conversation

PCI: Do not cache Immediate Readiness from a failed config read

PATCH New Baek Kyu, Kim 2 participants 2 messages Oct 31 PCI

lore
Share & tools
lore
#0 lore raw

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.

Fixes d6112f8def51 ("PCI: Add support for 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
index 27008e2ea5af..eb4e17ebd055 100644
@@ -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
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

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.

Fixes d6112f8def51 ("PCI: Add support for Immediate Readiness")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1