]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
cpufreq: remove race while accessing cur_policy
authorBibek Basu <bbasu@nvidia.com>
Fri, 9 May 2014 11:40:35 +0000 (17:10 +0530)
committerBibek Basu <bbasu@nvidia.com>
Mon, 19 May 2014 04:13:42 +0000 (21:13 -0700)
While accessing cur_policy during executing events
CPUFREQ_GOV_START, CPUFREQ_GOV_STOP, CPUFREQ_GOV_LIMITS
same mutex lock is not taken, dbs_data->mutex, which leads
to race and data corruption while running continious suspend
resume test.

Bug 1455519

Change-Id: I6b385578c791648681746b749d33f671d00154f3
Signed-off-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-on: http://git-master/r/407589
(cherry picked from commit 893243039ee4785099603dac1f3221311e3c219f)
Reviewed-on: http://git-master/r/409215
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
Reviewed-by: Puneet Saxena <puneets@nvidia.com>
Reviewed-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
drivers/cpufreq/cpufreq_governor.c

index a7272676b230ead59b30d693dee9ab6766070653..3a87379674d5cb7c8dbaf8c12c325bf0ff4022cd 100644 (file)
@@ -8,6 +8,7 @@
  *             (C) 2003 Jun Nakajima <jun.nakajima@intel.com>
  *             (C) 2009 Alexander Clouter <alex@digriz.org.uk>
  *             (c) 2012 Viresh Kumar <viresh.kumar@linaro.org>
+ * Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -364,6 +365,11 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                break;
 
        case CPUFREQ_GOV_LIMITS:
+               mutex_lock(&dbs_data->mutex);
+               if (!cpu_cdbs->cur_policy) {
+                       mutex_unlock(&dbs_data->mutex);
+                       break;
+               }
                mutex_lock(&cpu_cdbs->timer_mutex);
                if (policy->max < cpu_cdbs->cur_policy->cur)
                        __cpufreq_driver_target(cpu_cdbs->cur_policy,
@@ -373,6 +379,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                                        policy->min, CPUFREQ_RELATION_L);
                dbs_check_cpu(dbs_data, cpu);
                mutex_unlock(&cpu_cdbs->timer_mutex);
+               mutex_unlock(&dbs_data->mutex);
                break;
        }
        return 0;