cpufreq: intel_pstate: Avoid transient updates of cpuinfo.max_freq
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 22 Mar 2017 23:00:47 +0000 (00:00 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 24 Mar 2017 02:04:32 +0000 (03:04 +0100)
commit80b120ca1a75c2df093d15936ab0591d90c99de9
treee90a305d114dc1efbc5bf197e958f94bb735208d
parentc5a2ee7dde893e0a06044e75c16711f08d5c011d
cpufreq: intel_pstate: Avoid transient updates of cpuinfo.max_freq

Both intel_pstate_verify_policy() and intel_cpufreq_verify_policy()
set policy->cpuinfo.max_freq depending on the turbo status, but the
updates made by them are discarded by the core, because the policy
object passed to them by the core is temporary and cpuinfo.max_freq
from that object is not copied to the final policy object in
cpufreq_set_policy().

However, cpufreq_set_policy() passes the temporary policy object
to the ->setpolicy callback of the driver, so intel_pstate_set_policy()
actually sees the policy->cpuinfo.max_freq value updated by
intel_pstate_verify_policy() and not the final one.  It also
updates policy->max sometimes which basically has no effect after
it returns, because the core discards that update.

To avoid confusion, eliminate policy->cpuinfo.max_freq updates from
intel_pstate_verify_policy() and intel_cpufreq_verify_policy()
entirely and check the maximum frequency explicitly in
intel_pstate_update_perf_limits() instead of relying on the
transiently updated policy->cpuinfo.max_freq value.

Moreover, move the max->policy adjustment carried out in
intel_pstate_set_policy() to a separate function and call that
function from the ->verify driver callbacks to ensure that it will
actually be effective.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/intel_pstate.c