hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I99VPY CVE: NA
--------------------------------
When hiboost is enabled, set the turbo+ profile to Steady fixed mode, and set the board-level power capping target value and failure action in bmc, if the current power capping is higher than the target power capping, BIOS will reduce the core/uncore frequency, the nominal_freq recorded by the kernel is equal to lowest_freq, then perf_to_khz conversion error, the return frequency will be fixed to nominal_freq.
Fix this by adding the branch processing logic where nominal_freq is equal to lowest_freq.
Fixes: ec1c7ad47664 ("cpufreq: CPPC: Fix performance/frequency conversion") Signed-off-by: liwei liwei728@huawei.com --- drivers/cpufreq/cppc_cpufreq.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 156ef2c40464..ecd2b192772f 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -109,8 +109,14 @@ static unsigned int cppc_cpufreq_perf_to_khz(struct cppc_cpudata *cpu_data, u64 mul, div;
if (caps->lowest_freq && caps->nominal_freq) { - mul = caps->nominal_freq - caps->lowest_freq; - div = caps->nominal_perf - caps->lowest_perf; + /* Avoid the special case when nominal_freq is equal to lowest_freq */ + if (caps->nominal_freq == caps->lowest_freq) { + mul = caps->nominal_freq; + div = caps->nominal_perf; + } else { + mul = caps->nominal_freq - caps->lowest_freq; + div = caps->nominal_perf - caps->lowest_perf; + } offset = caps->nominal_freq - div64_u64(caps->nominal_perf * mul, div); } else { if (!max_khz)