PM / sleep: Allow devices without runtime PM to do direct-complete
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 15 Jul 2015 12:40:06 +0000 (14:40 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 21 Jul 2015 21:14:22 +0000 (23:14 +0200)
Don't unset the direct_complete flag on devices that have runtime PM
disabled, if they are runtime suspended.

This is needed because otherwise ancestor devices wouldn't be able to
do direct_complete without adding runtime PM support to all its
descendants.

Also removes pm_runtime_suspended_if_enabled() because it's now unused.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/power/devices.txt
Documentation/power/runtime_pm.txt
drivers/base/power/main.c
include/linux/pm_runtime.h

index d172bce0fd49845e4b9dd5a76b068e28e22055b5..8ba6625fdd63da42eae53cbbb1ca6539c199aa2e 100644 (file)
@@ -341,6 +341,13 @@ the phases are:
        and is entirely responsible for bringing the device back to the
        functional state as appropriate.
 
+       Note that this direct-complete procedure applies even if the device is
+       disabled for runtime PM; only the runtime-PM status matters.  It follows
+       that if a device has system-sleep callbacks but does not support runtime
+       PM, then its prepare callback must never return a positive value.  This
+       is because all devices are initially set to runtime-suspended with
+       runtime PM disabled.
+
     2. The suspend methods should quiesce the device to stop it from performing
        I/O.  They also may save the device registers and put it into the
        appropriate low-power state, depending on the bus type the device is on,
index e76dc0ad4d2b7393c0f6e55d51c2eab5686d6ed1..0784bc3a2ab51bd2d624644d6ea5a41e44529307 100644 (file)
@@ -445,10 +445,6 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
   bool pm_runtime_status_suspended(struct device *dev);
     - return true if the device's runtime PM status is 'suspended'
 
-  bool pm_runtime_suspended_if_enabled(struct device *dev);
-    - return true if the device's runtime PM status is 'suspended' and its
-      'power.disable_depth' field is equal to 1
-
   void pm_runtime_allow(struct device *dev);
     - set the power.runtime_auto flag for the device and decrease its usage
       counter (used by the /sys/devices/.../power/control interface to
index 30b7bbfdc5588d000dfc79d02ee53b0a886302e3..1710c26ba097d363873dfd8318ff1d949aeb4a86 100644 (file)
@@ -1377,7 +1377,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
        if (dev->power.direct_complete) {
                if (pm_runtime_status_suspended(dev)) {
                        pm_runtime_disable(dev);
-                       if (pm_runtime_suspended_if_enabled(dev))
+                       if (pm_runtime_status_suspended(dev))
                                goto Complete;
 
                        pm_runtime_enable(dev);
index 30e84d48bfeaa8e40075f1d47bba6e0d49b310c6..3bdbb4189780043f4e83af2e7d02401251f181a7 100644 (file)
@@ -98,11 +98,6 @@ static inline bool pm_runtime_status_suspended(struct device *dev)
        return dev->power.runtime_status == RPM_SUSPENDED;
 }
 
-static inline bool pm_runtime_suspended_if_enabled(struct device *dev)
-{
-       return pm_runtime_status_suspended(dev) && dev->power.disable_depth == 1;
-}
-
 static inline bool pm_runtime_enabled(struct device *dev)
 {
        return !dev->power.disable_depth;
@@ -164,7 +159,6 @@ static inline void device_set_run_wake(struct device *dev, bool enable) {}
 static inline bool pm_runtime_suspended(struct device *dev) { return false; }
 static inline bool pm_runtime_active(struct device *dev) { return true; }
 static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
-static inline bool pm_runtime_suspended_if_enabled(struct device *dev) { return false; }
 static inline bool pm_runtime_enabled(struct device *dev) { return false; }
 
 static inline void pm_runtime_no_callbacks(struct device *dev) {}