mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kochidanadu, Scaria" <s-kochidanadu@ti.com>
To: "Kevin Hilman (TI)" <khilman@baylibre.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Sudeep Holla <sudeep.holla@kernel.org>,
	Ulf Hansson <ulfh@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Christian Loehle <christian.loehle@arm.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Cc: Maulik Shah <maulik.shah@oss.qualcomm.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-rt-devel@lists.linux.dev" <linux-rt-devel@lists.linux.dev>
Subject: Re: [EXTERNAL] [PATCH v2] cpuidle: psci: Allow domain idle states in s2idle for all CPU idle states
Date: Wed, 25 Nov 2026 07:05:30 +0000	[thread overview]
Message-ID: <3d3924f2-9fd0-4ca9-acc4-aa82bfb2f6e5@ti.com> (raw)
In-Reply-To: <20261117-topic-lpm-psci-domain-callbacks-v2-1-744884105846@baylibre.com>

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>
>


      reply	other threads:[~2026-11-25  7:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 23:58 Kevin Hilman (TI)
2026-11-25  7:05 ` Kochidanadu, Scaria [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d3924f2-9fd0-4ca9-acc4-aa82bfb2f6e5@ti.com \
    --to=s-kochidanadu@ti.com \
    --cc=bigeasy@linutronix.de \
    --cc=christian.loehle@arm.com \
    --cc=clrkwllms@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=lpieralisi@kernel.org \
    --cc=maulik.shah@oss.qualcomm.com \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sudeep.holla@kernel.org \
    --cc=ulfh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®