Re: [PATCH 06/11] PM: runtime: Expand introduction with core concepts and structure

From: Rafael J. Wysocki (Intel)

Date: Thu Sep 17 2026 - 20:41:46 EST


On Fri, Sep 4, 2026 at 11:20 PM Brian Norris <briannorris@xxxxxxxxxxxx> wrote:
>
> I commonly see people have difficulty learning how runtime PM works
> because of the following key points [*]:
>
> 1) there are several boolean concepts in runtime PM, with somewhat
> similar meanings:
>
> enabled / disabled
> active / suspended
> allowed / forbidden
>
> 2) if these concepts are documented at all, they're scattered across
> the kerneldoc or Documentation/
>
> 3) the runtime_pm.rst docs don't make any attempt to ease a reader into
> understanding the concepts, and instead jump straight into how it's
> implemented (queues, 'struct device' fields, helpers).
>
> Let's try to remedy this a bit by discussing the core concepts and
> highlights at the top of the introduction, and introduce a few
> sub-headings, so it's easier to navigate different aspects of the
> introduction.
>
> While shuffling the intro around, I also see that the existing text
> largely mirrors the layout of the following sections (2, 3, and 4), but
> does so out of order. Reorder those, and point to section numbers.
>
> [*] In addition to API complexity. I count 61 pm_*() helpers, 7 of which
> are variations of put() and 8 of which are variations of get().
>
> Signed-off-by: Brian Norris <briannorris@xxxxxxxxxxxx>
> ---
>
> Documentation/power/runtime_pm.rst | 87 +++++++++++++++++++++++-------
> 1 file changed, 68 insertions(+), 19 deletions(-)
>
> diff --git a/Documentation/power/runtime_pm.rst b/Documentation/power/runtime_pm.rst
> index 39fdeeda7a1e..620b6988deca 100644
> --- a/Documentation/power/runtime_pm.rst
> +++ b/Documentation/power/runtime_pm.rst
> @@ -11,31 +11,80 @@ Runtime Power Management Framework for I/O Devices
> 1. Introduction
> ===============
>
> -Support for runtime power management (runtime PM) of I/O devices is provided
> -at the power management core (PM core) level by means of:
> -
> -* The power management workqueue pm_wq in which bus types and device drivers can
> - put their PM-related work items. It is strongly recommended that pm_wq be
> - used for queuing all work items related to runtime PM, because this allows
> - them to be synchronized with system-wide power transitions (suspend to RAM,
> - hibernation and resume from system sleep states). pm_wq is declared in
> - include/linux/pm_runtime.h and defined in kernel/power/main.c.
> -
> -* A number of runtime PM fields in the 'power' member of 'struct device' (which
> - is of the type 'struct dev_pm_info', defined in include/linux/pm.h) that can
> - be used for synchronizing runtime PM operations with one another.
> +Runtime power management (or runtime PM, sometimes shortened to RPM) allows
> +individual I/O devices to transition between high and low-power states
> +dynamically while the system is running, conserving power without waiting for a
> +system-wide sleep state.
> +
> +Core Concepts
> +-------------
> +
> +Understanding runtime PM requires distinguishing between several pairs of
> +complementary states that operate orthogonally: **active** / **suspended**,
> +**enabled** / **disabled**, and **allowed** / **forbidden**.
> +
> +* **Active**: The PM core tracks a device's runtime status as either **active**
> + (the device is operational, having completed its resume callback) or
> + **suspended** (the device is idle or in a low-power state, having
> + completed its suspend callback), along with transitional **suspending**
> + and **resuming** phases. State transitions are primarily driven by
> + reference counting: drivers call pm_runtime_get() (or related variants)
> + when the hardware is needed (ensuring the device is active) and
> + pm_runtime_put() when work completes, allowing the PM core to initiate
> + suspension (immediately or after an autosuspend delay) once the usage
> + counter and any active child dependencies reach zero.

