Commit be31d940 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull power management fixes from Rafael Wysocki:
 "These address two issues in the intel_pstate driver and one in the
  powernow-k8 cpufreq driver.

  Specifics:

   - Make the powernow-k8 cpufreq driver avoid calling
     cpufreq_cpu_get(), which theoretically may return NULL, to get a
     policy pointer that is known to it already (Colin Ian King)

   - Drop two functions that are not used any more from the intel_pstate
     driver (Lukas Bulwahn)

   - Make intel_pstate check the HWP capabilities to get the maximum
     available P-state in the passive mode to avoid using a stale value
     of it in case of out-of-band updates (Rafael Wysocki)"

* tag 'pm-5.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  cpufreq: intel_pstate: remove obsolete functions
  cpufreq: powernow-k8: pass policy rather than use cpufreq_cpu_get()
  cpufreq: intel_pstate: Use HWP capabilities in intel_cpufreq_adjust_perf()
parents 43d3d587 c4151604
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -76,11 +76,6 @@ static inline int ceiling_fp(int32_t x)
	return ret;
}

static inline int32_t percent_fp(int percent)
{
	return div_fp(percent, 100);
}

static inline u64 mul_ext_fp(u64 x, u64 y)
{
	return (x * y) >> EXT_FRAC_BITS;
@@ -91,11 +86,6 @@ static inline u64 div_ext_fp(u64 x, u64 y)
	return div64_u64(x << EXT_FRAC_BITS, y);
}

static inline int32_t percent_ext_fp(int percent)
{
	return div_ext_fp(percent, 100);
}

/**
 * struct sample -	Store performance sample
 * @core_avg_perf:	Ratio of APERF/MPERF which is the actual average
@@ -2653,12 +2643,13 @@ static void intel_cpufreq_adjust_perf(unsigned int cpunum,
				      unsigned long capacity)
{
	struct cpudata *cpu = all_cpu_data[cpunum];
	u64 hwp_cap = READ_ONCE(cpu->hwp_cap_cached);
	int old_pstate = cpu->pstate.current_pstate;
	int cap_pstate, min_pstate, max_pstate, target_pstate;

	update_turbo_state();
	cap_pstate = global.turbo_disabled ? cpu->pstate.max_pstate :
					     cpu->pstate.turbo_pstate;
	cap_pstate = global.turbo_disabled ? HWP_GUARANTEED_PERF(hwp_cap) :
					     HWP_HIGHEST_PERF(hwp_cap);

	/* Optimization: Avoid unnecessary divisions. */

+3 −6
Original line number Diff line number Diff line
@@ -878,9 +878,9 @@ static int get_transition_latency(struct powernow_k8_data *data)

/* Take a frequency, and issue the fid/vid transition command */
static int transition_frequency_fidvid(struct powernow_k8_data *data,
		unsigned int index)
		unsigned int index,
		struct cpufreq_policy *policy)
{
	struct cpufreq_policy *policy;
	u32 fid = 0;
	u32 vid = 0;
	int res;
@@ -912,9 +912,6 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,
	freqs.old = find_khz_freq_from_fid(data->currfid);
	freqs.new = find_khz_freq_from_fid(fid);

	policy = cpufreq_cpu_get(smp_processor_id());
	cpufreq_cpu_put(policy);

	cpufreq_freq_transition_begin(policy, &freqs);
	res = transition_fid_vid(data, fid, vid);
	cpufreq_freq_transition_end(policy, &freqs, res);
@@ -969,7 +966,7 @@ static long powernowk8_target_fn(void *arg)

	powernow_k8_acpi_pst_values(data, newstate);

	ret = transition_frequency_fidvid(data, newstate);
	ret = transition_frequency_fidvid(data, newstate, pol);

	if (ret) {
		pr_err("transition frequency failed\n");