Skip to content

Commit f965d11

Browse files
committed
cpufreq: CPPC: Avoid using CPUFREQ_ETERNAL as transition delay
If cppc_get_transition_latency() returns CPUFREQ_ETERNAL to indicate a failure to retrieve the transition latency value from the platform firmware, the CPPC cpufreq driver will use that value (converted to microseconds) as the policy transition delay, but it is way too large for any practical use. Address this by making the driver use the cpufreq's default transition latency value (in microseconds) as the transition delay if CPUFREQ_ETERNAL is returned by cppc_get_transition_latency(). Fixes: d4f3388 ("cpufreq / CPPC: Set platform specific transition_delay_us") Cc: 5.19+ <stable@vger.kernel.org> # 5.19 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Reviewed-by: Jie Zhan <zhanjie9@hisilicon.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Qais Yousef <qyousef@layalina.io>
1 parent f97aef0 commit f965d11

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ static int cppc_verify_policy(struct cpufreq_policy_data *policy)
308308
return 0;
309309
}
310310

311+
static unsigned int __cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
312+
{
313+
unsigned int transition_latency_ns = cppc_get_transition_latency(cpu);
314+
315+
if (transition_latency_ns == CPUFREQ_ETERNAL)
316+
return CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS / NSEC_PER_USEC;
317+
318+
return transition_latency_ns / NSEC_PER_USEC;
319+
}
320+
311321
/*
312322
* The PCC subspace describes the rate at which platform can accept commands
313323
* on the shared PCC channel (including READs which do not count towards freq
@@ -330,12 +340,12 @@ static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
330340
return 10000;
331341
}
332342
}
333-
return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
343+
return __cppc_cpufreq_get_transition_delay_us(cpu);
334344
}
335345
#else
336346
static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
337347
{
338-
return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
348+
return __cppc_cpufreq_get_transition_delay_us(cpu);
339349
}
340350
#endif
341351

0 commit comments

Comments
 (0)