Skip to content

Commit be6018a

Browse files
committed
Merge branches 'pm-core' and 'pm-sleep'
* pm-core: PM: runtime: Replace pm_runtime_callbacks_present() PM: runtime: clk: Fix clk_pm_runtime_get() error path PM: runtime: Make clear what we do when conditions are wrong in rpm_suspend() * pm-sleep: PM: hibernate: Restrict writes to the resume device PM: hibernate: Split off snapshot dev option PM: hibernate: Incorporate concurrency handling PM: sleep: Helpful edits for devices.rst documentation Documentation: PM: sleep: Update driver flags documentation PM: sleep: core: Rename DPM_FLAG_LEAVE_SUSPENDED PM: sleep: core: Rename DPM_FLAG_NEVER_SKIP PM: sleep: core: Rename dev_pm_smart_suspend_and_suspended() PM: sleep: core: Rename dev_pm_may_skip_resume() PM: sleep: core: Rework the power.may_skip_resume handling PM: sleep: core: Do not skip callbacks in the resume phase PM: sleep: core: Fold functions into their callers PM: sleep: core: Simplify the SMART_SUSPEND flag handling
3 parents 5fcd735 + 9a78754 + ad1e4f7 commit be6018a

File tree

30 files changed

+392
-442
lines changed

30 files changed

+392
-442
lines changed

Documentation/driver-api/pm/devices.rst

Lines changed: 127 additions & 72 deletions
Large diffs are not rendered by default.

Documentation/power/pci.rst

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,41 +1004,39 @@ including the PCI bus type. The flags should be set once at the driver probe
10041004
time with the help of the dev_pm_set_driver_flags() function and they should not
10051005
be updated directly afterwards.
10061006

1007-
The DPM_FLAG_NEVER_SKIP flag prevents the PM core from using the direct-complete
1008-
mechanism allowing device suspend/resume callbacks to be skipped if the device
1009-
is in runtime suspend when the system suspend starts. That also affects all of
1010-
the ancestors of the device, so this flag should only be used if absolutely
1011-
necessary.
1012-
1013-
The DPM_FLAG_SMART_PREPARE flag instructs the PCI bus type to only return a
1014-
positive value from pci_pm_prepare() if the ->prepare callback provided by the
1007+
The DPM_FLAG_NO_DIRECT_COMPLETE flag prevents the PM core from using the
1008+
direct-complete mechanism allowing device suspend/resume callbacks to be skipped
1009+
if the device is in runtime suspend when the system suspend starts. That also
1010+
affects all of the ancestors of the device, so this flag should only be used if
1011+
absolutely necessary.
1012+
1013+
The DPM_FLAG_SMART_PREPARE flag causes the PCI bus type to return a positive
1014+
value from pci_pm_prepare() only if the ->prepare callback provided by the
10151015
driver of the device returns a positive value. That allows the driver to opt
1016-
out from using the direct-complete mechanism dynamically.
1016+
out from using the direct-complete mechanism dynamically (whereas setting
1017+
DPM_FLAG_NO_DIRECT_COMPLETE means permanent opt-out).
10171018

