From: <xianhutan@asrmicro.com>
To: <linux-pci@vger.kernel.org>
Cc: <bhelgaas@google.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] PCI/PM: Reject invalid PMCSR when checking PME status
Date: Tue, 1 Dec 2026 15:25:01 +0800 [thread overview]
Message-ID: <20261201072501.2340605-1-xianhutan@asrmicro.com> (raw)
From: Xianhu Tan <xianhutan@asrmicro.com>
pci_check_pme_status() reads PMCSR and tests PME_STATUS without
checking whether the configuration read succeeded or returned
a valid value.
When the device or its upstream bridge is inaccessible, the
configuration read may fail or return all ones. Since bit 15
of 0xffff is set, the PCI core incorrectly interprets the
PME_STATUS bit as asserted and reports a spurious PME event,
triggering a runtime resume of an already suspended device.
The issue occurs in pci_pme_list_scan(), which scans the PME
device list and calls pci_check_pme_status() for each entry.
On the affected platform, a device that has just entered
D3hot with the PCIe link in L1 may return 0xffff when PMCSR
is read, causing the PME scan to incorrectly trigger a
runtime resume.
Check the return value of pci_read_config_word() and reject
an all-ones PMCSR before checking PME_STATUS.
This also prevents writing PMCSR back to an inaccessible
device.
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@asrmicro.com>
---
drivers/pci/pci.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c6f2aba8..d1f8ff856 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2323,6 +2323,7 @@ void pcie_clear_root_pme_status(struct pci_dev *dev)
bool pci_check_pme_status(struct pci_dev *dev)
{
int pmcsr_pos;
+ int rc;
u16 pmcsr;
bool ret = false;
@@ -2330,7 +2331,10 @@ bool pci_check_pme_status(struct pci_dev *dev)
return false;
pmcsr_pos = dev->pm_cap + PCI_PM_CTRL;
- pci_read_config_word(dev, pmcsr_pos, &pmcsr);
+ rc = pci_read_config_word(dev, pmcsr_pos, &pmcsr);
+ if (rc != PCIBIOS_SUCCESSFUL || pmcsr == 0xffff)
+ return false;
+
if (!(pmcsr & PCI_PM_CTRL_PME_STATUS))
return false;
--
2.34.1
next reply other threads:[~2026-12-01 7:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 7:25 xianhutan [this message]
2026-12-01 10:20 ` Lukas Wunner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201072501.2340605-1-xianhutan@asrmicro.com \
--to=xianhutan@asrmicro.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®