Patch "PM: runtime: Do not call __rpm_callback() from rpm_idle()" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    PM: runtime: Do not call __rpm_callback() from rpm_idle()

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pm-runtime-do-not-call-__rpm_callback-from-rpm_idle.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 110aaedb4ee40899a36a273475b4e53795d06486
Author: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Date:   Fri Dec 2 15:30:28 2022 +0100

    PM: runtime: Do not call __rpm_callback() from rpm_idle()
    
    [ Upstream commit bc80c2e438dcbfcf748452ec0f7ad5b79ff3ad88 ]
    
    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: 21d5c57b3726 ("PM / runtime: Use device links")
    Link: https://lore.kernel.org/linux-pm/36aed941-a73e-d937-2721-4f0decd61ce0@xxxxxxxxxxx
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
    Reviewed-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 24a3013728c3..9ee58bf49d13 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -465,7 +465,17 @@ static int rpm_idle(struct device *dev, int rpmflags)
 
 	dev->power.idle_notification = true;
 
-	retval = __rpm_callback(callback, dev);
+	if (dev->power.irq_safe)
+		spin_unlock(&dev->power.lock);
+	else
+		spin_unlock_irq(&dev->power.lock);
+
+	retval = callback(dev);
+
+	if (dev->power.irq_safe)
+		spin_lock(&dev->power.lock);
+	else
+		spin_lock_irq(&dev->power.lock);
 
 	dev->power.idle_notification = false;
 	wake_up_all(&dev->power.wait_queue);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux