Skip to content

Commit bc80c2e

Browse files
committed
PM: runtime: Do not call __rpm_callback() from rpm_idle()
Calling __rpm_callback() from rpm_idle() after adding device links support to the former is a clear mistake. Not only it causes rpm_idle() to carry out unnecessary actions, but it is also against the assumption regarding the stability of PM-runtime status across __rpm_callback() invocations, because rpm_suspend() and rpm_resume() may run in parallel with __rpm_callback() when it is called by rpm_idle() and the device's PM-runtime status can be updated by any of them. Fixes: 21d5c57 ("PM / runtime: Use device links") Link: https://lore.kernel.org/linux-pm/36aed941-a73e-d937-2721-4f0decd61ce0@quicinc.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
1 parent 76dcd73 commit bc80c2e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

drivers/base/power/runtime.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,17 @@ static int rpm_idle(struct device *dev, int rpmflags)
484484

485485
dev->power.idle_notification = true;
486486

487-
retval = __rpm_callback(callback, dev);
487+
if (dev->power.irq_safe)
488+
spin_unlock(&dev->power.lock);
489+
else
490+
spin_unlock_irq(&dev->power.lock);
491+
492+
retval = callback(dev);
493+
494+
if (dev->power.irq_safe)
495+
spin_lock(&dev->power.lock);
496+
else
497+
spin_lock_irq(&dev->power.lock);
488498

489499
dev->power.idle_notification = false;
490500
wake_up_all(&dev->power.wait_queue);

0 commit comments

Comments
 (0)