Commit graph

34 commits

Author SHA1 Message Date
Flavio Ceolin
437b56d22e pm: device_runtime: Make async optional
Async now uses its own work queue, which means it consumes more
resources. Since not all applications need the async API, we can make
it optional without any penalty for those applications.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-05-27 14:45:07 +02:00
Flavio Ceolin
64e38bab55 pm: device_runtime: Allow to use a dedicated wq
Device runtime is using the system workqueue to do operations
that are mostly blockers (suspend a device). This should not happen.

This commit adds an option to use dedicated queue for the device runtime
async operations.

The test for this API was assuming that the system workqueue
priority (which is cooperative) so we need to change the test priority
to be lower than the device runtime workqueue priority.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-05-27 14:45:07 +02:00
Krzysztof Chruściński
226c6ae17c pm: Optimize pre-wakeup in suspend procedure
When core is suspended and power mode has non zero exit_latency_us
a system timeout will be rescheduled to a point in time that is
earlier by exit_latency_us than request. It is to accommodate for
lengthy resuming procedure which would cause requested timeout to
be significantly late. However, setting additional wake up point
has cost, it is one more redundant core wake up and that impacts
performance and power consumption.

Add Kconfig option to chose what conversion method is used. It has
the biggest impact on small exit_latency_us where conversion may
result in 0 ticks (no pre-wake up) or 1 tick (wake up).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-04-08 19:26:57 +02:00
Flavio Ceolin
5bc6446dcc doc: releases: 4.1: Document removed PM symbol
The deprecated PM_DEVICE_RUNTIME_EXCLUSIVE option is been removed
in this release.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2025-01-31 07:50:17 +01:00
Gerard Marull-Paretas
6f4bb118a8 pm: policy: split policy APIs implementations
policy.c has grown organically, it contained many independent pieces of
code. This patch splits each logical unit into its own C file, making it
easier to browse the code.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-10-24 17:50:44 +02:00
Adam Kondraciuk
be523ad396 arch: arm: cortex_m: pm_s2ram: Minor typo fix
Fix typo in `PM_S2RAM_CUSTOM_MARKING` description.

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
2024-09-06 11:29:06 -04:00
Flavio Ceolin
f9de58efb9 pm: Do not select deprecated symbol
PM_DEVICE_RUNTIME_EXCLUSIVE was deprecated and its behavior
is achived with PM_DEVICE_SYSTEM_MANAGED=n.

Fixes #76037

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-07-22 03:28:54 -04:00
Alberto Escolar Piedras
1949f3205e subsys/pm/Kconfig: Fix typo
Fix a trivial typo in Kconfig

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-18 20:02:00 -04:00
Flavio Ceolin
73b755d817 pm: Add a symbol for device power state constraints
Add a symbol to enable device power state constraints this
saves resources when this feature is not needed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-07 19:06:23 -04:00
Flavio Ceolin
1c2e988021 pm: device: De-couple device pm from system pm
PM_DEVICE is not attached to system managed device power management.
It is a very common use case targets with device runtime power
management that don't want system device power management enabled.

We introduce a new symbol (PM_DEVICE_SYSTEM_MANAGED) to explicit
control whether or not system device power management should be
globally enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Flavio Ceolin
94af630b22 pm: Deprecate PM_DEVICE_RUNTIME_EXCLUSIVE
That is option has shown confusing on it is attempt to prevent
system pm doing device power management. Lets address this
problem properly.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Krzysztof Chruściński
24082d582f arch: arm: cortex_m: pm_s2ram: Add option for custom marking
s2ram procedure used RAM magic word for marking suspend-to-RAM. This
method may not work in some cases, e.g. when global reset does not
reset RAM content. In that case resuming from s2ram is detected when
global reset occurred.

RAM magic word method is the default but with
CONFIG_PM_S2RAM_CUSTOM_MARKING a custom implementation can be provided.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-05-17 14:33:47 +02:00
Fabio Baltieri
c5003e0eb1 pm: add device shell commands
Add support for a "pm" shell command to trigger suspend/resume as well
as runtime-get/put on devices. This is useful for testing during driver
development.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-04-25 18:00:05 -04:00
Leifu Zhao
61ab3a844c pm: policy: add check for device busy in policy
Add check for device busy when CONFIG_PM_NEED_ALL_DEVICES_IDLE is
set to y because one or more devices may still in busy and causes
problem when system go into low power in Intel ISH platform.

