cpufreq: intel_pstate: Free memory only when turning off
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 1 Sep 2020 16:33:41 +0000 (18:33 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 1 Sep 2020 19:14:52 +0000 (21:14 +0200)
commit55671ea3257ac596abd817c4031a996b2867e586
tree6ee954f462af2d48876aefee7e2eacbda84afe0b
parent4adcf2e5829f83cbab581ba376abb7cb6404eeb3
cpufreq: intel_pstate: Free memory only when turning off

When intel_pstate switches the operation mode from "active" to
"passive" or the other way around, freeing its data structures
representing CPUs and allocating them again from scratch is not
necessary and wasteful.  Moreover, if these data structures are
preserved, the cached HWP Request MSR value from there may be
written to the MSR to start with to reinitialize it and help to
restore the EPP value set previously (it is set to 0xFF when CPUs
go offline to allow their SMT siblings to use the full range of
EPP values and that also happens when the driver gets unregistered).

Accordingly, modify the driver to only do a full cleanup on driver
object registration errors and when its status is changed to "off"
via sysfs and to write the cached HWP Request MSR value back to
the MSR on CPU init if the data structure representing the given
CPU is still there.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
drivers/cpufreq/intel_pstate.c