Commit 23203ed2 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branch 'pm-cpufreq'

Merge cpufreq fixes for 6.15-rc5:

 - Fix a recent regression causing systems where frequency tables are
   used by cpufreq to have issues with setting frequency limits (Rafael
   Wysocki).

 - Fix a recent regressions causing frequency boost settings to become
   out-of-sync if platform firmware updates the registers associated
   with them during system resume (Viresh Kumar).

 - Fix an unchecked MSR aceess in the intel_pstate driver occurring when
   CPUID indicates no turbo, but the driver attempts to enable turbo
   frequencies due to a misleading value read from an MSR (Srinivas
   Pandruvada).

* pm-cpufreq:
  cpufreq: intel_pstate: Unchecked MSR aceess in legacy mode
  cpufreq: Fix setting policy limits when frequency tables are used
  cpufreq: ACPI: Re-sync CPU boost state on system resume
parents 533a8a67 ac4e04d9
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -909,8 +909,19 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
	if (perf->states[0].core_frequency * 1000 != freq_table[0].frequency)
		pr_warn(FW_WARN "P-state 0 is not max freq\n");

	if (acpi_cpufreq_driver.set_boost)
	if (acpi_cpufreq_driver.set_boost) {
		if (policy->boost_supported) {
			/*
			 * The firmware may have altered boost state while the
			 * CPU was offline (for example during a suspend-resume
			 * cycle).
			 */
			if (policy->boost_enabled != boost_state(cpu))
				set_boost(policy, policy->boost_enabled);
		} else {
			policy->boost_supported = true;
		}
	}

	return result;

+14 −8
Original line number Diff line number Diff line
@@ -536,14 +536,18 @@ void cpufreq_disable_fast_switch(struct cpufreq_policy *policy)
EXPORT_SYMBOL_GPL(cpufreq_disable_fast_switch);

static unsigned int __resolve_freq(struct cpufreq_policy *policy,
		unsigned int target_freq, unsigned int relation)
				   unsigned int target_freq,
				   unsigned int min, unsigned int max,
				   unsigned int relation)
{
	unsigned int idx;

	target_freq = clamp_val(target_freq, min, max);

	if (!policy->freq_table)
		return target_freq;

	idx = cpufreq_frequency_table_target(policy, target_freq, relation);
	idx = cpufreq_frequency_table_target(policy, target_freq, min, max, relation);
	policy->cached_resolved_idx = idx;
	policy->cached_target_freq = target_freq;
	return policy->freq_table[idx].frequency;
@@ -577,8 +581,7 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
	if (unlikely(min > max))
		min = max;

	return __resolve_freq(policy, clamp_val(target_freq, min, max),
			      CPUFREQ_RELATION_LE);
	return __resolve_freq(policy, target_freq, min, max, CPUFREQ_RELATION_LE);
}
EXPORT_SYMBOL_GPL(cpufreq_driver_resolve_freq);

@@ -2397,8 +2400,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
	if (cpufreq_disabled())
		return -ENODEV;

	target_freq = clamp_val(target_freq, policy->min, policy->max);
	target_freq = __resolve_freq(policy, target_freq, relation);
	target_freq = __resolve_freq(policy, target_freq, policy->min,
				     policy->max, relation);

	pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
		 policy->cpu, target_freq, relation, old_target_freq);
@@ -2727,8 +2730,11 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
	 * compiler optimizations around them because they may be accessed
	 * concurrently by cpufreq_driver_resolve_freq() during the update.
	 */
	WRITE_ONCE(policy->max, __resolve_freq(policy, new_data.max, CPUFREQ_RELATION_H));
	new_data.min = __resolve_freq(policy, new_data.min, CPUFREQ_RELATION_L);
	WRITE_ONCE(policy->max, __resolve_freq(policy, new_data.max,
					       new_data.min, new_data.max,
					       CPUFREQ_RELATION_H));
	new_data.min = __resolve_freq(policy, new_data.min, new_data.min,
				      new_data.max, CPUFREQ_RELATION_L);
	WRITE_ONCE(policy->min, new_data.min > policy->max ? policy->max : new_data.min);

	trace_cpu_frequency_limits(policy);
+2 −1
Original line number Diff line number Diff line
@@ -76,7 +76,8 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy,
		return freq_next;
	}

	index = cpufreq_frequency_table_target(policy, freq_next, relation);
	index = cpufreq_frequency_table_target(policy, freq_next, policy->min,
					       policy->max, relation);
	freq_req = freq_table[index].frequency;
	freq_reduc = freq_req * od_tuners->powersave_bias / 1000;
	freq_avg = freq_req - freq_reduc;
+3 −3
Original line number Diff line number Diff line
@@ -115,8 +115,8 @@ int cpufreq_generic_frequency_table_verify(struct cpufreq_policy_data *policy)
EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify);

int cpufreq_table_index_unsorted(struct cpufreq_policy *policy,
				 unsigned int target_freq,
				 unsigned int relation)
				 unsigned int target_freq, unsigned int min,
				 unsigned int max, unsigned int relation)
{
	struct cpufreq_frequency_table optimal = {
		.driver_data = ~0,
@@ -147,7 +147,7 @@ int cpufreq_table_index_unsorted(struct cpufreq_policy *policy,
	cpufreq_for_each_valid_entry_idx(pos, table, i) {
		freq = pos->frequency;

		if ((freq < policy->min) || (freq > policy->max))
		if (freq < min || freq > max)
			continue;
		if (freq == target_freq) {
			optimal.driver_data = i;
+3 −0
Original line number Diff line number Diff line
@@ -598,6 +598,9 @@ static bool turbo_is_disabled(void)
{
	u64 misc_en;

	if (!cpu_feature_enabled(X86_FEATURE_IDA))
		return true;

	rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);

	return !!(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE);
Loading