drivers/cpufreq/cppc_cpufreq.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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>
---
drivers/cpufreq/cppc_cpufreq.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -308,6 +308,16 @@ static int cppc_verify_policy(struct cpu
return 0;
}
+static unsigned int get_transition_latency_from_cppc(unsigned int cpu)
+{
+ unsigned int transition_latency_ns = cppc_get_transition_latency(cpu);
+
+ if (transition_latency_ns == CPUFREQ_ETERNAL)
+ return CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS / NSEC_PER_USEC;
+
+ return transition_latency_ns / NSEC_PER_USEC;
+}
+
/*
* The PCC subspace describes the rate at which platform can accept commands
* on the shared PCC channel (including READs which do not count towards freq
@@ -330,12 +340,12 @@ static unsigned int cppc_cpufreq_get_tra
return 10000;
}
}
- return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+ return get_transition_latency_from_cppc(cpu);
}
#else
static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
{
- return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+ return get_transition_latency_from_cppc(cpu);
}
#endif
On 9/25/2025 11:44 PM, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > 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> > --- > drivers/cpufreq/cppc_cpufreq.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -308,6 +308,16 @@ static int cppc_verify_policy(struct cpu > return 0; > } > > +static unsigned int get_transition_latency_from_cppc(unsigned int cpu) Minor bit: Can we name it as __cppc_cpufreq_get_transition_delay_us() because: 1. 'get_xxx' naming looks a bit different from other funcs in cppc_cpufreq.c 2. This is actually the main routine of cppc_cpufreq_get_transition_delay_us(). It's factored out just for the qualcomm workaround. > +{ > + unsigned int transition_latency_ns = cppc_get_transition_latency(cpu); > + > + if (transition_latency_ns == CPUFREQ_ETERNAL) > + return CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS / NSEC_PER_USEC; > + > + return transition_latency_ns / NSEC_PER_USEC; > +} > + > /* > * The PCC subspace describes the rate at which platform can accept commands > * on the shared PCC channel (including READs which do not count towards freq > @@ -330,12 +340,12 @@ static unsigned int cppc_cpufreq_get_tra > return 10000; > } > } > - return cppc_get_transition_latency(cpu) / NSEC_PER_USEC; > + return get_transition_latency_from_cppc(cpu); > } > #else > static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu) > { > - return cppc_get_transition_latency(cpu) / NSEC_PER_USEC; > + return get_transition_latency_from_cppc(cpu); > } > #endif >
On 9/25/2025 10:44 AM, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > 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>> --- > drivers/cpufreq/cppc_cpufreq.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -308,6 +308,16 @@ static int cppc_verify_policy(struct cpu > return 0; > } > > +static unsigned int get_transition_latency_from_cppc(unsigned int cpu) > +{ > + unsigned int transition_latency_ns = cppc_get_transition_latency(cpu); > + > + if (transition_latency_ns == CPUFREQ_ETERNAL) > + return CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS / NSEC_PER_USEC; > + > + return transition_latency_ns / NSEC_PER_USEC; > +} > + > /* > * The PCC subspace describes the rate at which platform can accept commands > * on the shared PCC channel (including READs which do not count towards freq > @@ -330,12 +340,12 @@ static unsigned int cppc_cpufreq_get_tra > return 10000; > } > } > - return cppc_get_transition_latency(cpu) / NSEC_PER_USEC; > + return get_transition_latency_from_cppc(cpu); > } > #else > static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu) > { > - return cppc_get_transition_latency(cpu) / NSEC_PER_USEC; > + return get_transition_latency_from_cppc(cpu); > } > #endif > > > >
© 2016 - 2025 Red Hat, Inc.