cpufreq: intel_pstate: Use locking in intel_cpufreq_verify_policy()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 30 Dec 2016 14:57:11 +0000 (15:57 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 31 Dec 2016 20:48:43 +0000 (21:48 +0100)
Race conditions are possible if intel_cpufreq_verify_policy()
is executed in parallel with global limits updates from sysfs,
so the invocation of intel_pstate_update_perf_limits() in it
should be carried out under intel_pstate_limits_lock.

Make that happen.

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

index dc457ab..f8e514d 100644 (file)
@@ -2103,8 +2103,12 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy)
        if (per_cpu_limits)
                perf_limits = cpu->perf_limits;
 
+       mutex_lock(&intel_pstate_limits_lock);
+
        intel_pstate_update_perf_limits(policy, perf_limits);
 
+       mutex_unlock(&intel_pstate_limits_lock);
+
        return 0;
 }