Commit 75bdef20 authored by Lifeng Zheng's avatar Lifeng Zheng
Browse files

cpufreq: CPPC: Fix wrong max_freq in policy initialization

mainline inclusion
from mainline-v6.7-rc5
commit 03d8b4e76266e11662c5e544854b737843173e2d
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBQYEH
CVE: NA

Reference: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=03d8b4e76266e11662c5e544854b737843173e2d



---------------------------------------------------------------------

In policy initialization, policy->max and policy->cpuinfo.max_freq are
always set to the value calculated from caps->nominal_perf.

This will cause the frequency stay on base frequency even if the policy
is already boosted when a CPU is going online.

Fix this by using policy->boost_enabled to determine which value should
be set.

Signed-off-by: default avatarLifeng Zheng <zhenglifeng1@huawei.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Link: https://patch.msgid.link/20250117101457.1530653-4-zhenglifeng1@huawei.com


[ rjw: Changelog edits ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarXinghai Cen <cenxinghai@h-partners.com>
parent 3853c737
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -638,7 +638,8 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
	 * Section 8.4.7.1.1.5 of ACPI 6.1 spec)
	 */
	policy->min = cppc_perf_to_khz(caps, caps->lowest_nonlinear_perf);
	policy->max = cppc_perf_to_khz(caps, caps->nominal_perf);
	policy->max = cppc_perf_to_khz(caps, policy->boost_enabled ?
						caps->highest_perf : caps->nominal_perf);

	/*
	 * Set cpuinfo.min_freq to Lowest to make the full range of performance
@@ -646,7 +647,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
	 * nonlinear perf
	 */
	policy->cpuinfo.min_freq = cppc_perf_to_khz(caps, caps->lowest_perf);
	policy->cpuinfo.max_freq = cppc_perf_to_khz(caps, caps->nominal_perf);
	policy->cpuinfo.max_freq = policy->max;

	policy->transition_delay_us = cppc_cpufreq_get_transition_delay_us(cpu);
	policy->shared_type = cpu_data->shared_type;