aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2016-02-11 07:01:13 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-03-09 08:41:01 -0500
commit99522fe6788f5bf627dce7c20ed9484c933511a3 (patch)
tree55353e0c03780e911cf855135f32f02565fd9603 /drivers/cpufreq/cpufreq.c
parent49f18560f8bac5315047edfb673dd13d56cbcbc9 (diff)
cpufreq: Remove cpufreq_governor_lock
We used to drop policy->rwsem just before calling __cpufreq_governor() in some cases earlier and so it was possible that __cpufreq_governor() ran concurrently via separate threads for the same policy. In order to guarantee valid state transitions for governors, 'governor_enabled' was required to be protected using some locking and cpufreq_governor_lock was added for that. But now __cpufreq_governor() is always called under policy->rwsem, and 'governor_enabled' is protected against races even without cpufreq_governor_lock. Get rid of the extra lock now. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Tested-by: Juri Lelli <juri.lelli@arm.com> Tested-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> [ rjw : Changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c8
1 files changed, 0 insertions, 8 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 692876892457..bc93272b4a12 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -147,8 +147,6 @@ void cpufreq_update_util(u64 time, unsigned long util, unsigned long max)
147 rcu_read_unlock(); 147 rcu_read_unlock();
148} 148}
149 149
150DEFINE_MUTEX(cpufreq_governor_lock);
151
152/* Flag to suspend/resume CPUFreq governors */ 150/* Flag to suspend/resume CPUFreq governors */
153static bool cpufreq_suspended; 151static bool cpufreq_suspended;
154 152
@@ -2015,11 +2013,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
2015 2013
2016 pr_debug("%s: for CPU %u, event %u\n", __func__, policy->cpu, event); 2014 pr_debug("%s: for CPU %u, event %u\n", __func__, policy->cpu, event);
2017 2015
2018 mutex_lock(&cpufreq_governor_lock);
2019 if ((policy->governor_enabled && event == CPUFREQ_GOV_START) 2016 if ((policy->governor_enabled && event == CPUFREQ_GOV_START)
2020 || (!policy->governor_enabled 2017 || (!policy->governor_enabled
2021 && (event == CPUFREQ_GOV_LIMITS || event == CPUFREQ_GOV_STOP))) { 2018 && (event == CPUFREQ_GOV_LIMITS || event == CPUFREQ_GOV_STOP))) {
2022 mutex_unlock(&cpufreq_governor_lock);
2023 return -EBUSY; 2019 return -EBUSY;
2024 } 2020 }
2025 2021
@@ -2028,8 +2024,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
2028 else if (event == CPUFREQ_GOV_START) 2024 else if (event == CPUFREQ_GOV_START)
2029 policy->governor_enabled = true; 2025 policy->governor_enabled = true;
2030 2026
2031 mutex_unlock(&cpufreq_governor_lock);
2032
2033 ret = policy->governor->governor(policy, event); 2027 ret = policy->governor->governor(policy, event);
2034 2028
2035 if (!ret) { 2029 if (!ret) {
@@ -2039,12 +2033,10 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
2039 policy->governor->initialized--; 2033 policy->governor->initialized--;
2040 } else { 2034 } else {
2041 /* Restore original values */ 2035 /* Restore original values */
2042 mutex_lock(&cpufreq_governor_lock);
2043 if (event == CPUFREQ_GOV_STOP) 2036 if (event == CPUFREQ_GOV_STOP)
2044 policy->governor_enabled = true; 2037 policy->governor_enabled = true;
2045 else if (event == CPUFREQ_GOV_START) 2038 else if (event == CPUFREQ_GOV_START)
2046 policy->governor_enabled = false; 2039 policy->governor_enabled = false;
2047 mutex_unlock(&cpufreq_governor_lock);
2048 } 2040 }
2049 2041
2050 if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) || 2042 if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) ||