From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
To: Val Packett <val@packett.cool>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Christian Loehle <christian.loehle@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpuidle: warn and fixup on sanity check instead of rejecting the driver
Date: Fri, 21 Nov 2025 15:16:34 +0200 [thread overview]
Message-ID: <efe52356123168be06811abd08a99f65d6980baa.camel@linux.intel.com> (raw)
In-Reply-To: <20251121010756.6687-1-val@packett.cool>
On Thu, 2025-11-20 at 22:06 -0300, Val Packett wrote:
> On Device Tree platforms, the latency and target residency values come
> directly from device trees, which are numerous and weren't all written
> with cpuidle invariants in mind. For example, qcom/hamoa.dtsi currently
> trips this check: exit latency 680000 > residency 600000.
>
> Instead of harshly rejecting the entire cpuidle driver with a mysterious
> error message, print a warning and set the target residency value to be
> equal to the exit latency.
>
> Fixes: 76934e495cdc ("cpuidle: Add sanity check for exit latency and target residency")
> Signed-off-by: Val Packett <val@packett.cool>
> ---
> drivers/cpuidle/driver.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
> index 1c295a93d582..06aeb59c1017 100644
> --- a/drivers/cpuidle/driver.c
> +++ b/drivers/cpuidle/driver.c
> @@ -199,8 +199,11 @@ static int __cpuidle_driver_init(struct cpuidle_driver *drv)
> * exceed its target residency which is assumed in cpuidle in
> * multiple places.
> */
> - if (s->exit_latency_ns > s->target_residency_ns)
> - return -EINVAL;
> + if (s->exit_latency_ns > s->target_residency_ns) {
> + pr_warn("cpuidle: state %d: exit latency %lld > residency %lld (fixing)\n",
> + i, s->exit_latency_ns, s->target_residency_ns);
> + s->target_residency_ns = s->exit_latency_ns;
> + }
> }
Ideally, in a perfect world, driver.c should verify input data and
reject bad input, rather than correct bad input.
So ideally, if there is an idle driver between DT and driver.c (like
intel_idle.c in case of Intel), that would be its job to correct DT
data.
But I'm not familiar with DT platforms, so I don't know if there is a
driver/piece of SW between DT parsing and driver.c that could handle
this correction at an earlier stage.
The reason I think this patch is not ideal is because it changes the
input data at the core framework level, and in theory the change may be
surprising to users. In general, sometimes rejecting bluntly is better
than correcting in a possibly unexpected way.
Artem.
next prev parent reply other threads:[~2025-11-21 13:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 1:06 [PATCH] cpuidle: warn and fixup on sanity check instead of rejecting the driver Val Packett
2025-11-21 13:10 ` Rafael J. Wysocki
2025-11-25 16:23 ` [PATCH v1] cpuidle: Warn instead of bailing out if target residency check fails Rafael J. Wysocki
2025-11-25 16:50 ` Christian Loehle
2025-11-26 5:29 ` Val Packett
2025-11-21 13:16 ` Artem Bityutskiy [this message]
2025-11-21 13:23 ` [PATCH] cpuidle: warn and fixup on sanity check instead of rejecting the driver Rafael J. Wysocki
2025-11-21 14:50 ` Konrad Dybcio
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=efe52356123168be06811abd08a99f65d6980baa.camel@linux.intel.com \
--to=artem.bityutskiy@linux.intel.com \
--cc=christian.loehle@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=val@packett.cool \
/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;
as well as URLs for NNTP newsgroup(s).