[PATCH v6 05/11] PCI: PM: Disable device wakeups when halting system through S4 flow

Mario Limonciello (AMD)
2025-08-18T02:01:23Z

PCI devices can be programmed as a wakeup source from low power states
by sysfs. However when using the S4 flow to go into S5 these wakeup
sources should be disabled to avoid what users would perceive as
spurious wakeup events.

Tested-by: Eric Naim <dnaim@cachyos.org>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
v5:
* Re-order
* Add tags
v4:
* https://lore.kernel.org/linux-pci/20250616175019.3471583-1-superm1@kernel.org/
---
drivers/pci/pci-driver.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 63665240ae87f..f201d298d7173 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1139,6 +1139,10 @@ static int pci_pm_poweroff(struct device *dev)
struct pci_dev *pci_dev = to_pci_dev(dev);
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;

+ if (device_may_wakeup(dev) &&
+ (system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF))
+ device_set_wakeup_enable(dev, false);
+
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_HIBERNATE);

--
2.43.0