Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PM: sleep: Introduce pm_suspend_in_progress()

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

+11 -6
+2 -2
arch/x86/pci/fixup.c
··· 970 970 struct pci_dev *rp; 971 971 972 972 /* 973 - * PM_SUSPEND_ON means we're doing runtime suspend, which means 973 + * If system suspend is not in progress, we're doing runtime suspend, so 974 974 * amd-pmc will not be involved so PMEs during D3 work as advertised. 975 975 * 976 976 * The PMEs *do* work if amd-pmc doesn't put the SoC in the hardware 977 977 * sleep state, but we assume amd-pmc is always present. 978 978 */ 979 - if (pm_suspend_target_state == PM_SUSPEND_ON) 979 + if (!pm_suspend_in_progress()) 980 980 return; 981 981 982 982 rp = pcie_find_root_port(dev);
+1 -1
drivers/base/power/wakeup.c
··· 337 337 if (!dev || !dev->power.can_wakeup) 338 338 return -EINVAL; 339 339 340 - if (pm_suspend_target_state != PM_SUSPEND_ON) 340 + if (pm_suspend_in_progress()) 341 341 dev_dbg(dev, "Suspicious %s() during system transition!\n", __func__); 342 342 343 343 ws = wakeup_source_register(dev, dev_name(dev));
+1 -1
drivers/gpu/drm/xe/xe_pm.c
··· 641 641 642 642 return dev->power.runtime_status == RPM_SUSPENDING || 643 643 dev->power.runtime_status == RPM_RESUMING || 644 - pm_suspend_target_state != PM_SUSPEND_ON; 644 + pm_suspend_in_progress(); 645 645 #else 646 646 return false; 647 647 #endif
+5
include/linux/suspend.h
··· 298 298 static inline void s2idle_wake(void) {} 299 299 #endif /* !CONFIG_SUSPEND */ 300 300 301 + static inline bool pm_suspend_in_progress(void) 302 + { 303 + return pm_suspend_target_state != PM_SUSPEND_ON; 304 + } 305 + 301 306 /* struct pbe is used for creating lists of pages that should be restored 302 307 * atomically during the resume from disk, because the page frames they have 303 308 * occupied before the suspend are in use.
+2 -2
kernel/power/main.c
··· 613 613 614 614 bool pm_debug_messages_should_print(void) 615 615 { 616 - return pm_debug_messages_on && (hibernation_in_progress() || 617 - pm_suspend_target_state != PM_SUSPEND_ON); 616 + return pm_debug_messages_on && (pm_suspend_in_progress() || 617 + hibernation_in_progress()); 618 618 } 619 619 EXPORT_SYMBOL_GPL(pm_debug_messages_should_print); 620 620