From: Christian Loehle <christian.loehle@arm.com>
To: Xueqin Luo <luoxueqin@kylinos.cn>,
rafael@kernel.org, daniel.lezcano@kernel.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] cpuidle: teo: Do not return a disabled idle state
Date: Fri, 28 Aug 2026 16:49:02 +0100 [thread overview]
Message-ID: <d5f96d83-b5c4-4795-9675-7779f35be78f@arm.com> (raw)
In-Reply-To: <20260828032457.2317326-1-luoxueqin@kylinos.cn>
On 8/28/26 04:24, Xueqin Luo wrote:
> If idle state 0 is disabled and none of the enabled idle states satisfies
> the PM QoS latency constraint, constraint_idx in teo_select() stays at its
> initial value of 0, because the loop that updates it starts at state 1,
> and so the candidate state index is capped at state 0, which is disabled,
> and that state is returned to the caller.
>
> The cpuidle core does not validate the returned state index against the
> per-state disable flags, so the CPU ends up entering the disabled state 0.
>
> To address this, ensure that constraint_idx is at least equal to the index
> of the first enabled idle state (idx0), so that the candidate state is
> never capped to a disabled one.
>
> Fixes: c410a9a142f1 ("cpuidle: teo: Change the main idle state selection logic")
> Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
> ---
> v1 -> v2:
> - Instead of falling back to idx0 after the candidate index has been
> capped to a disabled state, ensure that constraint_idx is at least
> equal to idx0 before the capping check (suggested by Rafael J. Wysocki).
>
> drivers/cpuidle/governors/teo.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
> index ac43b9b013b3..906f4f89e365 100644
> --- a/drivers/cpuidle/governors/teo.c
> +++ b/drivers/cpuidle/governors/teo.c
> @@ -426,6 +426,17 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
> }
> }
>
> + /*
> + * If the latency constraint does not allow any of the enabled idle
> + * states to be used, the candidate state index will be capped to 0
> + * by the check below, but state 0 may be disabled. To prevent the
> + * selection of a disabled state in that case, ensure that
> + * constraint_idx is at least equal to the index of the first
> + * enabled idle state.
> + */
> + if (constraint_idx < idx0)
> + constraint_idx = idx0;
> +
> /*
> * If there is a latency constraint, it may be necessary to select an
> * idle state shallower than the current candidate one.
prev parent reply other threads:[~2026-08-28 15:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 3:24 [PATCH v2] cpuidle: teo: Do not return a disabled idle state Xueqin Luo
2026-08-28 15:49 ` Christian Loehle [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=d5f96d83-b5c4-4795-9675-7779f35be78f@arm.com \
--to=christian.loehle@arm.com \
--cc=daniel.lezcano@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=luoxueqin@kylinos.cn \
--cc=rafael@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