linux-stable/Documentation/power
Rafael J. Wysocki c24efa6732 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.

Link: https://lore.kernel.org/linux-pm/20211026222626.39222-1-ulf.hansson@linaro.org/t/#u
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-12-17 16:16:40 +01:00
..
powercap Documentation/powercap/dtpm: Add documentation for dtpm 2020-12-22 19:50:40 +01:00
regulator docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
apm-acpi.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
basic-pm-debugging.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
charger-manager.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
drivers-testing.rst PM: Wrap documentation to fit in 80 columns 2019-11-20 12:16:37 +01:00
energy-model.rst Documentation: power: Describe 'advanced' and 'simple' EM models 2021-11-10 21:26:34 +01:00
freezing-of-tasks.rst Documentation: Replace lkml.org links with lore 2021-01-11 12:47:38 -07:00
index.rst Documentation/powercap/dtpm: Add documentation for dtpm 2020-12-22 19:50:40 +01:00
opp.rst PM: Wrap documentation to fit in 80 columns 2019-11-20 12:16:37 +01:00
pci.rst PCI/PM: Rename pci_dev.d3_delay to d3hot_delay 2020-09-29 14:21:50 -05:00
pm_qos_interface.rst Documentation: power: fix pm_qos_interface.rst format warning 2020-02-20 11:53:32 +01:00
power_supply_class.rst dt-bindings: power: update battery.yaml reference 2021-04-02 13:00:55 +02:00
runtime_pm.rst PM: runtime: Capture device status before disabling runtime PM 2021-12-17 16:16:40 +01:00
s2ram.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
suspend-and-cpuhotplug.rst cpu/hotplug: Remove disable_nonboot_cpus() 2020-05-07 15:18:40 +02:00
suspend-and-interrupts.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
swsusp-and-swap-files.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
swsusp-dmcrypt.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
swsusp.rst PM: Wrap documentation to fit in 80 columns 2019-11-20 12:16:37 +01:00
tricks.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
userland-swsusp.rst PM: hibernate: fix docs for ioctls that return loff_t via pointer 2020-03-14 11:51:32 +01:00
video.rst docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00