cpufreq: Reject improper settings for userspace min/max limits

When userspace min/max limits are written to they are compared against
the aggregated max/min respectively. This can take system to a bad
state as follows:
1) Userspace client writes a max value that is lower than the
   original value.
2) A kernel client happens to hold a vote for max higher than the
   userspace max value, so that is what the policy->max is set to
   as part of cpufreq_set_policy(). But we still set user_policy->max
   to the value from step 1.
3) Userspace writes a min value that is higher than the max value it
   wrote before (in step 1). Since cpufreq_set_policy() compares it
   against policy->max the write is successful and user_policy->min
   is now higher than user_policy->max.
If all the CPUs in a policy go offline with this bad state, trying
to bring the first CPU online would fail since cpufreq_online()
starts with user_policy->min/max as the original limits.

To prevent this scenario, set the limits of the policy passed to
cpufreq_set_policy() to the latest userspace values so that any
inconsistent settings are rejected.

Change-Id: I5ad92ba05162cb5c32c3ba3fdae21d2e505493d3
Signed-off-by: Taniya Das <tdas@codeaurora.org>
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
1 file changed