cpufreq: CPPC: Add support for frequency invariance's divide-by zero part

fix ampere cpu kernel warning:
cpufreg: cpufreg_online: ->get() failed
refer upstream 1eb5dde674 (cpufreq: CPPC: Add support for frequency invariance)
backport this commit's divide-by zero part

Signed-off-by: Huang Cun <cunhuang@tencent.com>
This commit is contained in:
Huang Cun 2024-06-18 17:22:27 +08:00
parent 4ad0c632c2
commit 37c2f83262
1 changed files with 4 additions and 4 deletions

View File

@ -382,12 +382,12 @@ static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu,
delta_delivered = get_delta(fb_ctrs_t1.delivered, delta_delivered = get_delta(fb_ctrs_t1.delivered,
fb_ctrs_t0.delivered); fb_ctrs_t0.delivered);
/* Check to avoid divide-by zero */ /* Check to avoid divide-by zero and invalid delivered_perf */
if (delta_reference || delta_delivered) if (!delta_reference || !delta_delivered)
delivered_perf = cpu->perf_ctrls.desired_perf;
else
delivered_perf = (reference_perf * delta_delivered) / delivered_perf = (reference_perf * delta_delivered) /
delta_reference; delta_reference;
else
delivered_perf = cpu->perf_ctrls.desired_perf;
return cppc_cpufreq_perf_to_khz(cpu, delivered_perf); return cppc_cpufreq_perf_to_khz(cpu, delivered_perf);
} }