|
@@ -349,8 +349,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
|
|
io_busy = od_tuners->io_is_busy;
|
|
io_busy = od_tuners->io_is_busy;
|
|
}
|
|
}
|
|
|
|
|
|
- mutex_lock(&dbs_data->mutex);
|
|
|
|
-
|
|
|
|
for_each_cpu(j, policy->cpus) {
|
|
for_each_cpu(j, policy->cpus) {
|
|
struct cpu_dbs_common_info *j_cdbs = cdata->get_cpu_cdbs(j);
|
|
struct cpu_dbs_common_info *j_cdbs = cdata->get_cpu_cdbs(j);
|
|
unsigned int prev_load;
|
|
unsigned int prev_load;
|
|
@@ -388,8 +386,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
|
|
od_ops->powersave_bias_init_cpu(cpu);
|
|
od_ops->powersave_bias_init_cpu(cpu);
|
|
}
|
|
}
|
|
|
|
|
|
- mutex_unlock(&dbs_data->mutex);
|
|
|
|
-
|
|
|
|
/* Initiate timer time stamp */
|
|
/* Initiate timer time stamp */
|
|
cpu_cdbs->time_stamp = ktime_get();
|
|
cpu_cdbs->time_stamp = ktime_get();
|
|
|
|
|
|
@@ -414,10 +410,8 @@ static void cpufreq_governor_stop(struct cpufreq_policy *policy,
|
|
|
|
|
|
gov_cancel_work(dbs_data, policy);
|
|
gov_cancel_work(dbs_data, policy);
|
|
|
|
|
|
- mutex_lock(&dbs_data->mutex);
|
|
|
|
mutex_destroy(&cpu_cdbs->timer_mutex);
|
|
mutex_destroy(&cpu_cdbs->timer_mutex);
|
|
cpu_cdbs->cur_policy = NULL;
|
|
cpu_cdbs->cur_policy = NULL;
|
|
- mutex_unlock(&dbs_data->mutex);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static void cpufreq_governor_limits(struct cpufreq_policy *policy,
|
|
static void cpufreq_governor_limits(struct cpufreq_policy *policy,
|
|
@@ -427,11 +421,8 @@ static void cpufreq_governor_limits(struct cpufreq_policy *policy,
|
|
unsigned int cpu = policy->cpu;
|
|
unsigned int cpu = policy->cpu;
|
|
struct cpu_dbs_common_info *cpu_cdbs = cdata->get_cpu_cdbs(cpu);
|
|
struct cpu_dbs_common_info *cpu_cdbs = cdata->get_cpu_cdbs(cpu);
|
|
|
|
|
|
- mutex_lock(&dbs_data->mutex);
|
|
|
|
- if (!cpu_cdbs->cur_policy) {
|
|
|
|
- mutex_unlock(&dbs_data->mutex);
|
|
|
|
|
|
+ if (!cpu_cdbs->cur_policy)
|
|
return;
|
|
return;
|
|
- }
|
|
|
|
|
|
|
|
mutex_lock(&cpu_cdbs->timer_mutex);
|
|
mutex_lock(&cpu_cdbs->timer_mutex);
|
|
if (policy->max < cpu_cdbs->cur_policy->cur)
|
|
if (policy->max < cpu_cdbs->cur_policy->cur)
|
|
@@ -442,8 +433,6 @@ static void cpufreq_governor_limits(struct cpufreq_policy *policy,
|
|
CPUFREQ_RELATION_L);
|
|
CPUFREQ_RELATION_L);
|
|
dbs_check_cpu(dbs_data, cpu);
|
|
dbs_check_cpu(dbs_data, cpu);
|
|
mutex_unlock(&cpu_cdbs->timer_mutex);
|
|
mutex_unlock(&cpu_cdbs->timer_mutex);
|
|
-
|
|
|
|
- mutex_unlock(&dbs_data->mutex);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
int cpufreq_governor_dbs(struct cpufreq_policy *policy,
|
|
int cpufreq_governor_dbs(struct cpufreq_policy *policy,
|
|
@@ -452,12 +441,18 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
|
|
struct dbs_data *dbs_data;
|
|
struct dbs_data *dbs_data;
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
|
|
+ /* Lock governor to block concurrent initialization of governor */
|
|
|
|
+ mutex_lock(&cdata->mutex);
|
|
|
|
+
|
|
if (have_governor_per_policy())
|
|
if (have_governor_per_policy())
|
|
dbs_data = policy->governor_data;
|
|
dbs_data = policy->governor_data;
|
|
else
|
|
else
|
|
dbs_data = cdata->gdbs_data;
|
|
dbs_data = cdata->gdbs_data;
|
|
|
|
|
|
- WARN_ON(!dbs_data && (event != CPUFREQ_GOV_POLICY_INIT));
|
|
|
|
|
|
+ if (WARN_ON(!dbs_data && (event != CPUFREQ_GOV_POLICY_INIT))) {
|
|
|
|
+ ret = -EINVAL;
|
|
|
|
+ goto unlock;
|
|
|
|
+ }
|
|
|
|
|
|
switch (event) {
|
|
switch (event) {
|
|
case CPUFREQ_GOV_POLICY_INIT:
|
|
case CPUFREQ_GOV_POLICY_INIT:
|
|
@@ -477,6 +472,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+unlock:
|
|
|
|
+ mutex_unlock(&cdata->mutex);
|
|
|
|
+
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(cpufreq_governor_dbs);
|
|
EXPORT_SYMBOL_GPL(cpufreq_governor_dbs);
|