linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] PM / sleep: Check legacy pm callbacks for direct complete
@ 2016-02-25  0:11 Derek Basehore
  2016-02-25  0:11 ` [PATCH v1 2/3] PM / sleep: try to runtime suspend " Derek Basehore
  2016-02-25  0:11 ` [PATCH v1 3/3] scsi: allow scsi devices to use " Derek Basehore
  0 siblings, 2 replies; 5+ messages in thread
From: Derek Basehore @ 2016-02-25  0:11 UTC (permalink / raw)
  To: linux-pm
  Cc: Rafael J . Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
	linux-kernel, James E . J . Bottomley, Martin K . Petersen,
	linux-scsi, Derek Basehore

This adds checks for legacy pm callbacks when setting no_pm_callbacks.
This fixes an issue where these suspend/resume callbacks were
incorrectly ignored during suspend/resume with direct complete.

Fixes: 4534d9d881f9 "PM / sleep: Go direct_complete if driver has..."
Signed-off-by: Derek Basehore <dbasehore@chromium.org>
---
 drivers/base/power/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 6e7c3cc..e0017d9 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1764,8 +1764,10 @@ void device_pm_check_callbacks(struct device *dev)
 {
 	spin_lock_irq(&dev->power.lock);
 	dev->power.no_pm_callbacks =
-		(!dev->bus || pm_ops_is_empty(dev->bus->pm)) &&
-		(!dev->class || pm_ops_is_empty(dev->class->pm)) &&
+		(!dev->bus || (!dev->bus->resume && !dev->bus->suspend &&
+			       pm_ops_is_empty(dev->bus->pm))) &&
+		(!dev->class || (!dev->class->resume && !dev->class->suspend &&
+				 pm_ops_is_empty(dev->class->pm))) &&
 		(!dev->type || pm_ops_is_empty(dev->type->pm)) &&
 		(!dev->pm_domain || pm_ops_is_empty(&dev->pm_domain->ops)) &&
 		(!dev->driver || pm_ops_is_empty(dev->driver->pm));
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 2/3] PM / sleep: try to runtime suspend for direct complete
  2016-02-25  0:11 [PATCH v1 1/3] PM / sleep: Check legacy pm callbacks for direct complete Derek Basehore
@ 2016-02-25  0:11 ` Derek Basehore
  2016-03-01 20:41   ` Ulf Hansson
  2016-02-25  0:11 ` [PATCH v1 3/3] scsi: allow scsi devices to use " Derek Basehore
  1 sibling, 1 reply; 5+ messages in thread
From: Derek Basehore @ 2016-02-25  0:11 UTC (permalink / raw)
  To: linux-pm
  Cc: Rafael J . Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
	linux-kernel, James E . J . Bottomley, Martin K . Petersen,
	linux-scsi, Derek Basehore

This tries to runtime suspend devices that are still active for direct
complete. This is for cases such as autosuspend delays which leaves
devices able to runtime suspend but still active. It's beneficial in
this case to runtime suspend the device to take advantage of direct
complete when possible.

Signed-off-by: Derek Basehore <dbasehore@chromium.org>
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
---
 drivers/base/power/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index e0017d9..9693032 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1380,7 +1380,12 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
 		goto Complete;
 
 	if (dev->power.direct_complete) {
-		if (pm_runtime_status_suspended(dev)) {
+		/*
+		 * Check if we're runtime suspended. If not, try to runtime
+		 * suspend for autosuspend cases.
+		 */
+		if (pm_runtime_status_suspended(dev) ||
+		    !pm_runtime_suspend(dev)) {
 			pm_runtime_disable(dev);
 			if (pm_runtime_status_suspended(dev))
 				goto Complete;
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 3/3] scsi: allow scsi devices to use direct complete
  2016-02-25  0:11 [PATCH v1 1/3] PM / sleep: Check legacy pm callbacks for direct complete Derek Basehore
  2016-02-25  0:11 ` [PATCH v1 2/3] PM / sleep: try to runtime suspend " Derek Basehore
@ 2016-02-25  0:11 ` Derek Basehore
  1 sibling, 0 replies; 5+ messages in thread
From: Derek Basehore @ 2016-02-25  0:11 UTC (permalink / raw)
  To: linux-pm
  Cc: Rafael J . Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
	linux-kernel, James E . J . Bottomley, Martin K . Petersen,
	linux-scsi, Derek Basehore

This allows scsi devices to remain runtime suspended for system
suspend. Since runtime suspend is stricter than system suspend
callbacks, this is just returning a positive number for the prepare
callback.

Signed-off-by: Derek Basehore <dbasehore@chromium.org>
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
---
 drivers/scsi/scsi_pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index b44c1bb..7af76ad 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -178,7 +178,7 @@ static int scsi_bus_prepare(struct device *dev)
 		/* Wait until async scanning is finished */
 		scsi_complete_async_scans();
 	}
-	return 0;
+	return 1;
 }
 
 static int scsi_bus_suspend(struct device *dev)
-- 
2.7.0.rc3.207.g0ac5344


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/3] PM / sleep: try to runtime suspend for direct complete
  2016-02-25  0:11 ` [PATCH v1 2/3] PM / sleep: try to runtime suspend " Derek Basehore
