PM: sleep: Updates related to pm_suspend_target_state
Subsystems (8)
cover PM: sleep: Updates related to pm_suspend_target_state
Hi Everyone,
This allows PM debug messages to be printed during hibernation (again) in patch [1/3], adds pm_suspend_in_progress() for checking if a system suspend transition is in progress (which does not cover hibernation) on top of that (patch [2/3]), and adds pm_sleep_transition_in_progress() covering both system suspend and hibernation (patch [3/3]).
Thanks!
PATCH 1/3 PM: sleep: Print PM debug messages during hibernation
From: Rafael J. Wysocki <[email protected]>
Commit cdb8c100d8a4 ("include/linux/suspend.h: Only show pm_pr_dbg messages at suspend/resume") caused PM debug messages to only be printed during system-wide suspend and resume in progress, but it forgot about hibernation.
Address this by adding a check for hibernation in progress to pm_debug_messages_should_print().
--- kernel/power/hibernate.c | 5 +++++ kernel/power/main.c | 3 ++- kernel/power/power.h | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-)
kernel/power/hibernate.c +5 -0
@@ -90,6 +90,11 @@atomic_inc (&hibernate_atomic); } +bool hibernation_in_progress (void ) +{ +return !atomic_read (&hibernate_atomic); +} +bool hibernation_available (void ) { return nohibernate == 0 &&
kernel/power/main.c +2 -1
@@ -613,7 +613,8 @@bool pm_debug_messages_should_print (void ) { -return pm_debug_messages_on && pm_suspend_target_state !=PM_SUSPEND_ON ; +return pm_debug_messages_on && (hibernation_in_progress () || + pm_suspend_target_state !=PM_SUSPEND_ON ); }EXPORT_SYMBOL_GPL (pm_debug_messages_should_print);
kernel/power/power.h +4 -0
@@ -71,10 +71,14 @@static inline void enable_restore_image_protection (void ) {}#endif /* CONFIG_STRICT_KERNEL_RWX */ +extern bool hibernation_in_progress (void ); +#else /* !CONFIG_HIBERNATION */ static inline void hibernate_reserved_size_init (void ) {}static inline void hibernate_image_size_init (void ) {} + +static inline bool hibernation_in_progress (void ) {return false; }#endif /* !CONFIG_HIBERNATION */ #define power_attr (_name) \
PATCH 2/3 PM: sleep: Introduce pm_suspend_in_progress()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
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.
---
The only change in this patch that depends in the [1/3] is in kernel/power/main.c and it is not relevant for PCI/x86 and xe.
--- arch/x86/pci/fixup.c | 4 ++-- drivers/base/power/wakeup.c | 2 +- drivers/gpu/drm/xe/xe_pm.c | 2 +- include/linux/suspend.h | 5 +++++ kernel/power/main.c | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-)
arch/x86/pci/fixup.c +2 -2
@@ -970,13 +970,13 @@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);
drivers/base/power/wakeup.c +1 -1
@@ -337,7 +337,7 @@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));
drivers/gpu/drm/xe/xe_pm.c +1 -1
@@ -641,7 +641,7 @@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
include/linux/suspend.h +5 -0
@@ -298,6 +298,11 @@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.
kernel/power/main.c +2 -2
@@ -613,8 +613,8 @@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);
Re: [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress()
Quoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Introduce
pm_suspend_in_progress()to be used for checking if a system- wide suspend or resume transition is in progress, instead of comparingpm_suspend_target_statedirectly toPM_SUSPEND_ON, and use it where applicable.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 9 lines
---
The only change in this patch that depends in the [1/3] is in
kernel/power/main.cand it is not relevant for PCI/x86 and xe.--- arch/x86/pci/fixup.c | 4 ++-- drivers/base/power/wakeup.c | 2 +- drivers/gpu/drm/xe/xe_pm.c | 2 +-
to merge this through your trees
Quoted 74 lines
include/linux/suspend.h | 5 +++++ kernel/power/main.c | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-)arch/x86/pci/fixup.c +2
-2@@ -970,13 +970,13 @@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);drivers/base/power/wakeup.c +1
-1@@ -337,7 +337,7 @@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));drivers/gpu/drm/xe/xe_pm.c +1
-1@@ -641,7 +641,7 @@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 include/linux/suspend.h +5
-0@@ -298,6 +298,11 @@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. kernel/power/main.c +2
-2@@ -613,8 +613,8 @@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);
Re: [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress()
In reply to Rafael J. WysockiQuoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Introduce
pm_suspend_in_progress()to be used for checking if a system- wide suspend or resume transition is in progress, instead of comparingpm_suspend_target_statedirectly toPM_SUSPEND_ON, and use it where applicable.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>
PATCH 3/3 PM: sleep: Introduce pm_sleep_transition_in_progress()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
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().
--- drivers/base/power/wakeup.c | 2 +- include/linux/suspend.h | 4 ++++ kernel/power/main.c | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/base/power/wakeup.c +1 -1
@@ -337,7 +337,7 @@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));
include/linux/suspend.h +4 -0
@@ -475,6 +475,8 @@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 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
kernel/power/main.c +6 -2
@@ -609,12 +609,16 @@power_attr_ro (pm_wakeup_irq); +bool pm_sleep_transition_in_progress (void ) +{ +return pm_suspend_in_progress () ||hibernation_in_progress (); +} +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);
Quoted 12 lines · Rafael J. Wysocki
Hi Everyone,
This allows PM debug messages to be printed during hibernation (again) in patch [1/3], adds
pm_suspend_in_progress()for checking if a system suspend transition is in progress (which does not cover hibernation) on top of that (patch [2/3]), and addspm_sleep_transition_in_progress()covering both system suspend and hibernation (patch [3/3]).Thanks!
Thanks, LGTM!