* [PATCH v2] cpuidle: psci: Allow domain idle states in s2idle for all CPU idle states
@ 2026-11-17 23:58 Kevin Hilman (TI)
2026-11-25 7:05 ` [EXTERNAL] " Kochidanadu, Scaria
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Hilman (TI) @ 2026-11-17 23:58 UTC (permalink / raw)
To: Lorenzo Pieralisi, Sudeep Holla, Ulf Hansson, Rafael J. Wysocki,
Daniel Lezcano, Christian Loehle, Sebastian Andrzej Siewior,
Clark Williams, Steven Rostedt
Cc: Scaria Kochidanadu, Maulik Shah, linux-pm, linux-arm-kernel,
linux-kernel, linux-rt-devel
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@ti.com>
Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com>
---
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@oss.qualcomm.com
---
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@baylibre.com
---
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@baylibre.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [EXTERNAL] [PATCH v2] cpuidle: psci: Allow domain idle states in s2idle for all CPU idle states
2026-11-17 23:58 [PATCH v2] cpuidle: psci: Allow domain idle states in s2idle for all CPU idle states Kevin Hilman (TI)
@ 2026-11-25 7:05 ` Kochidanadu, Scaria
0 siblings, 0 replies; 2+ messages in thread
From: Kochidanadu, Scaria @ 2026-11-25 7:05 UTC (permalink / raw)
To: Kevin Hilman (TI),
Lorenzo Pieralisi, Sudeep Holla, Ulf Hansson, Rafael J. Wysocki,
Daniel Lezcano, Christian Loehle, Sebastian Andrzej Siewior,
Clark Williams, Steven Rostedt
Cc: Maulik Shah, linux-pm, linux-arm-kernel, linux-kernel, linux-rt-devel
On 18/11/26 05:28, Kevin Hilman (TI) wrote:
> 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
> ZjQcmQRYFpfptBannerStart
> This message was sent from outside of Texas Instruments.
> Do not click links or open attachments unless you recognize the source
> of this email and know the content is safe.
> Report Suspicious
> <https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK!tZdqXRfPtk07CuXMtzuI9tl5EvviUjT6mV4YIWcp0tAL5rKsp5Fd4sctdzKMpgQRp8G9YbL3wAnd-0reX52pcEh_zROV_CZnQSEliiH75mmnSv9TqAsxpJqa7bxfC00XI28$>
>
> ZjQcmQRYFpfptBannerEnd
> 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.
Is it necessarily true that domain idle states are always deeper than
the deepest CPU idle state?
Could we have a scenario where a cluster idle state is shallower than a
CPU idle state.
E.g. A CPU power-down having higher latency than a cluster idle state
only performing clock-gating.
Would such a states in the DT violate any PM-domain requirements?
> 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.
The cpuidle and genpd governor select a domain state considering the
next timer event and predicted idle duration.
This does not necessarily guarantee that the composite cluster state
selected is compatible with the CPU idle state
requested by the participating CPUs. Should'nt the firmware act as the
final arbitrator, rejecting composite states
that are inconsistent with the overall system state?
Thus I believe domain-aware callbacks could also be enabled for shallow
CPU state in the regular idle path.
Best, Scaria.
>
> Suggested-by: Scaria Kochidanadu <s-kochidanadu@ti.com>
> Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com>
> ---
> 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://urldefense.com/v3/__https://lore.kernel.org/r/20261005-s2idle_state-v1-0-3c402c66f388@oss.qualcomm.com__;!!G3vK!VmbWgOlTRXXMHnI-AYWfwdk8ta4ck3TOHMLRyY6i7ctqnEOUJH9mFK9vnH_TbF5tlbLob8Qa4bRM6FaIGg$
> ---
> 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://urldefense.com/v3/__https://patch.msgid.link/20260831-topic-lpm-psci-domain-callbacks-v1-1-4a47d95c9c79@baylibre.com__;!!G3vK!VmbWgOlTRXXMHnI-AYWfwdk8ta4ck3TOHMLRyY6i7ctqnEOUJH9mFK9vnH_TbF5tlbLob8Qa4bR41VJOfw$
> ---
> 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@baylibre.com>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 7:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 23:58 [PATCH v2] cpuidle: psci: Allow domain idle states in s2idle for all CPU idle states Kevin Hilman (TI)
2026-11-25 7:05 ` [EXTERNAL] " Kochidanadu, Scaria
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®