linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow()
@ 2016-06-29  0:53 Rafael J. Wysocki
  2016-06-29 14:02 ` Alan Stern
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2016-06-29  0:53 UTC (permalink / raw)
  To: Linux PM list
  Cc: Arjan van de Ven, Linux Kernel Mailing List, Alan Stern,
	Ulf Hansson, Kevin Hilman

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Arjan reports that it takes a relatively long time to enable runtime
PM for multiple devices at system startup, because all writes to the
"control" attribute in sysfs are handled synchronously and if the
device is suspended as a result of the write, it will block until
that operation is complete.

That may be avoided by passing the RPM_ASYNC flag to rpm_idle()
in pm_runtime_allow() which will make it execute the device's
"idle" callback asynchronously, so writes to "control" changing
it from "on" to "auto" will return without waiting.

Reported-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/base/power/runtime.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-pm/drivers/base/power/runtime.c
===================================================================
--- linux-pm.orig/drivers/base/power/runtime.c
+++ linux-pm/drivers/base/power/runtime.c
@@ -1256,7 +1256,7 @@ void pm_runtime_allow(struct device *dev
 
 	dev->power.runtime_auto = true;
 	if (atomic_dec_and_test(&dev->power.usage_count))
-		rpm_idle(dev, RPM_AUTO);
+		rpm_idle(dev, RPM_AUTO | RPM_ASYNC);
 
  out:
 	spin_unlock_irq(&dev->power.lock);

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

* Re: [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow()
  2016-06-29  0:53 [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow() Rafael J. Wysocki
@ 2016-06-29 14:02 ` Alan Stern
  2016-06-29 15:00   ` Lukas Wunner
  2016-06-29 16:48 ` Ulf Hansson
  2016-06-30 22:48 ` Kevin Hilman
  2 siblings, 1 reply; 5+ messages in thread
From: Alan Stern @ 2016-06-29 14:02 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM list, Arjan van de Ven, Linux Kernel Mailing List,
	Ulf Hansson, Kevin Hilman

On Wed, 29 Jun 2016, Rafael J. Wysocki wrote:

> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Arjan reports that it takes a relatively long time to enable runtime
> PM for multiple devices at system startup, because all writes to the
> "control" attribute in sysfs are handled synchronously and if the
> device is suspended as a result of the write, it will block until
> that operation is complete.
> 
> That may be avoided by passing the RPM_ASYNC flag to rpm_idle()
> in pm_runtime_allow() which will make it execute the device's
> "idle" callback asynchronously, so writes to "control" changing
> it from "on" to "auto" will return without waiting.
> 
> Reported-by: Arjan van de Ven <arjan@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/base/power/runtime.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-pm/drivers/base/power/runtime.c
> ===================================================================
> --- linux-pm.orig/drivers/base/power/runtime.c
> +++ linux-pm/drivers/base/power/runtime.c
> @@ -1256,7 +1256,7 @@ void pm_runtime_allow(struct device *dev
>  
>  	dev->power.runtime_auto = true;
>  	if (atomic_dec_and_test(&dev->power.usage_count))
> -		rpm_idle(dev, RPM_AUTO);
> +		rpm_idle(dev, RPM_AUTO | RPM_ASYNC);
>  
>   out:
>  	spin_unlock_irq(&dev->power.lock);

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

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

* Re: [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow()
  2016-06-29 14:02 ` Alan Stern
