intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 2/3] PM: sleep: Introduce pm_suspend_in_progress()
       [not found] <5903743.DvuYhMxLoT@rjwysocki.net>
@ 2025-05-09 13:02 ` Rafael J. Wysocki
  2025-05-09 15:52   ` Rodrigo Vivi
  2025-05-09 16:20   ` Raag Jadav
  0 siblings, 2 replies; 3+ 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] 3+ 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; 3+ 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] 3+ 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; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2025-05-09 16:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <5903743.DvuYhMxLoT@rjwysocki.net>
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).