public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM: allow runtime_suspend methods to call pm_schedule_suspend
@ 2010-03-19 15:51 Alan Stern
  2010-03-19 21:25 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2010-03-19 15:51 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux-pm mailing list

This patch (as1361) changes the runtime PM interface slightly; it
allows suspend requests to be scheduled while the runtime_suspend
method is running.  If the method succeeds then the scheduled request
is cancelled, whereas if the method fails then an idle notification is
sent only if no request was scheduled.

Being able to schedule suspend requests from within a runtime_suspend
method is useful for drivers that need to test for idleness and
suspend the device all while holding a single spinlock, or for drivers
that want to check for idleness by polling.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---

Index: usb-2.6/drivers/base/power/runtime.c
===================================================================
--- usb-2.6.orig/drivers/base/power/runtime.c
+++ usb-2.6/drivers/base/power/runtime.c
@@ -229,14 +229,16 @@ int __pm_runtime_suspend(struct device *
 
 	if (retval) {
 		dev->power.runtime_status = RPM_ACTIVE;
-		pm_runtime_cancel_pending(dev);
-
 		if (retval == -EAGAIN || retval == -EBUSY) {
-			notify = true;
+			if (dev->power.timer_expires == 0)
+				notify = true;
 			dev->power.runtime_error = 0;
+		} else {
+			pm_runtime_cancel_pending(dev);
 		}
 	} else {
 		dev->power.runtime_status = RPM_SUSPENDED;
+		pm_runtime_deactivate_timer(dev);
 
 		if (dev->parent) {
 			parent = dev->parent;
@@ -659,8 +661,6 @@ int pm_schedule_suspend(struct device *d
 
 	if (dev->power.runtime_status == RPM_SUSPENDED)
 		retval = 1;
-	else if (dev->power.runtime_status == RPM_SUSPENDING)
-		retval = -EINPROGRESS;
 	else if (atomic_read(&dev->power.usage_count) > 0
 	    || dev->power.disable_depth > 0)
 		retval = -EAGAIN;

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

* Re: [PATCH] PM: allow runtime_suspend methods to call pm_schedule_suspend
  2010-03-19 15:51 [PATCH] PM: allow runtime_suspend methods to call pm_schedule_suspend Alan Stern
@ 2010-03-19 21:25 ` Rafael J. Wysocki
  2010-03-20  1:49   ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2010-03-19 21:25 UTC (permalink / raw)
  To: Alan Stern; +Cc: Linux-pm mailing list

On Friday 19 March 2010, Alan Stern wrote:
> This patch (as1361) changes the runtime PM interface slightly; it
> allows suspend requests to be scheduled while the runtime_suspend
> method is running.  If the method succeeds then the scheduled request
> is cancelled, whereas if the method fails then an idle notification is
> sent only if no request was scheduled.
> 
> Being able to schedule suspend requests from within a runtime_suspend
> method is useful for drivers that need to test for idleness and
> suspend the device all while holding a single spinlock, or for drivers
> that want to check for idleness by polling.
> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

Looks good.

Do you need it in 2.6.34 or is it sufficient to queue it up for 2.6.35 (I'd prefer so)?

Rafael


> ---
> 
> Index: usb-2.6/drivers/base/power/runtime.c
> ===================================================================
> --- usb-2.6.orig/drivers/base/power/runtime.c
> +++ usb-2.6/drivers/base/power/runtime.c
> @@ -229,14 +229,16 @@ int __pm_runtime_suspend(struct device *
>  
>  	if (retval) {
>  		dev->power.runtime_status = RPM_ACTIVE;
> -		pm_runtime_cancel_pending(dev);
> -
>  		if (retval == -EAGAIN || retval == -EBUSY) {
> -			notify = true;
> +			if (dev->power.timer_expires == 0)
> +				notify = true;
>  			dev->power.runtime_error = 0;
> +		} else {
> +			pm_runtime_cancel_pending(dev);
>  		}
>  	} else {
>  		dev->power.runtime_status = RPM_SUSPENDED;
> +		pm_runtime_deactivate_timer(dev);
>  
>  		if (dev->parent) {
>  			parent = dev->parent;
> @@ -659,8 +661,6 @@ int pm_schedule_suspend(struct device *d
>  
>  	if (dev->power.runtime_status == RPM_SUSPENDED)
>  		retval = 1;
> -	else if (dev->power.runtime_status == RPM_SUSPENDING)
> -		retval = -EINPROGRESS;
>  	else if (atomic_read(&dev->power.usage_count) > 0
>  	    || dev->power.disable_depth > 0)
>  		retval = -EAGAIN;

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

* Re: [PATCH] PM: allow runtime_suspend methods to call pm_schedule_suspend
  2010-03-19 21:25 ` Rafael J. Wysocki
@ 2010-03-20  1:49   ` Alan Stern
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Stern @ 2010-03-20  1:49 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux-pm mailing list

On Fri, 19 Mar 2010, Rafael J. Wysocki wrote:

> On Friday 19 March 2010, Alan Stern wrote:
> > This patch (as1361) changes the runtime PM interface slightly; it
> > allows suspend requests to be scheduled while the runtime_suspend
> > method is running.  If the method succeeds then the scheduled request
> > is cancelled, whereas if the method fails then an idle notification is
> > sent only if no request was scheduled.
> > 
> > Being able to schedule suspend requests from within a runtime_suspend
> > method is useful for drivers that need to test for idleness and
> > suspend the device all while holding a single spinlock, or for drivers
> > that want to check for idleness by polling.
> > 
> > Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> 
> Looks good.
> 
> Do you need it in 2.6.34 or is it sufficient to queue it up for 2.6.35 (I'd prefer so)?

2.6.35 is good enough.

Alan Stern

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

end of thread, other threads:[~2010-03-20  1:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-19 15:51 [PATCH] PM: allow runtime_suspend methods to call pm_schedule_suspend Alan Stern
2010-03-19 21:25 ` Rafael J. Wysocki
2010-03-20  1:49   ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox