Skip to content

Commit 4484694

Browse files
committed
PM / Sleep: Simplify generic system suspend callbacks
The pm_runtime_suspended() check in __pm_generic_call() doesn't really help and may cause problems to happen, because in some cases the system suspend callbacks need to be called even if the given device has been suspended by runtime PM. For example, if the device generally supports remote wakeup and is not enabled to wake up the system from sleep, it should be prevented from generating wakeup signals during system suspend and that has to be done by the suspend callbacks that the pm_runtime_suspended() check prevents from being executed. Similarly, it may not be a good idea to unconditionally change the runtime PM status of the device to 'active' in __pm_generic_resume(), because the driver may want to leave the device in the 'suspended' state, depending on what happened to it before the system suspend and whether or not it is enabled to wake up the system. For the above reasons, remove the pm_runtime_suspended() check from __pm_generic_call() and remove the code changing the device's runtime PM status from __pm_generic_resume(). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> --- yaml --- svn_rev: 280399 current_ref: refs/heads/rpi-3.18.y current_commit: 8ca6d9b head_branch: refs/heads/rpi-3.18.y
1 parent 423f482 commit 4484694

2 files changed

Lines changed: 7 additions & 19 deletions

File tree

‎[refs]‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/rpi-3.18.y: cf007e3526a785a95a738d5a8fba44f1f4fe33e0
2+
refs/heads/rpi-3.18.y: 8ca6d9bcc8d33c592c0855b4b1481bc723ac7e85

‎trunk/drivers/base/power/generic_ops.c‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ int pm_generic_prepare(struct device *dev)
9797
* @event: PM transition of the system under way.
9898
* @bool: Whether or not this is the "noirq" stage.
9999
*
100-
* If the device has not been suspended at run time, execute the
101-
* suspend/freeze/poweroff/thaw callback provided by its driver, if defined, and
102-
* return its error code. Otherwise, return zero.
100+
* Execute the suspend/freeze/poweroff/thaw callback provided by the driver of
101+
* @dev, if defined, and return its error code. Return 0 if the callback is
102+
* not present.
103103
*/
104104
static int __pm_generic_call(struct device *dev, int event, bool noirq)
105105
{
106106
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
107107
int (*callback)(struct device *);
108108

109-
if (!pm || pm_runtime_suspended(dev))
109+
if (!pm)
110110
return 0;
111111

112112
switch (event) {
@@ -217,14 +217,12 @@ EXPORT_SYMBOL_GPL(pm_generic_thaw);
217217
* @bool: Whether or not this is the "noirq" stage.
218218
*
219219
* Execute the resume/resotre callback provided by the @dev's driver, if
220-
* defined. If it returns 0, change the device's runtime PM status to 'active'.
221-
* Return the callback's error code.
220+
* defined, and return its error code. Return 0 if the callback is not present.
222221
*/
223222
static int __pm_generic_resume(struct device *dev, int event, bool noirq)
224223
{
225224
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
226225
int (*callback)(struct device *);
227-
int ret;
228226

229227
if (!pm)
230228
return 0;
@@ -241,17 +239,7 @@ static int __pm_generic_resume(struct device *dev, int event, bool noirq)
241239
break;
242240
}
243241

244-
if (!callback)
245-
return 0;
246-
247-
ret = callback(dev);
248-
if (!ret && !noirq && pm_runtime_enabled(dev)) {
249-
pm_runtime_disable(dev);
250-
pm_runtime_set_active(dev);
251-
pm_runtime_enable(dev);
252-
}
253-
254-
return ret;
242+
return callback ? callback(dev) : 0;
255243
}
256244

257245
/**

0 commit comments

Comments
 (0)