All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM / runtime: Allow an irq-safe parent to be runtime suspended
@ 2017-11-17 13:16 Ulf Hansson
  2017-12-01  7:35 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2017-11-17 13:16 UTC (permalink / raw)
  To: Rafael J . Wysocki, Alan Stern, Ulf Hansson, linux-pm
  Cc: Kevin Hilman, Geert Uytterhoeven, Lina Iyer

When pm_runtime_irq_safe() is a called for a child device, it's assumed
that the parent is never also irq-safe. Therefore, is the parent runtime
resumed and the usage counter increased for it, as to avoid having an
irq-safe child waiting for non-irq-safe parent.

Improve this behaviour by taking into account that the parent could also be
irq-safe. In such case let's allow it to be runtime suspended.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/base/power/runtime.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index ec059750..d44f520 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1370,13 +1370,13 @@ EXPORT_SYMBOL_GPL(pm_runtime_no_callbacks);
  * Set the power.irq_safe flag, which tells the PM core that the
  * ->runtime_suspend() and ->runtime_resume() callbacks for this device should
  * always be invoked with the spinlock held and interrupts disabled.  It also
- * causes the parent's usage counter to be permanently incremented, preventing
- * the parent from runtime suspending -- otherwise an irq-safe child might have
- * to wait for a non-irq-safe parent.
+ * causes the parent's usage counter to be permanently incremented, unless the
+ * parent is also irq-safe. This prevents the parent from runtime suspending,
+ * otherwise an irq-safe child might have to wait for a non-irq-safe parent.
  */
 void pm_runtime_irq_safe(struct device *dev)
 {
-	if (dev->parent)
+	if (dev->parent && !pm_runtime_is_irq_safe(dev->parent))
 		pm_runtime_get_sync(dev->parent);
 	spin_lock_irq(&dev->power.lock);
 	dev->power.irq_safe = 1;
@@ -1507,7 +1507,7 @@ void pm_runtime_reinit(struct device *dev)
 			spin_lock_irq(&dev->power.lock);
 			dev->power.irq_safe = 0;
 			spin_unlock_irq(&dev->power.lock);
-			if (dev->parent)
+			if (dev->parent && !pm_runtime_is_irq_safe(dev->parent))
 				pm_runtime_put(dev->parent);
 		}
 	}
-- 
2.7.4

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

* Re: [PATCH] PM / runtime: Allow an irq-safe parent to be runtime suspended
  2017-11-17 13:16 [PATCH] PM / runtime: Allow an irq-safe parent to be runtime suspended Ulf Hansson
@ 2017-12-01  7:35 ` Ulf Hansson
  2017-12-01 13:52   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2017-12-01  7:35 UTC (permalink / raw)
  To: Rafael J . Wysocki, Alan Stern, Ulf Hansson, linux-pm
  Cc: Kevin Hilman, Geert Uytterhoeven, Lina Iyer

On 17 November 2017 at 14:16, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> When pm_runtime_irq_safe() is a called for a child device, it's assumed
> that the parent is never also irq-safe. Therefore, is the parent runtime
> resumed and the usage counter increased for it, as to avoid having an
> irq-safe child waiting for non-irq-safe parent.
>
> Improve this behaviour by taking into account that the parent could also be
> irq-safe. In such case let's allow it to be runtime suspended.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Rafael, I noticed you applied this for next, but I realized that I
have overlooked a couple of more things that needs to be taken care
of.

Can you please drop this version? I will re-spin a new version soon.

Kind regards
Uffe

> ---
>  drivers/base/power/runtime.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index ec059750..d44f520 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -1370,13 +1370,13 @@ EXPORT_SYMBOL_GPL(pm_runtime_no_callbacks);
>   * Set the power.irq_safe flag, which tells the PM core that the
>   * ->runtime_suspend() and ->runtime_resume() callbacks for this device should
>   * always be invoked with the spinlock held and interrupts disabled.  It also
> - * causes the parent's usage counter to be permanently incremented, preventing
> - * the parent from runtime suspending -- otherwise an irq-safe child might have
> - * to wait for a non-irq-safe parent.
> + * causes the parent's usage counter to be permanently incremented, unless the
> + * parent is also irq-safe. This prevents the parent from runtime suspending,
> + * otherwise an irq-safe child might have to wait for a non-irq-safe parent.
>   */
>  void pm_runtime_irq_safe(struct device *dev)
>  {
> -       if (dev->parent)
> +       if (dev->parent && !pm_runtime_is_irq_safe(dev->parent))
>                 pm_runtime_get_sync(dev->parent);
>         spin_lock_irq(&dev->power.lock);
>         dev->power.irq_safe = 1;
> @@ -1507,7 +1507,7 @@ void pm_runtime_reinit(struct device *dev)
>                         spin_lock_irq(&dev->power.lock);
>                         dev->power.irq_safe = 0;
>                         spin_unlock_irq(&dev->power.lock);
> -                       if (dev->parent)
> +                       if (dev->parent && !pm_runtime_is_irq_safe(dev->parent))
>                                 pm_runtime_put(dev->parent);
>                 }
>         }
> --
> 2.7.4
>

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

* Re: [PATCH] PM / runtime: Allow an irq-safe parent to be runtime suspended
  2017-12-01  7:35 ` Ulf Hansson
@ 2017-12-01 13:52   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2017-12-01 13:52 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Alan Stern, linux-pm, Kevin Hilman, Geert Uytterhoeven, Lina Iyer

On Friday, December 1, 2017 8:35:50 AM CET Ulf Hansson wrote:
> On 17 November 2017 at 14:16, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > When pm_runtime_irq_safe() is a called for a child device, it's assumed
> > that the parent is never also irq-safe. Therefore, is the parent runtime
> > resumed and the usage counter increased for it, as to avoid having an
> > irq-safe child waiting for non-irq-safe parent.
> >
> > Improve this behaviour by taking into account that the parent could also be
> > irq-safe. In such case let's allow it to be runtime suspended.
> >
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> Rafael, I noticed you applied this for next, but I realized that I
> have overlooked a couple of more things that needs to be taken care
> of.
> 
> Can you please drop this version? I will re-spin a new version soon.

Will do, thanks!

Rafael

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

end of thread, other threads:[~2017-12-01 13:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 13:16 [PATCH] PM / runtime: Allow an irq-safe parent to be runtime suspended Ulf Hansson
2017-12-01  7:35 ` Ulf Hansson
2017-12-01 13:52   ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.