Commit c1f9e33a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Jia, Yingbao
Browse files

cpufreq: intel_pstate: Update the maximum CPU frequency consistently

mainline inclusion
from mainline-v6.10
commit e8217b4bece379e66d43ab5070431712f07bf625
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/IB6QC4
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e8217b4bece379e66d43ab5070431712f07bf625



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

Intel-SIG: commit e8217b4bece3 cpufreq: intel_pstate: Update the maximum CPU frequency consistently.
Backport intel_pstate driver update for 6.6 from 6.11

There are 3 places at which the maximum CPU frequency may change,
store_no_turbo(), intel_pstate_update_limits() (when called by the
cpufreq core) and intel_pstate_notify_work() (when handling a HWP
change notification).  Currently, cpuinfo.max_freq is only updated by
store_no_turbo() and intel_pstate_notify_work(), although it principle
it may be necessary to update it in intel_pstate_update_limits() either.

Make all of them mutually consistent.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ Yingbao Jia: amend commit log ]
Signed-off-by: default avatarYingbao Jia <yingbao.jia@intel.com>
parent 139ff713
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -1149,18 +1149,32 @@ static void intel_pstate_update_policies(void)
static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
					   struct cpufreq_policy *policy)
{
	intel_pstate_get_hwp_cap(cpudata);

	policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
			cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;

	refresh_frequency_limits(policy);
}

static void intel_pstate_update_limits(unsigned int cpu)
{
	mutex_lock(&intel_pstate_driver_lock);
	struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);

	cpufreq_update_policy(cpu);
	if (!policy)
		return;

	mutex_unlock(&intel_pstate_driver_lock);
	__intel_pstate_update_max_freq(all_cpu_data[cpu], policy);

	cpufreq_cpu_release(policy);
}

static void intel_pstate_update_limits_for_all(void)
{
	int cpu;

	for_each_possible_cpu(cpu)
		intel_pstate_update_limits(cpu);
}

/************************** sysfs begin ************************/
@@ -1307,7 +1321,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,

	mutex_unlock(&intel_pstate_limits_lock);

	intel_pstate_update_policies();
	intel_pstate_update_limits_for_all();
	arch_set_max_freq_ratio(no_turbo);

unlock_driver:
@@ -1591,7 +1605,6 @@ static void intel_pstate_notify_work(struct work_struct *work)
	struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpudata->cpu);

	if (policy) {
		intel_pstate_get_hwp_cap(cpudata);
		__intel_pstate_update_max_freq(cpudata, policy);

		cpufreq_cpu_release(policy);