[PATCH v2] PCI/PM: Reject invalid PMCSR when checking PME status

From: xianhutan

Date: Wed Dec 02 2026 - 01:30:19 EST


From: Xianhu Tan <xianhutan@xxxxxxxxxxxx>

pci_check_pme_status() reads the PMCSR and checks the PME_STATUS
bit without validating the value read from the device.

If the device or its upstream bridge is inaccessible, a
configuration read may return all ones. Since bit 15 of 0xffff
is set, the PCI core incorrectly interprets the value as an
asserted PME_STATUS bit and reports a spurious PME event.

This can cause an unnecessary runtime resume of a suspended
device.

The issue occurs in pci_pme_list_scan(), which scans devices
on the PME list and calls pci_check_pme_status() to check
their PME status.

On the affected platform, reading the PMCSR after the device
enters D3hot with the PCIe link in L1 returns 0xffff, causing
the PME scan to trigger a false PME event.

Use PCI_POSSIBLE_ERROR() to reject an invalid PMCSR value
before checking PME_STATUS.

This also prevents writing the invalid PMCSR value back to
the device when clearing the PME status.

Tested on:
- ARM32 platform with PCIe endpoint.

Test cases:
- PMCSR read returns 0xffff: no false PME event is reported.
- Normal PME status handling remains unchanged.

Signed-off-by: Xianhu Tan <xianhutan@xxxxxxxxxxxx>
---
v2: Use PCI_POSSIBLE_ERROR() instead of open-coding the 0xffff check,
and drop the return value check of pci_read_config_word(), since the
PCI core already sets PCI_ERROR_RESPONSE on failed config reads.
(Lukas Wunner)

drivers/pci/pci.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c6f2aba8144..29ef31411dc8 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2331,6 +2331,9 @@ bool pci_check_pme_status(struct pci_dev *dev)

pmcsr_pos = dev->pm_cap + PCI_PM_CTRL;
pci_read_config_word(dev, pmcsr_pos, &pmcsr);
+ if (PCI_POSSIBLE_ERROR(pmcsr))
+ return false;
+
if (!(pmcsr & PCI_PM_CTRL_PME_STATUS))
return false;

--
2.34.1