Re: [PATCH] cpufreq: Change default transition delay to 2ms

From: Qais Yousef
Date: Fri Feb 23 2024 - 08:27:49 EST


On 02/23/24 10:48, Pierre Gondois wrote:

> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index 66cef33c4ec7..668263c53810 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -576,8 +576,17 @@ unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy)
> > latency = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
> > if (latency) {
> > + unsigned int max_delay_us = 2 * MSEC_PER_SEC;;
> > +
> > + /*
> > + * If the platform already has high transition_latency, use it
> > + * as-is.
> > + */
> > + if (latency > max_delay_us)
> > + return latency;
> > +
> > /*
> > - * For platforms that can change the frequency very fast (< 10
> > + * For platforms that can change the frequency very fast (< 20
>
> I think it should be 10->2us as we do:
> min(latency * 1000, 2ms)

Yeah I meant 2, that was a typo

Thanks

-->8--

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 66cef33c4ec7..de92a9912587 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -576,8 +576,17 @@ unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy)

latency = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
if (latency) {
+ unsigned int max_delay_us = 2 * MSEC_PER_SEC;;
+
+ /*
+ * If the platform already has high transition_latency, use it
+ * as-is.
+ */
+ if (latency > max_delay_us)
+ return latency;
+
/*
- * For platforms that can change the frequency very fast (< 10
+ * For platforms that can change the frequency very fast (< 2
* us), the above formula gives a decent transition delay. But
* for platforms where transition_latency is in milliseconds, it
* ends up giving unrealistic values.
@@ -586,7 +595,7 @@ unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy)
* a reasonable amount of time after which we should reevaluate
* the frequency.
*/
- return min(latency * LATENCY_MULTIPLIER, (unsigned int)(2 * MSEC_PER_SEC));
+ return min(latency * LATENCY_MULTIPLIER, max_delay_us);
}

return LATENCY_MULTIPLIER;