History

PM: runtime: Capture device status before disabling runtime PM

In some cases (for example, during system-wide suspend and resume of devices) it is useful to know whether or not runtime PM has ever been enabled for a given device and, if so, what the runtime PM status of it had been right before runtime PM was disabled for it last time. For this reason, introduce a new struct dev_pm_info field called last_status that will be used for capturing the runtime PM status of the device when its power.disable_depth counter changes from 0 to 1. The new field will be set to RPM_INVALID to start with and whenever power.disable_depth changes from 1 to 0, so it will be valid only when runtime PM of the device is currently disabled, but it has been enabled at least once. Immediately use power.last_status in rpm_resume() to make it handle the case when PM runtime is disabled for the device, but its runtime PM status is RPM_ACTIVE more consistently. Namely, make it return 1 if power.last_status is also equal to RPM_ACTIVE in that case (the idea being that if the status was RPM_ACTIVE last time when power.disable_depth was changing from 0 to 1 and it is still RPM_ACTIVE, it can be assumed to reflect what happened to the device last time when it was using runtime PM) and -EACCES otherwise. Update the documentation to provide a description of last_status and change the description of pm_runtime_resume() in it to reflect the new behavior of rpm_active(). While at it, rearrange the code in pm_runtime_enable() to be more straightforward and replace the WARN() macro in it with a pr_warn() invocation which is less disruptive.

Rafael J. Wysocki committed 4 years ago

Commit c24efa61 parent 1a3c7bb3 files · +37 −24Browse files

Showing the changes to include (1 of 3 files). Show all

Unified · Split

include/linux/pm.h+2−0
@@ -521,6 +521,7 @@ const struct dev_pm_ops __maybe_unused name = { \ · 520 unmodified lines
521 */521 */
522 522
523enum rpm_status {523enum rpm_status {
524 RPM_INVALID = -1,
524 RPM_ACTIVE = 0,525 RPM_ACTIVE = 0,
525 RPM_RESUMING,526 RPM_RESUMING,
526 RPM_SUSPENDED,527 RPM_SUSPENDED,
@@ -634,6 +635,7 @@ struct dev_pm_info { · 107 unmodified lines
634 unsigned int links_count;635 unsigned int links_count;
635 enum rpm_request request;636 enum rpm_request request;
636 enum rpm_status runtime_status;637 enum rpm_status runtime_status;
638 enum rpm_status last_status;
637 int runtime_error;639 int runtime_error;
638 int autosuspend_delay;640 int autosuspend_delay;
639 u64 last_busy;641 u64 last_busy;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t