]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PM: sleep: Introduce pm_sleep_transition_in_progress()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 9 May 2025 13:03:35 +0000 (15:03 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 13 May 2025 19:59:02 +0000 (21:59 +0200)
The "suspend in progress" check in device_wakeup_enable() does not
cover hibernation, but arguably it should do that, so introduce
pm_sleep_transition_in_progress() covering transitions during both
system suspend and hibernation to use in there and use it also in
pm_debug_messages_should_print().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patch.msgid.link/7820474.EvYhyI6sBW@rjwysocki.net
[ rjw: Move the new function definition under CONFIG_PM_SLEEP ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/wakeup.c
include/linux/suspend.h
kernel/power/main.c

index 6f6f309817f4b62462d2c20e3ce31d5d3615ff0f..7e612977be1b4cc3aaa9b7fcfe86429a5a30fe8d 100644 (file)
@@ -337,7 +337,7 @@ int device_wakeup_enable(struct device *dev)
        if (!dev || !dev->power.can_wakeup)
                return -EINVAL;
 
-       if (pm_suspend_in_progress())
+       if (pm_sleep_transition_in_progress())
                dev_dbg(dev, "Suspicious %s() during system transition!\n", __func__);
 
        ws = wakeup_source_register(dev, dev_name(dev));
index 52ea108f945197353dcda2186a0de6cf01a55e12..b1c76c8f2c8220a65f2c94dfc9f1561c7df8ca41 100644 (file)
@@ -475,6 +475,8 @@ extern void pm_print_active_wakeup_sources(void);
 extern unsigned int lock_system_sleep(void);
 extern void unlock_system_sleep(unsigned int);
 
+extern bool pm_sleep_transition_in_progress(void);
+
 #else /* !CONFIG_PM_SLEEP */
 
 static inline int register_pm_notifier(struct notifier_block *nb)
@@ -503,6 +505,8 @@ static inline void pm_system_irq_wakeup(unsigned int irq_number) {}
 static inline unsigned int lock_system_sleep(void) { return 0; }
 static inline void unlock_system_sleep(unsigned int flags) {}
 
+static inline bool pm_sleep_transition_in_progress(void) { return false; }
+
 #endif /* !CONFIG_PM_SLEEP */
 
 #ifdef CONFIG_PM_SLEEP_DEBUG
index 8c26241c6724282875c1ba4ee9792391906113d5..8d17de9c84162efd7db803c3f44d26ab90823daa 100644 (file)
@@ -557,6 +557,10 @@ static int __init pm_debugfs_init(void)
 late_initcall(pm_debugfs_init);
 #endif /* CONFIG_DEBUG_FS */
 
+bool pm_sleep_transition_in_progress(void)
+{
+       return pm_suspend_in_progress() || hibernation_in_progress();
+}
 #endif /* CONFIG_PM_SLEEP */
 
 #ifdef CONFIG_PM_SLEEP_DEBUG
@@ -613,8 +617,7 @@ bool pm_debug_messages_on __read_mostly;
 
 bool pm_debug_messages_should_print(void)
 {
-       return pm_debug_messages_on && (pm_suspend_in_progress() ||
-               hibernation_in_progress());
+       return pm_debug_messages_on && pm_sleep_transition_in_progress();
 }
 EXPORT_SYMBOL_GPL(pm_debug_messages_should_print);