Skip to content

[RFC] feat(linux): s2idle: Document the mode selection logic#641

Draft
DhruvaG2000 wants to merge 1 commit intoTexasInstruments:masterfrom
DhruvaG2000:s2idle_mode_sel_v1
Draft

[RFC] feat(linux): s2idle: Document the mode selection logic#641
DhruvaG2000 wants to merge 1 commit intoTexasInstruments:masterfrom
DhruvaG2000:s2idle_mode_sel_v1

Conversation

@DhruvaG2000
Copy link
Copy Markdown
Collaborator

Document the mode selection logic using the s2idle flow

Copy link
Copy Markdown
Contributor

@kwillis01 kwillis01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to see if there are other places in the previous parts of the doc that can be updated or that the new info can loop into and consolidate.

2. **Constraint Propagation**: When a device in the CLUSTER_PD is active (e.g., Display Subsystem),
the cluster cannot enter its deepest idle state. The constraint propagates up the hierarchy,
preventing both CLUSTER_PD and MAIN_PD from entering deeper states.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the above point correct, since when we use rtcwake, even if the Display is connected, it does enter the selected LPM

3. **Automatic Mode Selection**: The cpuidle framework uses the hierarchy to automatically select
the deepest possible state. If any device in a power domain is active or has latency constraints,
shallower states are automatically chosen.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, the framework is obeying the latency constraint for mode selection but not the power domain mapping on forced s2idle


1. Each device or CPU can register a latency constraint (in nanoseconds)
2. The cpuidle governor queries these constraints before selecting an idle state
3. Only idle states with ``exit-latency-us`` ≤ constraint are considered
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the governor compares the constraint with exit-latency-us + entry-latency-us. This could cause confusion while setting the constraints

domain idle states defined for s2idle suspend.

**Setting QoS Constraints from User Space:**

Copy link
Copy Markdown

@ti-scaria ti-scaria Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we could also provide using exec command that Kevin mentioned for setting the constraints
"exec 4<>/dev/cpu_wakeup_latency; echo 0x3e8 >&4"

(e.g., "0x7ef41").

* **To force Deep Sleep mode**: Set constraint above Deep Sleep's exit latency (10ms = 10,000 μs)
but below RTC+DDR's exit latency (600ms = 600,000 μs). For example, use **520 μs (520,001 ns)**:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above the constraint compares with exit+entry


1. Registers a global CPU wakeup latency constraint
2. Causes the cpuidle governor to filter out any idle states with exit latency exceeding this value
3. Remains active as long as the file descriptor is open
Copy link
Copy Markdown

@ti-scaria ti-scaria Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two points should be highlighted a bit more since the constraints are only valid till the file is open and this is how we enable mode selection

#include <signal.h>

#define QOS_DEV "/dev/cpu_wakeup_latency"
#define LATENCY_VAL "0x1000" /* 4096 ns (4 μs) in hex */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latency value is in microseconds


**Calculation:**

- Target latency: 520 μs = 520,000 ns (round to 520,001 for convenience)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values here should be 520ms and 520000 us

Document the mode selection logic using the s2idle flow

Signed-off-by: Dhruva Gole <d-gole@ti.com>
Copy link
Copy Markdown
Contributor

@kwillis01 kwillis01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good, I think that the QoS Latency Constraints and Mode Selection section needs to be fixed up to flow better and be a little more condensed.

Comment on lines +409 to +411
This mapping ensures that when the Display (DSS0) is active, the system won't enter states that
would cause DDR Auto Self-Refresh issues. Similarly, active UART or USB connections prevent
deeper system states that would disconnect those interfaces.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nicer to move this block up to the "Hierarchical Structure" heading since it shows this there. However, this is also fine here, just felt like it might be extra info the user might not necessarily need.


.. note::
For complete Device Tree definitions including all latency parameters, refer to the platform's
device tree source files (e.g., ``k3-am62l-main.dtsi``).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this release its in k3-am62l3-evm-idle-states.dtso


**Setting QoS Constraints from User Space:**

Applications can constrain the system's low-power behavior by writing to the PM QoS device file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be specified that it is the PM QoS CPU wakeup latency file. Just because this sentence makes it sound like each device would have a PM QoS file, when its only for CPUs.

3. Only idle states with ``exit-latency-us`` ≤ constraint are considered
4. The deepest eligible state is selected

**Setting QoS Constraints from User Space:**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this section should be combined with the Example: Deep Sleep Mode Selection section. You're showing an example of how to set the QoS constraint without properly explaining it. Also by combining with the Example: Deep Sleep Mode Selection section you can make this into an example for just deepsleep

that the cpuidle governor correctly respects QoS constraints and selects the appropriate idle state
based on latency requirements.

**Selecting Specific Low-Power Modes:**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section should go after the How It Sets QoS Constraints: section since that is when the /dev/cpu_wakeup_latency is explained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants