* [PATCH v1 1/3] PM: sleep: Print PM debug messages during hibernation
2025-05-09 12:49 [PATCH v1 0/3] PM: sleep: Updates related to pm_suspend_target_state Rafael J. Wysocki
@ 2025-05-09 12:51 ` Rafael J. Wysocki
2025-05-09 13:02 ` [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress() Rafael J. Wysocki
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-05-09 12:51 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Mario Limonciello
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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().
Fixes: cdb8c100d8a4 ("include/linux/suspend.h: Only show pm_pr_dbg messages at suspend/resume")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
kernel/power/hibernate.c | 5 +++++
kernel/power/main.c | 3 ++-
kernel/power/power.h | 4 ++++
3 files changed, 11 insertions(+), 1 deletion(-)
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -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 &&
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -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);
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -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) \
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress()
2025-05-09 12:49 [PATCH v1 0/3] PM: sleep: Updates related to pm_suspend_target_state Rafael J. Wysocki
2025-05-09 12:51 ` [PATCH v1 1/3] PM: sleep: Print PM debug messages during hibernation Rafael J. Wysocki
@ 2025-05-09 13:02 ` Rafael J. Wysocki
2025-05-09 15:52 ` Rodrigo Vivi
2025-05-09 16:20 ` Raag Jadav
2025-05-09 13:03 ` [PATCH v1 3/3] PM: sleep: Introduce pm_sleep_transition_in_progress() Rafael J. Wysocki
2025-05-09 13:33 ` [PATCH v1 0/3] PM: sleep: Updates related to pm_suspend_target_state Mario Limonciello
3 siblings, 2 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-05-09 13:02 UTC (permalink / raw)
To: Linux PM
Cc: LKML, Mario Limonciello, Bjorn Helgaas, Linux PCI,
x86 Maintainers, intel-xe, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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>
---
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(-)
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -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);
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -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));
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -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
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -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.
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -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);
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress()
2025-05-09 13:02 ` [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress() Rafael J. Wysocki
@ 2025-05-09 15:52 ` Rodrigo Vivi
2025-05-09 16:20 ` Raag Jadav
1 sibling, 0 replies; 7+ messages in thread
From: Rodrigo Vivi @ 2025-05-09 15:52 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PM, LKML, Mario Limonciello, Bjorn Helgaas, Linux PCI,
x86 Maintainers, intel-xe, Lucas De Marchi, Thomas Hellström
On Fri, May 09, 2025 at 03:02:27PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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>
> ---
>
> 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 +-
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
to merge this through your trees
> include/linux/suspend.h | 5 +++++
> kernel/power/main.c | 4 ++--
> 5 files changed, 11 insertions(+), 6 deletions(-)
>
> --- a/arch/x86/pci/fixup.c
> +++ b/arch/x86/pci/fixup.c
> @@ -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);
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -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));
> --- a/drivers/gpu/drm/xe/xe_pm.c
> +++ b/drivers/gpu/drm/xe/xe_pm.c
> @@ -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
> --- a/include/linux/suspend.h
> +++ b/include/linux/suspend.h
> @@ -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.
> --- a/kernel/power/main.c
> +++ b/kernel/power/main.c
> @@ -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);
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress()
2025-05-09 13:02 ` [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress() Rafael J. Wysocki
2025-05-09 15:52 ` Rodrigo Vivi
@ 2025-05-09 16:20 ` Raag Jadav
1 sibling, 0 replies; 7+ messages in thread
From: Raag Jadav @ 2025-05-09 16:20 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PM, LKML, Mario Limonciello, Bjorn Helgaas, Linux PCI,
x86 Maintainers, intel-xe, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi
On Fri, May 09, 2025 at 03:02:27PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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: Raag Jadav <raag.jadav@intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 3/3] PM: sleep: Introduce pm_sleep_transition_in_progress()
2025-05-09 12:49 [PATCH v1 0/3] PM: sleep: Updates related to pm_suspend_target_state Rafael J. Wysocki
2025-05-09 12:51 ` [PATCH v1 1/3] PM: sleep: Print PM debug messages during hibernation Rafael J. Wysocki
2025-05-09 13:02 ` [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress() Rafael J. Wysocki
@ 2025-05-09 13:03 ` Rafael J. Wysocki
2025-05-09 13:33 ` [PATCH v1 0/3] PM: sleep: Updates related to pm_suspend_target_state Mario Limonciello
3 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-05-09 13:03 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Mario Limonciello
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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>
---
drivers/base/power/wakeup.c | 2 +-
include/linux/suspend.h | 4 ++++
kernel/power/main.c | 8 ++++++--
3 files changed, 11 insertions(+), 3 deletions(-)
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -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));
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -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
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -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);
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v1 0/3] PM: sleep: Updates related to pm_suspend_target_state
2025-05-09 12:49 [PATCH v1 0/3] PM: sleep: Updates related to pm_suspend_target_state Rafael J. Wysocki
` (2 preceding siblings ...)
2025-05-09 13:03 ` [PATCH v1 3/3] PM: sleep: Introduce pm_sleep_transition_in_progress() Rafael J. Wysocki
@ 2025-05-09 13:33 ` Mario Limonciello
3 siblings, 0 replies; 7+ messages in thread
From: Mario Limonciello @ 2025-05-09 13:33 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux PM; +Cc: LKML
On 5/9/2025 7:49 AM, Rafael J. Wysocki wrote:
> 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!
>
>
>
Thanks, LGTM!
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
^ permalink raw reply [flat|nested] 7+ messages in thread