Power management fixes for 5.11-rc3

- 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).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAl/4mQYSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxOuIP/R5nqQyyeG4N2wLvGgr1HgrMWAJ4dyy2
 KywFv/JqC1SyU5LXstYqlhskTFP/RoLJShrh1pqp8sqEloDBCpaPpuGMOPO5r/qE
 H0vall70wFKLhdNwEVDGlURZdGUAN0lCDDpvsDbzdsnmQ22yWIHZxsoHcfaYI7Ry
 E+j0LlUSt0otxFh+910nlORdU5yuQTFc1oz3YuBLE9zgMh34UXMY2seZtiKK9EWW
 4+Gx2Qu/TG8Y9UpBSs6VovrP3pU95aW+NHNYYUv90whA7WGx1GcyvDxNlHMISimu
 DBByMGa4Lnrs80nlh0XoEcvpjoUOckFNXku33e/XGCKxvaXudQ/vVGq1Nl0M8deG
 nE9o2aGXIPwujzD9bWmXwozt1T174+7RzYo//y1GYJqw6r/6/3VTe56hSqfTMqiw
 SY0h+oS8O8SwNlT5BH7O0YU6j7rWqomFvCPOe5blMFpgKOP/UAXY/Zcf4AFy45dR
 szvtVSpDav9KTA5iEQ+/GUJfRl/kjONwWfi7q/PkupHkMFpY9fjCkNSPumZR2AiB
 if6Taj9bK/ihHLsQddgbOIHoIkrcf1Op+odonE5T+R+7lkwT4KG0nF8+8rbQl8ao
 SdNl0AWbL7pka23c1YbXPKIILfEwQbWicIj9sNDn3mqpQMjxjN+wcAqCSCUFpLz5
 QVwKW2LjOugj
 =rOzW
 -----END PGP SIGNATURE-----

Merge tag 'pm-5.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

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()
This commit is contained in:
Linus Torvalds 2021-01-08 15:39:25 -08:00
commit be31d940b3
2 changed files with 6 additions and 18 deletions

View File

@ -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. */

View File

@ -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");