Skip to content

Commit a755d0e

Browse files
qais-yousefrafaeljw
authored andcommitted
cpufreq: Honour transition_latency over transition_delay_us
Some platforms like Arm's Juno can have a high transition latency that can be larger than the 2ms cap introduced. If a driver reports a transition_latency that is higher than the cap, then use it as-is. Update comment s/10/2/ to reflect the new cap of 2ms. Reported-by: Pierre Gondois <[email protected]> Signed-off-by: Qais Yousef <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent d394abc commit a755d0e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,17 @@ unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy)
576576

577577
latency = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
578578
if (latency) {
579+
unsigned int max_delay_us = 2 * MSEC_PER_SEC;
580+
581+
/*
582+
* If the platform already has high transition_latency, use it
583+
* as-is.
584+
*/
585+
if (latency > max_delay_us)
586+
return latency;
587+
579588
/*
580-
* For platforms that can change the frequency very fast (< 10
589+
* For platforms that can change the frequency very fast (< 2
581590
* us), the above formula gives a decent transition delay. But
582591
* for platforms where transition_latency is in milliseconds, it
583592
* ends up giving unrealistic values.
@@ -586,7 +595,7 @@ unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy)
586595
* a reasonable amount of time after which we should reevaluate
587596
* the frequency.
588597
*/
589-
return min(latency * LATENCY_MULTIPLIER, (unsigned int)(2 * MSEC_PER_SEC));
598+
return min(latency * LATENCY_MULTIPLIER, max_delay_us);
590599
}
591600

592601
return LATENCY_MULTIPLIER;

0 commit comments

Comments
 (0)