Skip to content

Commit 81c5d23

Browse files
rafaeljwgregkh
authored andcommitted
cpufreq: Make drivers using CPUFREQ_ETERNAL specify transition latency
[ Upstream commit f97aef0 ] Commit a755d0e ("cpufreq: Honour transition_latency over transition_delay_us") caused platforms where cpuinfo.transition_latency is CPUFREQ_ETERNAL to get a very large transition latency whereas previously it had been capped at 10 ms (and later at 2 ms). This led to a user-observable regression between 6.6 and 6.12 as described by Shawn: "The dbs sampling_rate was 10000 us on 6.6 and suddently becomes 6442450 us (4294967295 / 1000 * 1.5) on 6.12 for these platforms because the default transition delay was dropped [...]. It slows down dbs governor's reacting to CPU loading change dramatically. Also, as transition_delay_us is used by schedutil governor as rate_limit_us, it shows a negative impact on device idle power consumption, because the device gets slightly less time in the lowest OPP." Evidently, the expectation of the drivers using CPUFREQ_ETERNAL as cpuinfo.transition_latency was that it would be capped by the core, but they may as well return a default transition latency value instead of CPUFREQ_ETERNAL and the core need not do anything with it. Accordingly, introduce CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS and make all of the drivers in question use it instead of CPUFREQ_ETERNAL. Also update the related Rust binding. Fixes: a755d0e ("cpufreq: Honour transition_latency over transition_delay_us") Closes: https://lore.kernel.org/linux-pm/[email protected]/ Reported-by: Shawn Guo <[email protected]> Reviewed-by: Mario Limonciello (AMD) <[email protected]> Reviewed-by: Jie Zhan <[email protected]> Acked-by: Viresh Kumar <[email protected]> Cc: 6.6+ <[email protected]> # 6.6+ Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected] [ rjw: Fix typo in new symbol name, drop redundant type cast from Rust binding ] Tested-by: Shawn Guo <[email protected]> # with cpufreq-dt driver Reviewed-by: Qais Yousef <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> [ omitted Rust changes ] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 820cfae commit 81c5d23

File tree

7 files changed

+9
-6
lines changed

7 files changed

+9
-6
lines changed

drivers/cpufreq/cpufreq-dt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
110110

111111
transition_latency = dev_pm_opp_get_max_transition_latency(cpu_dev);
112112
if (!transition_latency)
113-
transition_latency = CPUFREQ_ETERNAL;
113+
transition_latency = CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS;
114114

115115
cpumask_copy(policy->cpus, priv->cpus);
116116
policy->driver_data = priv;

drivers/cpufreq/imx6q-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
443443
}
444444

445445
if (of_property_read_u32(np, "clock-latency", &transition_latency))
446-
transition_latency = CPUFREQ_ETERNAL;
446+
transition_latency = CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS;
447447

448448
/*
449449
* Calculate the ramp time for max voltage change in the

drivers/cpufreq/mediatek-cpufreq-hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int mtk_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
238238

239239
latency = readl_relaxed(data->reg_bases[REG_FREQ_LATENCY]) * 1000;
240240
if (!latency)
241-
latency = CPUFREQ_ETERNAL;
241+
latency = CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS;
242242

243243
policy->cpuinfo.transition_latency = latency;
244244
policy->fast_switch_possible = true;

drivers/cpufreq/scmi-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
280280

281281
latency = perf_ops->transition_latency_get(ph, domain);
282282
if (!latency)
283-
latency = CPUFREQ_ETERNAL;
283+
latency = CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS;
284284

285285
policy->cpuinfo.transition_latency = latency;
286286

drivers/cpufreq/scpi-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static int scpi_cpufreq_init(struct cpufreq_policy *policy)
157157

158158
latency = scpi_ops->get_transition_latency(cpu_dev);
159159
if (!latency)
160-
latency = CPUFREQ_ETERNAL;
160+
latency = CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS;
161161

162162
policy->cpuinfo.transition_latency = latency;
163163

drivers/cpufreq/spear-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev)
183183

184184
if (of_property_read_u32(np, "clock-latency",
185185
&spear_cpufreq.transition_latency))
186-
spear_cpufreq.transition_latency = CPUFREQ_ETERNAL;
186+
spear_cpufreq.transition_latency = CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS;
187187

188188
cnt = of_property_count_u32_elems(np, "cpufreq_tbl");
189189
if (cnt <= 0) {

include/linux/cpufreq.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
*/
3333

3434
#define CPUFREQ_ETERNAL (-1)
35+
36+
#define CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS NSEC_PER_MSEC
37+
3538
#define CPUFREQ_NAME_LEN 16
3639
/* Print length for names. Extra 1 space for accommodating '\n' in prints */
3740
#define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1)

0 commit comments

Comments
 (0)