10181019
The DPM_FLAG_SMART_SUSPEND flag tells the PCI bus type that from the driver's
10191020
perspective the device can be safely left in runtime suspend during system
10201021
suspend. That causes pci_pm_suspend(), pci_pm_freeze() and pci_pm_poweroff()
1021-
to skip resuming the device from runtime suspend unless there are PCI-specific
1022-
reasons for doing that. Also, it causes pci_pm_suspend_late/noirq(),
1023-
pci_pm_freeze_late/noirq() and pci_pm_poweroff_late/noirq() to return early
1024-
if the device remains in runtime suspend in the beginning of the "late" phase
1025-
of the system-wide transition under way. Moreover, if the device is in
1026-
runtime suspend in pci_pm_resume_noirq() or pci_pm_restore_noirq(), its runtime
1027-
power management status will be changed to "active" (as it is going to be put
1028-
into D0 going forward), but if it is in runtime suspend in pci_pm_thaw_noirq(),
1029-
the function will set the power.direct_complete flag for it (to make the PM core
1030-
skip the subsequent "thaw" callbacks for it) and return.
1031-
1032-
Setting the DPM_FLAG_LEAVE_SUSPENDED flag means that the driver prefers the
1033-
device to be left in suspend after system-wide transitions to the working state.
1034-
This flag is checked by the PM core, but the PCI bus type informs the PM core
1035-
which devices may be left in suspend from its perspective (that happens during
1036-
the "noirq" phase of system-wide suspend and analogous transitions) and next it
1037-
uses the dev_pm_may_skip_resume() helper to decide whether or not to return from
1038-
pci_pm_resume_noirq() early, as the PM core will skip the remaining resume
1039-
callbacks for the device during the transition under way and will set its
1040-
runtime PM status to "suspended" if dev_pm_may_skip_resume() returns "true" for
1041-
it.
1022+
to avoid resuming the device from runtime suspend unless there are PCI-specific
1023+
reasons for doing that. Also, it causes pci_pm_suspend_late/noirq() and
1024+
pci_pm_poweroff_late/noirq() to return early if the device remains in runtime
1025+
suspend during the "late" phase of the system-wide transition under way.
1026+
Moreover, if the device is in runtime suspend in pci_pm_resume_noirq() or
1027+
pci_pm_restore_noirq(), its runtime PM status will be changed to "active" (as it
1028+
is going to be put into D0 going forward).
1029+
1030+
Setting the DPM_FLAG_MAY_SKIP_RESUME flag means that the driver allows its
1031+
"noirq" and "early" resume callbacks to be skipped if the device can be left
1032+
in suspend after a system-wide transition into the working state. This flag is
1033+
taken into consideration by the PM core along with the power.may_skip_resume
1034+
status bit of the device which is set by pci_pm_suspend_noirq() in certain
1035+
situations. If the PM core determines that the driver's "noirq" and "early"
1036+
resume callbacks should be skipped, the dev_pm_skip_resume() helper function
1037+
will return "true" and that will cause pci_pm_resume_noirq() and
1038+
pci_pm_resume_early() to return upfront without touching the device and
1039+
executing the driver callbacks.
10421040

10431041
3.2. Device Runtime Power Management
10441042
------------------------------------

drivers/acpi/acpi_lpss.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ static int acpi_lpss_do_suspend_late(struct device *dev)
10411041
{
10421042
int ret;
10431043

1044-
if (dev_pm_smart_suspend_and_suspended(dev))
1044+
if (dev_pm_skip_suspend(dev))
10451045
return 0;
10461046

10471047
ret = pm_generic_suspend_late(dev);
@@ -1093,6 +1093,9 @@ static int acpi_lpss_resume_early(struct device *dev)
10931093
if (pdata->dev_desc->resume_from_noirq)
10941094
return 0;
10951095

1096+
if (dev_pm_skip_resume(dev))
1097+
return 0;
1098+
10961099
return acpi_lpss_do_resume_early(dev);
10971100
}
10981101

@@ -1102,12 +1105,9 @@ static int acpi_lpss_resume_noirq(struct device *dev)
11021105
int ret;
11031106

11041107
/* Follow acpi_subsys_resume_noirq(). */
1105-
if (dev_pm_may_skip_resume(dev))
1108+
if (dev_pm_skip_resume(dev))
11061109
return 0;
11071110