@ 2016-03-01 20:41   ` Ulf Hansson
       [not found]     ` <CAGAzgsocODbT9+sKE0tR1W5V=68FkX=O6_mvSwhzu7Lq9E7NtQ@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2016-03-01 20:41 UTC (permalink / raw)
  To: Derek Basehore
  Cc: linux-pm@vger.kernel.org, Rafael J . Wysocki, Len Brown,
	Pavel Machek, Greg Kroah-Hartman, linux-kernel@vger.kernel.org,
	James E . J . Bottomley, Martin K . Petersen, linux-scsi

On 25 February 2016 at 01:11, Derek Basehore <dbasehore@chromium.org> wrote:
> This tries to runtime suspend devices that are still active for direct
> complete. This is for cases such as autosuspend delays which leaves
> devices able to runtime suspend but still active. It's beneficial in
> this case to runtime suspend the device to take advantage of direct
> complete when possible.

Unfortunate this doesn't work. In the device_prepare() phase the PM
core prevents runtime suspend via a call to pm_runtime_get_noresume().

Kind regards
Uffe

>
> Signed-off-by: Derek Basehore <dbasehore@chromium.org>
> Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
> ---
>  drivers/base/power/main.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index e0017d9..9693032 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -1380,7 +1380,12 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
>                 goto Complete;
>
>         if (dev->power.direct_complete) {
> -               if (pm_runtime_status_suspended(dev)) {
> +               /*
> +                * Check if we're runtime suspended. If not, try to runtime
> +                * suspend for autosuspend cases.
> +                */
> +               if (pm_runtime_status_suspended(dev) ||
> +                   !pm_runtime_suspend(dev)) {
>                         pm_runtime_disable(dev);
>                         if (pm_runtime_status_suspended(dev))
>                                 goto Complete;
> --
> 2.7.0.rc3.207.g0ac5344
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/3] PM / sleep: try to runtime suspend for direct complete
       [not found]     ` <CAGAzgsocODbT9+sKE0tR1W5V=68FkX=O6_mvSwhzu7Lq9E7NtQ@mail.gmail.com>
@ 2016-03-02  9:26       ` Ulf Hansson
  0 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2016-03-02  9:26 UTC (permalink / raw)
  To: dbasehore .
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Greg Kroah-Hartman, linux-pm@vger.kernel.org, Len Brown,
	Rafael J . Wysocki, Pavel Machek, linux-kernel@vger.kernel.org

On 2 March 2016 at 09:31, dbasehore . <dbasehore@chromium.org> wrote:
>
> On Mar 1, 2016 12:41, "Ulf Hansson" <ulf.hansson@linaro.org> wrote:
>>
>> On 25 February 2016 at 01:11, Derek Basehore <dbasehore@chromium.org>
>> wrote:
>> > This tries to runtime suspend devices that are still active for direct
>> > complete. This is for cases such as autosuspend delays which leaves
>> > devices able to runtime suspend but still active. It's beneficial in
>> > this case to runtime suspend the device to take advantage of direct
>> > complete when possible.
>>
>> Unfortunate this doesn't work. In the device_prepare() phase the PM
>> core prevents runtime suspend via a call to pm_runtime_get_noresume().
>>
>> Kind regards
>> Uffe
>>
>
> A call to pm_runtime_put_sync_suspend should work. We can't do this
> earlier, because we don't know if the device will actually use
> direct_complete due to its children. Calling pm_runtime_put_noidle may
> allow another pm_runtime_put to runtime suspend the device, but we're
> trying to do that anyways. Also, we can't just call ...put_sync since that
> might not suspend due to autosuspend delays.
>
> We just need to balance the call with another get_noresume after. Am I
> missing anything?

Yes.

The important part that you need to take into consideration is the
sysfs intererface for runtime PM of devices. It allows userspace to
prevent runtime PM suspend (pm_runtime_forbid()). Therefore, you
simply can not rely on the regular runtime PM APIs to put a device
into low power state during system PM.

In cases of a runtime PM centric subsystem/driver, it can instead use
pm_runtime_force_suspend().

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-02  9:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-25  0:11 [PATCH v1 1/3] PM / sleep: Check legacy pm callbacks for direct complete Derek Basehore
2016-02-25  0:11 ` [PATCH v1 2/3] PM / sleep: try to runtime suspend " Derek Basehore
2016-03-01 20:41   ` Ulf Hansson
     [not found]     ` <CAGAzgsocODbT9+sKE0tR1W5V=68FkX=O6_mvSwhzu7Lq9E7NtQ@mail.gmail.com>
2016-03-02  9:26       ` Ulf Hansson
2016-02-25  0:11 ` [PATCH v1 3/3] scsi: allow scsi devices to use " Derek Basehore

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).