Signed-off-by: Leifu Zhao <leifu.zhao@intel.com>
2023-09-15 14:51:50 -04:00
Gerard Marull-Paretas
3d2194f11e pm: introduce HAS_PM
Add a new Kconfig option that has to be selected by SoCs providing PM
hooks. This option will be now required to enable CONFIG_PM. Before this
change, CONFIG_PM could always be enabled, regardless of SoC providing
any kind of low-power support.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-20 10:33:00 +00:00
Gerard Marull-Paretas
26bf349ab1 pm: drop HAS_NO_PM
Remove HAS_NO_PM option, in preparation for a new HAS_PM option
(inverted logic).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-20 10:33:00 +00:00
Gerard Marull-Paretas
1ebd76ed51 pm: add prompt to DEVICE_DEPS_DYNAMIC
The option can now be set by projects. This change will also allow to
make it dependent on a future CONFIG_DEVICE_DEPS option.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
319fbe57e1 device: s/HAS_DYNAMIC_DEVICE_HANDLES/DEVICE_DEPS_DYMAMIC
Rename the Kconfig option to be in line with recent renamings in device
handles/dependencies.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Carlo Caione
d38a6b4bcd pm: runtime: Migrate from condition variables to events
For the async operation move from condition variables to events to
reduce the dependency on the mutexes that cannot be used in IRQ
context.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-15 22:35:38 +01:00
Carlo Caione
1e74f1bff5 arch: Introduce S2RAM interface
Add a new API used by arch to implement suspend-to-RAM (S2RAM).

The API is composed by a single function to save the CPU context on
suspend.

A CPU context is the arch-specific set of registers that must be
preserved on power-off (in retained RAM) to be able to resume the
execution from the point it was suspended without going through the
whole kernel startup stage.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-11 15:26:26 +02:00
Carlo Caione
1608c8adba pm: Introduce CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE
Sometimes we want to entirely decouple the system PM from the device PM,
leaving the devices to manage its own power states using the runtime PM.

This is currently not possible because the suspend / resume code path is
triggering the device PM hooks even when the runtime PM is enabled.

Introduce a new PM_DEVICE_RUNTIME_EXCLUSIVE symbol to allow the platform
to skip the device PM triggers on suspend / resume.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-22 12:24:43 +02:00
Flavio Ceolin
0b13b44a66 pm: device: Dynamically add a device to a power domain
Add API to add devices to a power domain in runtime. The number of
devices that can be added is defined in build time.

The script gen_handles.py will check the number defined in
`CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC` to resize the handles vector,
adding empty slots in the supported sector to be used later.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Gerard Marull-Paretas
2238387285 pm: policy: move to pm folder
Move policy code one level up for simplicity, since there is a single
source file. Source file has been renamed to "policy.c" to make things
clear.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
95fb0ded6b kconfig: remove Enable from boolean prompts
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:

sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Flavio Ceolin
2e732dff6d pm: device: Make power domain optional
Add a Kconfig symbol to enable/disable power domain on Zephyr.
Disabling power domain save some memory / space.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-01-19 13:35:32 -05:00
Gerard Marull-Paretas
eea4eaccd6 pm: adjust PM_DEVICE prompt
Other prompts are use Capitalized Words.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-10-28 13:00:13 +02:00
Gerard Marull-Paretas
9398d0647b pm: rename HAS_NO_SYS_PM to HAS_NO_PM
Align name with other Kconfig options (CONFIG_PM).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-10-28 13:00:13 +02:00
Gerard Marull-Paretas
faa06ac4b1 pm: improve logging
List of improvements:

- The PM logging module was only available if CONFIG_PM=y, however, it
  was also used by Device PM (which can be selected without PM). A new
  logging module has been created for Device PM.
- Log level is passed to LOG_MODULE_(DECLARE|REGISTER)
- Logger name has been adjusted to `pm` (was `power`)

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-10-28 13:00:13 +02:00
Gerard Marull-Paretas
e3ce7859db pm: device: runtime: remove dependency on POLL
POLL is not a dependency of runtime device PM since it now uses
conditional variables to notify waiting threads.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-10-28 13:00:13 +02:00
Gerard Marull-Paretas
92b338e239 pm: remove deprecated Kconfig options
SYS_POWER_MANAGEMENT and DEVICE_POWER_MANAGEMENT were deprecated in
2.5.0, remove them now.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-10-28 13:00:13 +02:00
Tom Burdick
f523c336ef pm: Use stats subsys for tracking system states
Uses the stats subsys to provide simple but useful debugging stats for
power management state changes and timing.

Removes the no longer needed PM_DEBUG config option

Replaces the use of PM_DEBUG for a test clock output pin for mec1501 and
adds in its place an SoC Kconfig option to enable it.

Adds a STATS_SET macro for assigning a value to a stat group field

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2021-10-17 10:56:21 -04:00
Gerard Marull-Paretas
c708a17b8e pm: device: remove CONFIG_PM_MAX_DEVICES
When a device is defined a new pointer to a device will be created in
the "z_pm_device_slots" region, effectively creating a device array with
the same size as the number of system devices. This array is then used
by the device PM subsystem to keep track of suspended devices during
power transitions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-29 07:38:06 -04:00
Gerard Marull-Paretas
f69759d34a pm: rename CONFIG_PM_DEVICE_IDLE to CONFIG_PM_DEVICE_RUNTIME
Make naming clear on the purpose of this option.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
99cbee3f16 pm: move power subsystem to pm
Adjust naming to make things consistent.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Renamed from subsys/power/Kconfig (Browse further)