diff mbox series

PM / runtime: Allow an irq-safe parent to be runtime suspended

Message ID 1510924566-16112-1-git-send-email-ulf.hansson@linaro.org
State New
Headers show
Series PM / runtime: Allow an irq-safe parent to be runtime suspended | expand

Commit Message

Ulf Hansson Nov. 17, 2017, 1:16 p.m. UTC
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(-)

-- 
2.7.4

Comments

Ulf Hansson Dec. 1, 2017, 7:35 a.m. UTC | #1
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

>
Rafael J. Wysocki Dec. 1, 2017, 1:52 p.m. UTC | #2
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
diff mbox series

Patch

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);
 		}
 	}