Skip to content

[RFC] Enhancements to Zephyr Power Management #84049

Open
0 of 1 issue completed
Open
RFC
0 of 1 issue completed
@ceolin

Description

@ceolin

Proposal for Enhancements to Zephyr Power Management

Introduction

Zephyr’s current power management framework provides mechanisms for managing device power states. However, we propose a refinement to focus exclusively on device runtime power management for better control, simplicity, and efficiency. Additionally, we will simplify power management build options and provide clear guidelines for device behavior during power state transitions.

This RFC takes #75963 into account.

Proposed Changes

Device Power Management via Runtime API Only

  • Eliminate calls to pm_device_action_run for managing device power states.
  • Power transitions will be exclusively managed through the runtime power management API.

Application Responsibility for Device Power Management

  • Applications must call pm_device_runtime_get to acquire a reference for a device before using it.
  • Applications must release the device using pm_device_runtime_put when done.

Subsystem Responsibility for Device Power Management

  • Subsystems must adopt similar responsibilities as applications:
    • Acquire references to devices they use via pm_device_runtime_get.
    • Release references when usage ends via pm_device_runtime_put.

Devices Initialized in Powered-Down State

  • All devices will initialize in a powered-down state.
  • Devices will transition to active states only when explicitly needed by an application or subsystem.

Simplify Build Options

Consolidate build options to only two power management modes:

  • System Power Management: Manages system-wide power transitions (e.g., suspend, resume).
    • Zephyr’s System Power Management focuses on managing the system power states (e.g., sleep, deep sleep, suspend, or power off).
    • System state changes are primarily motivated by two factors:
      • The system attempts to enter the lowest possible power state based on the next scheduled event. (IDLE thread)
      • Constraints: Devices and applications can define wake-up latency requirements, which restrict deeper low-power states, and power state constraints.
  • Device Power Management: Manages individual device power states via runtime APIs.
    • When device power management is disabled, devices will be initialized and kept active by default.

The following table by @decsny helps describe the affects of the two power management modes from the perspective of a single device and a system with three sleep states:

Possible SOC power states (example): mode_0 (active), mode_1 (idle), mode_2 (standby)

Example device DT:

dev@x {
    reg = <x>;
    compat = "some_dev";
    zephyr,disabling-states = <&mode_2>;
};
System PM Device PM Initial Device State Lowest possible SOC mode
n n Active * mode_0
y n Active * mode_1
n y Suspend mode_0
y y Suspend mode_2+

* will never be suspended if CONFIG_PM_DEVICE=n
+ can only enter mode_2 if dev is suspended (device constraint)

Device Behavior for Suspend and Turn Off

  • Devices must assume the following:
    • Suspend: Devices retain their context (e.g., internal states, configuration, and data). Devices can quickly resume operation without reinitialization.
    • Turn Off: Devices lose their context, including all states and configuration. This is a consequence of the suspension of the power domain the device belongs to. The device is completely powered down and requires reinitialization when powered on.
  • Application does not have control whether a device is suspended or powered off. The application only can inform if a device is needed. Turn off action is only triggered by the power domain the device belongs to.
  • States X actions:
Image
  • Power Domains/Rails Mapping:
    • A direct consequence of this behavior distinction is the need to map and control additional power domains and rails, such as those for internal SoC devices. This ensures precise control over which parts of the system are powered during suspend or turn-off states.
    • Updates to the power management framework will include support for mapping power domains to devices, allowing finer control and enabling the platform to power down unused regions of the SoC efficiently.

Benefits

  • Improved Efficiency: Devices powered only when needed reduce overall power consumption.
  • Simplified Build Configuration: Unified power management options make configuration easier for developers.
  • Consistent Device Behavior: Clearly defined rules for suspend and turn off actions ensure device drivers behave predictably.
  • Clear Responsibilities: Applications and subsystems explicitly manage power usage, aligning with modular design principles.
  • Scalability: The proposed changes lay the groundwork for more advanced power management features in the future.

Conclusion

This proposal aims to streamline and improve Zephyr’s power management framework by consolidating device power management under the runtime API, simplifying build options, and defining clear behaviors for suspend and turn-off actions. These changes will enhance power efficiency, simplify device power control, and reduce the complexity of power management configuration.

Scope of required changes

  • Implement pm device hook in all device drivers
  • Update all subsystems to use pm runtime
  • Stop using pm actions directly
  • Samples don’t need to be updated (except if they currently use pm actions directly)
  • SoCs must map internal devices to appropriated power domains

Sub-issues

Metadata

Metadata

Assignees

Labels

Architecture ReviewDiscussion in the Architecture WG requiredRFCRequest For Comments: want input from the communityarea: Power Management

Type

Projects

Status

No status

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions