Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: d4f3388afd48 ("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>

+12 -2
+12 -2
drivers/cpufreq/cppc_cpufreq.c
··· 308 308 return 0; 309 309 } 310 310 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 + 311 321 /* 312 322 * The PCC subspace describes the rate at which platform can accept commands 313 323 * on the shared PCC channel (including READs which do not count towards freq ··· 340 330 return 10000; 341 331 } 342 332 } 343 - return cppc_get_transition_latency(cpu) / NSEC_PER_USEC; 333 + return __cppc_cpufreq_get_transition_delay_us(cpu); 344 334 } 345 335 #else 346 336 static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu) 347 337 { 348 - return cppc_get_transition_latency(cpu) / NSEC_PER_USEC; 338 + return __cppc_cpufreq_get_transition_delay_us(cpu); 349 339 } 350 340 #endif 351 341