Skip to content

Commit 34a364f

Browse files
committed
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
1 parent 1b17d45 commit 34a364f

5 files changed

Lines changed: 11 additions & 6 deletions

File tree

arch/x86/pci/fixup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,13 +970,13 @@ static void amd_rp_pme_suspend(struct pci_dev *dev)
970970
struct pci_dev *rp;
971971

972972
/*
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
974974
* amd-pmc will not be involved so PMEs during D3 work as advertised.
975975
*
976976
* The PMEs *do* work if amd-pmc doesn't put the SoC in the hardware
977977
* sleep state, but we assume amd-pmc is always present.
978978
*/
979-
if (pm_suspend_target_state == PM_SUSPEND_ON)
979+
if (!pm_suspend_in_progress())
980980
return;
981981

982982
rp = pcie_find_root_port(dev);

drivers/base/power/wakeup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ int device_wakeup_enable(struct device *dev)
337337
if (!dev || !dev->power.can_wakeup)
338338
return -EINVAL;
339339

340-
if (pm_suspend_target_state != PM_SUSPEND_ON)
340+
if (pm_suspend_in_progress())
341341
dev_dbg(dev, "Suspicious %s() during system transition!\n", __func__);
342342

343343
ws = wakeup_source_register(dev, dev_name(dev));

drivers/gpu/drm/xe/xe_pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ static bool xe_pm_suspending_or_resuming(struct xe_device *xe)
641641

642642
return dev->power.runtime_status == RPM_SUSPENDING ||
643643
dev->power.runtime_status == RPM_RESUMING ||
644-
pm_suspend_target_state != PM_SUSPEND_ON;
644+
pm_suspend_in_progress();
645645
#else
646646
return false;
647647
#endif

include/linux/suspend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {}
298298
static inline void s2idle_wake(void) {}
299299
#endif /* !CONFIG_SUSPEND */
300300

301+
static inline bool pm_suspend_in_progress(void)
302+
{
303+
return pm_suspend_target_state != PM_SUSPEND_ON;
304+
}
305+
301306
/* struct pbe is used for creating lists of pages that should be restored
302307
* atomically during the resume from disk, because the page frames they have
303308
* occupied before the suspend are in use.

kernel/power/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ bool pm_debug_messages_on __read_mostly;
613613

614614
bool pm_debug_messages_should_print(void)
615615
{
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());
618618
}
619619
EXPORT_SYMBOL_GPL(pm_debug_messages_should_print);
620620

0 commit comments

Comments
 (0)