1108-
if (dev_pm_smart_suspend_and_suspended(dev))
1109-
pm_runtime_set_active(dev);
1110-
11111111
ret = pm_generic_resume_noirq(dev);
11121112
if (ret)
11131113
return ret;
@@ -1169,7 +1169,7 @@ static int acpi_lpss_poweroff_late(struct device *dev)
11691169
{
11701170
struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
11711171

1172-
if (dev_pm_smart_suspend_and_suspended(dev))
1172+
if (dev_pm_skip_suspend(dev))
11731173
return 0;
11741174

11751175
if (pdata->dev_desc->resume_from_noirq)
@@ -1182,7 +1182,7 @@ static int acpi_lpss_poweroff_noirq(struct device *dev)
11821182
{
11831183
struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
11841184

1185-
if (dev_pm_smart_suspend_and_suspended(dev))
1185+
if (dev_pm_skip_suspend(dev))
11861186
return 0;
11871187

11881188
if (pdata->dev_desc->resume_from_noirq) {

drivers/acpi/acpi_tad.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static int acpi_tad_probe(struct platform_device *pdev)
624624
*/
625625
device_init_wakeup(dev, true);
626626
dev_pm_set_driver_flags(dev, DPM_FLAG_SMART_SUSPEND |
627-
DPM_FLAG_LEAVE_SUSPENDED);
627+
DPM_FLAG_MAY_SKIP_RESUME);
628628
/*
629629
* The platform bus type layer tells the ACPI PM domain powers up the
630630
* device, so set the runtime PM status of it to "active".

drivers/acpi/device_pm.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ int acpi_subsys_suspend_late(struct device *dev)
10841084
{
10851085
int ret;
10861086

1087-
if (dev_pm_smart_suspend_and_suspended(dev))
1087+
if (dev_pm_skip_suspend(dev))
10881088
return 0;
10891089

10901090
ret = pm_generic_suspend_late(dev);
@@ -1100,10 +1100,8 @@ int acpi_subsys_suspend_noirq(struct device *dev)
11001100
{
11011101
int ret;
11021102

1103-
if (dev_pm_smart_suspend_and_suspended(dev)) {
1104-
dev->power.may_skip_resume = true;
1103+
if (dev_pm_skip_suspend(dev))
11051104
return 0;
1106-
}
11071105

11081106
ret = pm_generic_suspend_noirq(dev);
11091107
if (ret)
@@ -1116,8 +1114,8 @@ int acpi_subsys_suspend_noirq(struct device *dev)
11161114
* acpi_subsys_complete() to take care of fixing up the device's state
11171115
* anyway, if need be.
11181116
*/
1119-
dev->power.may_skip_resume = device_may_wakeup(dev) ||
1120-
!device_can_wakeup(dev);
1117+
if (device_can_wakeup(dev) && !device_may_wakeup(dev))
1118+
dev->power.may_skip_resume = false;
11211119

11221120
return 0;
11231121
}
@@ -1129,17 +1127,9 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend_noirq);
11291127
*/
11301128
static int acpi_subsys_resume_noirq(struct device *dev)
11311129
{
1132-
if (dev_pm_may_skip_resume(dev))
1130+
if (dev_pm_skip_resume(dev))
11331131
return 0;
11341132

1135-
/*
1136-
* Devices with DPM_FLAG_SMART_SUSPEND may be left in runtime suspend
1137-
* during system suspend, so update their runtime PM status to "active"
1138-
* as they will be put into D0 going forward.
1139-
*/
1140-
if (dev_pm_smart_suspend_and_suspended(dev))
1141-
pm_runtime_set_active(dev);
1142-
11431133
return pm_generic_resume_noirq(dev);
11441134
}
11451135

@@ -1153,7 +1143,12 @@ static int acpi_subsys_resume_noirq(struct device *dev)
11531143
*/
11541144
static int acpi_subsys_resume_early(struct device *dev)
11551145
{
1156-
int ret = acpi_dev_resume(dev);
1146+
int ret;
1147+
1148+
if (dev_pm_skip_resume(dev))
1149+
return 0;
1150+
1151+
ret = acpi_dev_resume(dev);
11571152
return ret ? ret : pm_generic_resume_early(dev);
11581153
}
11591154

@@ -1218,7 +1213,7 @@ static int acpi_subsys_poweroff_late(struct device *dev)
12181213
{
12191214
int ret;
12201215

1221-
if (dev_pm_smart_suspend_and_suspended(dev))
1216+
if (dev_pm_skip_suspend(dev))
12221217
return 0;
12231218

12241219
ret = pm_generic_poweroff_late(dev);
@@ -1234,7 +1229,7 @@ static int acpi_subsys_poweroff_late(struct device *dev)
12341229
*/
12351230
static int acpi_subsys_poweroff_noirq(struct device *dev)
12361231
{
1237-
if (dev_pm_smart_suspend_and_suspended(dev))
1232+
if (dev_pm_skip_suspend(dev))
12381233
return 0;
12391234

12401235
return pm_generic_poweroff_noirq(dev);

0 commit comments

Comments
 (0)