linux-pm.vger.kernel.org archive mirror
 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

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