[PATCH v2] cpuidle: psci: Allow domain idle states in s2idle for all CPU idle states

From: Kevin Hilman (TI)

Date: Tue Nov 17 2026 - 18:58:56 EST


Currently, only the deepest CPU idle state has its ->enter_s2idle()
callback set to the domain-aware psci_enter_s2idle_domain_idle_state().
The other CPU idle states use psci_enter_idle_state(), which bypasses
the PM domain entirely.

During s2idle, the CPU idle state is selected by find_deepest_state(),
constrained by the CPU wakeup latency QoS limit. If that limit excludes
the deepest CPU idle state, a shallower state is selected, and the CPU
PM domain hierarchy is never powered off. As a result, no domain idle
state can be entered, even if some of them are within the QoS limit.

Fix this by assigning the domain-aware ->enter_s2idle() callback to all
CPU idle states, except WFI. This is safe for s2idle because:

- The genpd governor selects the domain idle state in
cpu_system_power_down_ok(), using the same CPU wakeup latency QoS
limit that constrains the CPU idle state selection, or a stricter
one if a device in the domain has a system-wide resume latency
constraint.

- There is no idle duration prediction involved in s2idle. Both the
CPU idle state and the domain idle state are simply the deepest ones
allowed by the QoS limit, so the genpd governor can't override a
decision made by the cpuidle governor.

The domain idle state's arm,psci-suspend-param is a composite state that
overrides the CPU idle state, so the exit latency of the domain idle
state must account for the complete composite state.

The regular idle path is left unchanged, so only the deepest CPU idle
state can trigger the selection of a domain idle state, as the domain
idle states are assumed to be deeper than the deepest CPU idle state.
Extending this to the shallower CPU idle states isn't safe. The cpuidle
governor may select a shallower CPU idle state, based on its predicted
idle duration. The genpd governor isn't aware of that, as it only
considers the next timer event, so it could select a domain idle state
that overrides the shallower CPU idle state with a deeper composite
state.

Suggested-by: Scaria Kochidanadu <s-kochidanadu@xxxxxx>
Signed-off-by: Kevin Hilman (TI) <khilman@xxxxxxxxxxxx>
---
v1 assigned the domain-aware callbacks to all CPU idle states, for both
the regular idle path and s2idle. As pointed out by Ulf, that breaks
the current contract with genpd for the regular idle path, since the
genpd governor isn't aware of the CPU idle state selected by the
cpuidle governor.

As discussed with Ulf at LPC, this v2 takes an initial step by limiting
the change to s2idle, where both the CPU idle state and the domain idle
state are selected based only on the CPU wakeup latency QoS limit.

This pairs well with Maulik's series [1] adding support for domain idle
states that are only allowed during system suspend (system-state). Along
with this patch, platforms can describe several s2idle-only domain idle
states, and select between them via the CPU wakeup latency QoS limit,
even when that limit excludes the deepest CPU idle state. There is no
build or runtime dependency between the two series though.

[1] https://lore.kernel.org/r/20261005-s2idle_state-v1-0-3c402c66f388@xxxxxxxxxxxxxxxx
---
Changes in v2:
- Limit the change to s2idle; keep the regular idle path using the
domain-aware callback only for the deepest CPU idle state (Ulf)
- Reword commit message, fix incorrect claim that no other CPU idle
state has ->enter_s2idle() set
- Link to v1: https://patch.msgid.link/20260831-topic-lpm-psci-domain-callbacks-v1-1-4a47d95c9c79@xxxxxxxxxxxx
---
drivers/cpuidle/cpuidle-psci.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
index 0187d6a9096a..01a571479e5c 100644
--- a/drivers/cpuidle/cpuidle-psci.c
+++ b/drivers/cpuidle/cpuidle-psci.c
@@ -250,6 +250,8 @@ static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv,
struct psci_cpuidle_data *data,
unsigned int state_count, int cpu)
{
+ int i;
+
/* Currently limit the hierarchical topology to be used in OSI mode. */
if (!psci_has_osi_support())
return 0;
@@ -261,12 +263,21 @@ static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv,
psci_cpuidle_use_syscore = true;

/*
- * Using the deepest state for the CPU to trigger a potential selection
- * of a shared state for the domain, assumes the domain states are all
- * deeper states. On PREEMPT_RT the hierarchical topology is limited to
- * s2ram and s2idle.
+ * For s2idle, use the domain-aware callback for all CPU idle states
+ * except WFI. The CPU idle state is selected by find_deepest_state()
+ * and the domain idle state by the genpd governor, both constrained
+ * by the same CPU wakeup latency QoS limit. Hence, if the deepest CPU
+ * idle state is excluded by the QoS limit, the domain may still enter
+ * a domain idle state that fits the limit.
+ *
+ * For the regular idle path, only use the deepest CPU idle state to
+ * trigger a potential selection of a shared state for the domain, as
+ * the domain states are assumed to be deeper states. On PREEMPT_RT
+ * the hierarchical topology is limited to s2ram and s2idle.
*/
- drv->states[state_count - 1].enter_s2idle = psci_enter_s2idle_domain_idle_state;
+ for (i = 1; i < state_count; i++)
+ drv->states[i].enter_s2idle = psci_enter_s2idle_domain_idle_state;
+
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
drv->states[state_count - 1].enter = psci_enter_domain_idle_state;


---
base-commit: bc71431221f5ba8bb33918399552636e059c2c45
change-id: 20260831-topic-lpm-psci-domain-callbacks-a8af0cd7df35

Best regards,
--
Kevin Hilman (TI) <khilman@xxxxxxxxxxxx>