While the above is fine IMV, the enabled/disabled concept is more
fundamental because "active" and "suspended" are not really relevant
when runtime PM is disabled. Yes, they need to be set properly before
enabling it and there is some complexity related to the integration
with system-wide PM, but generally speaking, if runtime PM is disabled
for a given device, its active/suspended status is irrelevant.

> +
> +* **Enabled**: Orthogonal to whether a device is currently active or suspended
> + is whether runtime PM is **enabled** or **disabled**.

So it is not orthogonal.

> This is governed by an
> + internal disable counter (``disable_depth``). All devices are initialized
> + with runtime PM disabled (``disable_depth == 1``)

This is only partially true because the PCI bus type, for instance,
enables runtime PM for all PCI devices and so it is enabled when
drivers get to them.

> and can also be disabled
> + during system sleep transitions or explicitly via pm_runtime_disable(). In
> + the disabled state, the PM core ignores idle and suspend requests and will
> + not execute runtime PM callbacks (->runtime_suspend(), ->runtime_resume(),
> + ->runtime_idle()).

Moreover, parent-child and supplied-consumer dependencies are
generally not tracked for devices with disabled runtime PM.

> A driver activates runtime PM processing during
> + initialization or probe by calling pm_runtime_enable(), decrementing
> + ``disable_depth`` to zero.

Yes, and it needs to set the active/suspended status to reflect the
current physical state of the device before calling
pm_runtime_enable().

> +
> +* **Allowed**: System policy and user space govern whether dynamic suspension
> + is permitted through the concepts of **allowed** and **forbidden**,
> + manipulated in-kernel via pm_runtime_allow() and pm_runtime_forbid() and
> + exposed to user space through the ``/sys/devices/.../power/control``
> + attribute. When runtime PM is forbidden (``control`` set to ``on``), the PM
> + core increments the device's usage counter, forcing the device to remain
> + active regardless of whether the driver is idle. When runtime PM is allowed
> + (``control`` set to ``auto``), this reference is dropped, permitting the PM
> + core to automatically suspend the device whenever its driver and child
> + devices are no longer using it.
> +
> +Notably, runtime PM also has a feature called "autosuspend." This is different
> +than the ``control`` notion of "auto" (i.e., "allowed"). Autosuspend is
> +described in more detail in Section 9.

Yup, and the changes below look good.

> +
> +Implementation Structure
> +------------------------
> +
> +Support for runtime power management is provided at the power management core
> +(PM core) level by means of:
>
> * Three device runtime PM callbacks in 'struct dev_pm_ops' (defined in
> - include/linux/pm.h).
> + include/linux/pm.h). See Section 2.
> +
> +* A number of runtime PM fields in the 'power' member of 'struct device' that
> + can be used for synchronizing runtime PM operations with one another. These
> + are covered in Section 3.
>
> * A set of helper functions defined in drivers/base/power/runtime.c that can be
> used for carrying out runtime PM operations in such a way that the
> - synchronization between them is taken care of by the PM core. Bus types and
> - device drivers are encouraged to use these functions.
> + synchronization between them is taken care of by the PM core. Bus types and
> + device drivers are encouraged to use these functions. They are covered in
> + Section 4.
>
> -The runtime PM callbacks present in 'struct dev_pm_ops', the device runtime PM
> -fields of 'struct dev_pm_info' and the core helper functions provided for
> -runtime PM are described below.
> +* The power management workqueue pm_wq in which bus types and device drivers can
> + put their PM-related work items. It is strongly recommended that pm_wq be
> + used for queuing all work items related to runtime PM, because this allows
> + them to be synchronized with system-wide power transitions (suspend to RAM,
> + hibernation and resume from system sleep states). pm_wq is declared in
> + include/linux/pm_runtime.h and defined in kernel/power/main.c.
>
> 2. Device Runtime PM Callbacks
> ==============================
> --
> 2.55.0.979.g7e5102b832-goog

Do the subsequent patches in the series depend on this one?