diff mbox series

PM: sleep: Do not let "syscore" devices runtime-suspend during system transitions

Message ID 5773062.lOV4Wx5bFT@kreacher (mailing list archive)
State Mainlined, archived
Headers show
Series PM: sleep: Do not let "syscore" devices runtime-suspend during system transitions | expand

Commit Message

Rafael J. Wysocki Oct. 22, 2021, 12:58 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

There is no reason to allow "syscore" devices to runtime-suspend
during system-wide PM transitions, because they are subject to the
same possible failure modes as any other devices in that respect.

Accordingly, change device_prepare() and device_complete() to call
pm_runtime_get_noresume() and pm_runtime_put(), respectively, for
"syscore" devices too.

Fixes: 057d51a1268f ("Merge branch 'pm-sleep'")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: 3.10+ <stable@vger.kernel.org> # 3.10+
---
 drivers/base/power/main.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Ulf Hansson Oct. 22, 2021, 1:57 p.m. UTC | #1
On Fri, 22 Oct 2021 at 14:58, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> There is no reason to allow "syscore" devices to runtime-suspend
> during system-wide PM transitions, because they are subject to the
> same possible failure modes as any other devices in that respect.
>
> Accordingly, change device_prepare() and device_complete() to call
> pm_runtime_get_noresume() and pm_runtime_put(), respectively, for
> "syscore" devices too.
>
> Fixes: 057d51a1268f ("Merge branch 'pm-sleep'")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Cc: 3.10+ <stable@vger.kernel.org> # 3.10+

This makes perfect sense for me too.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/base/power/main.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> Index: linux-pm/drivers/base/power/main.c
> ===================================================================
> --- linux-pm.orig/drivers/base/power/main.c
> +++ linux-pm/drivers/base/power/main.c
> @@ -1048,7 +1048,7 @@ static void device_complete(struct devic
>         const char *info = NULL;
>
>         if (dev->power.syscore)
> -               return;
> +               goto out;
>
>         device_lock(dev);
>
> @@ -1078,6 +1078,7 @@ static void device_complete(struct devic
>
>         device_unlock(dev);
>
> +out:
>         pm_runtime_put(dev);
>  }
>
> @@ -1789,9 +1790,6 @@ static int device_prepare(struct device
>         int (*callback)(struct device *) = NULL;
>         int ret = 0;
>
> -       if (dev->power.syscore)
> -               return 0;
> -
>         /*
>          * If a device's parent goes into runtime suspend at the wrong time,
>          * it won't be possible to resume the device.  To prevent this we
> @@ -1800,6 +1798,9 @@ static int device_prepare(struct device
>          */
>         pm_runtime_get_noresume(dev);
>
> +       if (dev->power.syscore)
> +               return 0;
> +
>         device_lock(dev);
>
>         dev->power.wakeup_path = false;
>
>
>
diff mbox series

Patch

Index: linux-pm/drivers/base/power/main.c
===================================================================
--- linux-pm.orig/drivers/base/power/main.c
+++ linux-pm/drivers/base/power/main.c
@@ -1048,7 +1048,7 @@  static void device_complete(struct devic
 	const char *info = NULL;
 
 	if (dev->power.syscore)
-		return;
+		goto out;
 
 	device_lock(dev);
 
@@ -1078,6 +1078,7 @@  static void device_complete(struct devic
 
 	device_unlock(dev);
 
+out:
 	pm_runtime_put(dev);
 }
 
@@ -1789,9 +1790,6 @@  static int device_prepare(struct device
 	int (*callback)(struct device *) = NULL;
 	int ret = 0;
 
-	if (dev->power.syscore)
-		return 0;
-
 	/*
 	 * If a device's parent goes into runtime suspend at the wrong time,
 	 * it won't be possible to resume the device.  To prevent this we
@@ -1800,6 +1798,9 @@  static int device_prepare(struct device
 	 */
 	pm_runtime_get_noresume(dev);
 
+	if (dev->power.syscore)
+		return 0;
+
 	device_lock(dev);
 
 	dev->power.wakeup_path = false;