]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PM: sleep: Introduce pm_suspend_in_progress()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 9 May 2025 13:02:27 +0000 (15:02 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 13 May 2025 12:00:20 +0000 (14:00 +0200)
Introduce pm_suspend_in_progress() to be used for checking if a system-
wide suspend or resume transition is in progress, instead of comparing
pm_suspend_target_state directly to PM_SUSPEND_ON, and use it where
applicable.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patch.msgid.link/2020901.PYKUYFuaPT@rjwysocki.net
arch/x86/pci/fixup.c
drivers/base/power/wakeup.c
drivers/gpu/drm/xe/xe_pm.c
include/linux/suspend.h
kernel/power/main.c

index efefeb82ab61d0522a28f754ac2e4289cf3c5dea..e8ee1afa1992a4e799b462e9d8edbf7e86ff654b 100644 (file)
@@ -970,13 +970,13 @@ static void amd_rp_pme_suspend(struct pci_dev *dev)
        struct pci_dev *rp;
 
        /*
-        * PM_SUSPEND_ON means we're doing runtime suspend, which means
+        * If system suspend is not in progress, we're doing runtime suspend, so
         * amd-pmc will not be involved so PMEs during D3 work as advertised.
         *
         * The PMEs *do* work if amd-pmc doesn't put the SoC in the hardware
         * sleep state, but we assume amd-pmc is always present.
         */
-       if (pm_suspend_target_state == PM_SUSPEND_ON)
+       if (!pm_suspend_in_progress())
                return;
 
        rp = pcie_find_root_port(dev);
index 63bf914a4d4467dcf6c42e50951b91677fb9c46d..6f6f309817f4b62462d2c20e3ce31d5d3615ff0f 100644 (file)
@@ -337,7 +337,7 @@ int device_wakeup_enable(struct device *dev)
        if (!dev || !dev->power.can_wakeup)
                return -EINVAL;
 
-       if (pm_suspend_target_state != PM_SUSPEND_ON)
+       if (pm_suspend_in_progress())
                dev_dbg(dev, "Suspicious %s() during system transition!\n", __func__);
 
        ws = wakeup_source_register(dev, dev_name(dev));
index 7b6b754ad6eb787429d6b80f4e4182028dcd631d..cb7fbf74138e7a0ae2763aa0e38ff069dac8d09f 100644 (file)
@@ -641,7 +641,7 @@ static bool xe_pm_suspending_or_resuming(struct xe_device *xe)
 
        return dev->power.runtime_status == RPM_SUSPENDING ||
                dev->power.runtime_status == RPM_RESUMING ||
-               pm_suspend_target_state != PM_SUSPEND_ON;
+               pm_suspend_in_progress();
 #else
        return false;
 #endif
index da6ebca3ff774c8bf59353aac08fe17106682b6d..52ea108f945197353dcda2186a0de6cf01a55e12 100644 (file)
@@ -298,6 +298,11 @@ static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {}
 static inline void s2idle_wake(void) {}
 #endif /* !CONFIG_SUSPEND */
 
+static inline bool pm_suspend_in_progress(void)
+{
+       return pm_suspend_target_state != PM_SUSPEND_ON;
+}
+
 /* struct pbe is used for creating lists of pages that should be restored
  * atomically during the resume from disk, because the page frames they have
  * occupied before the suspend are in use.
index fb20a6e26fb6ae4669a572f9e0c0e4f528c74eb7..8c26241c6724282875c1ba4ee9792391906113d5 100644 (file)
@@ -613,8 +613,8 @@ bool pm_debug_messages_on __read_mostly;
 
 bool pm_debug_messages_should_print(void)
 {
-       return pm_debug_messages_on && (hibernation_in_progress() ||
-               pm_suspend_target_state != PM_SUSPEND_ON);
+       return pm_debug_messages_on && (pm_suspend_in_progress() ||
+               hibernation_in_progress());
 }
 EXPORT_SYMBOL_GPL(pm_debug_messages_should_print);