[PATCH v5 04/11] USB: Pass PMSG_POWEROFF event to suspend_common() for poweroff with S4 flow
Mario Limonciello (AMD)
superm1 at kernel.org
Mon Aug 11 19:40:55 UTC 2025
If powering off the system with the S4 flow USB wakeup sources should
be ignored. Add a new callback hcd_pci_poweroff() which will differentiate
whether target state is S5 and pass PMSG_POWEROFF as the message so that
suspend_common() will avoid doing wakeups.
Signed-off-by: Mario Limonciello (AMD) <superm1 at kernel.org>
---
v5:
* New patch
v4:
* https://lore.kernel.org/linux-pci/20250616175019.3471583-1-superm1@kernel.org/
---
drivers/usb/core/hcd-pci.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index cd223475917ef..bfbd715c8cae9 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -6,6 +6,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/pm.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
@@ -531,6 +532,13 @@ static int hcd_pci_freeze(struct device *dev)
return suspend_common(dev, PMSG_FREEZE);
}
+static int hcd_pci_poweroff(struct device *dev)
+{
+ if (system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF)
+ return suspend_common(dev, PMSG_POWEROFF);
+ return suspend_common(dev, PMSG_SUSPEND);
+}
+
static int hcd_pci_suspend_noirq(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
@@ -639,7 +647,7 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops = {
.freeze_noirq = check_root_hub_suspended,
.thaw_noirq = NULL,
.thaw = hcd_pci_resume,
- .poweroff = hcd_pci_suspend,
+ .poweroff = hcd_pci_poweroff,
.poweroff_late = hcd_pci_poweroff_late,
.poweroff_noirq = hcd_pci_suspend_noirq,
.restore_noirq = hcd_pci_resume_noirq,
--
2.43.0
More information about the dri-devel
mailing list