@ 2016-06-29 15:00   ` Lukas Wunner
  0 siblings, 0 replies; 5+ messages in thread
From: Lukas Wunner @ 2016-06-29 15:00 UTC (permalink / raw)
  To: Alan Stern
  Cc: Rafael J. Wysocki, Linux PM list, Arjan van de Ven,
	Linux Kernel Mailing List, Ulf Hansson, Kevin Hilman

On Wed, Jun 29, 2016 at 10:02:42AM -0400, Alan Stern wrote:
> On Wed, 29 Jun 2016, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > Arjan reports that it takes a relatively long time to enable runtime
> > PM for multiple devices at system startup, because all writes to the
> > "control" attribute in sysfs are handled synchronously and if the
> > device is suspended as a result of the write, it will block until
> > that operation is complete.
> > 
> > That may be avoided by passing the RPM_ASYNC flag to rpm_idle()
> > in pm_runtime_allow() which will make it execute the device's
> > "idle" callback asynchronously, so writes to "control" changing
> > it from "on" to "auto" will return without waiting.

Looks like pm_runtime_allow() can now be added to the section "It is
safe to execute the following helper functions from interrupt context"
in Documentation/power/runtime_pm.txt.

Best regards,

Lukas

> > 
> > Reported-by: Arjan van de Ven <arjan@linux.intel.com>
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> >  drivers/base/power/runtime.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > Index: linux-pm/drivers/base/power/runtime.c
> > ===================================================================
> > --- linux-pm.orig/drivers/base/power/runtime.c
> > +++ linux-pm/drivers/base/power/runtime.c
> > @@ -1256,7 +1256,7 @@ void pm_runtime_allow(struct device *dev
> >  
> >  	dev->power.runtime_auto = true;
> >  	if (atomic_dec_and_test(&dev->power.usage_count))
> > -		rpm_idle(dev, RPM_AUTO);
> > +		rpm_idle(dev, RPM_AUTO | RPM_ASYNC);
> >  
> >   out:
> >  	spin_unlock_irq(&dev->power.lock);
> 
> Acked-by: Alan Stern <stern@rowland.harvard.edu>

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

* Re: [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow()
  2016-06-29  0:53 [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow() Rafael J. Wysocki
  2016-06-29 14:02 ` Alan Stern
@ 2016-06-29 16:48 ` Ulf Hansson
  2016-06-30 22:48 ` Kevin Hilman
  2 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2016-06-29 16:48 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM list, Arjan van de Ven, Linux Kernel Mailing List,
	Alan Stern, Kevin Hilman

On 29 June 2016 at 02:53, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Arjan reports that it takes a relatively long time to enable runtime
> PM for multiple devices at system startup, because all writes to the
> "control" attribute in sysfs are handled synchronously and if the
> device is suspended as a result of the write, it will block until
> that operation is complete.
>
> That may be avoided by passing the RPM_ASYNC flag to rpm_idle()
> in pm_runtime_allow() which will make it execute the device's
> "idle" callback asynchronously, so writes to "control" changing
> it from "on" to "auto" will return without waiting.
>
> Reported-by: Arjan van de Ven <arjan@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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

Kind regards
Uffe

> ---
>  drivers/base/power/runtime.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-pm/drivers/base/power/runtime.c
> ===================================================================
> --- linux-pm.orig/drivers/base/power/runtime.c
> +++ linux-pm/drivers/base/power/runtime.c
> @@ -1256,7 +1256,7 @@ void pm_runtime_allow(struct device *dev
>
>         dev->power.runtime_auto = true;
>         if (atomic_dec_and_test(&dev->power.usage_count))
> -               rpm_idle(dev, RPM_AUTO);
> +               rpm_idle(dev, RPM_AUTO | RPM_ASYNC);
>
>   out:
>         spin_unlock_irq(&dev->power.lock);
>

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

* Re: [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow()
  2016-06-29  0:53 [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow() Rafael J. Wysocki
  2016-06-29 14:02 ` Alan Stern
  2016-06-29 16:48 ` Ulf Hansson
@ 2016-06-30 22:48 ` Kevin Hilman
  2 siblings, 0 replies; 5+ messages in thread
From: Kevin Hilman @ 2016-06-30 22:48 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM list, Arjan van de Ven, Linux Kernel Mailing List,
	Alan Stern, Ulf Hansson

"Rafael J. Wysocki" <rjw@rjwysocki.net> writes:

> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Arjan reports that it takes a relatively long time to enable runtime
> PM for multiple devices at system startup, because all writes to the
> "control" attribute in sysfs are handled synchronously and if the
> device is suspended as a result of the write, it will block until
> that operation is complete.
>
> That may be avoided by passing the RPM_ASYNC flag to rpm_idle()
> in pm_runtime_allow() which will make it execute the device's
> "idle" callback asynchronously, so writes to "control" changing
> it from "on" to "auto" will return without waiting.
>
> Reported-by: Arjan van de Ven <arjan@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Reviewed-by: Kevin Hilman <khilman@baylibre.com>

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

end of thread, other threads:[~2016-06-30 22:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29  0:53 [PATCH] PM / runtime: Asynchronous "idle" in pm_runtime_allow() Rafael J. Wysocki
2016-06-29 14:02 ` Alan Stern
2016-06-29 15:00   ` Lukas Wunner
2016-06-29 16:48 ` Ulf Hansson
2016-06-30 22:48 ` Kevin Hilman

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