|
@@ -329,9 +329,9 @@ static void free_common_dbs_info(struct cpufreq_policy *policy,
|
|
|
}
|
|
|
|
|
|
static int cpufreq_governor_init(struct cpufreq_policy *policy,
|
|
|
- struct dbs_data *dbs_data,
|
|
|
struct common_dbs_data *cdata)
|
|
|
{
|
|
|
+ struct dbs_data *dbs_data = cdata->gdbs_data;
|
|
|
unsigned int latency;
|
|
|
int ret;
|
|
|
|
|
@@ -403,9 +403,9 @@ free_dbs_data:
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-static int cpufreq_governor_exit(struct cpufreq_policy *policy,
|
|
|
- struct dbs_data *dbs_data)
|
|
|
+static int cpufreq_governor_exit(struct cpufreq_policy *policy)
|
|
|
{
|
|
|
+ struct dbs_data *dbs_data = policy->governor_data;
|
|
|
struct common_dbs_data *cdata = dbs_data->cdata;
|
|
|
struct cpu_dbs_info *cdbs = cdata->get_cpu_cdbs(policy->cpu);
|
|
|
|
|
@@ -432,9 +432,9 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int cpufreq_governor_start(struct cpufreq_policy *policy,
|
|
|
- struct dbs_data *dbs_data)
|
|
|
+static int cpufreq_governor_start(struct cpufreq_policy *policy)
|
|
|
{
|
|
|
+ struct dbs_data *dbs_data = policy->governor_data;
|
|
|
struct common_dbs_data *cdata = dbs_data->cdata;
|
|
|
unsigned int sampling_rate, ignore_nice, j, cpu = policy->cpu;
|
|
|
struct cpu_dbs_info *cdbs = cdata->get_cpu_cdbs(cpu);
|
|
@@ -499,9 +499,9 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int cpufreq_governor_stop(struct cpufreq_policy *policy,
|
|
|
- struct dbs_data *dbs_data)
|
|
|
+static int cpufreq_governor_stop(struct cpufreq_policy *policy)
|
|
|
{
|
|
|
+ struct dbs_data *dbs_data = policy->governor_data;
|
|
|
struct cpu_dbs_info *cdbs = dbs_data->cdata->get_cpu_cdbs(policy->cpu);
|
|
|
struct cpu_common_dbs_info *shared = cdbs->shared;
|
|
|
|
|
@@ -515,9 +515,9 @@ static int cpufreq_governor_stop(struct cpufreq_policy *policy,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int cpufreq_governor_limits(struct cpufreq_policy *policy,
|
|
|
- struct dbs_data *dbs_data)
|
|
|
+static int cpufreq_governor_limits(struct cpufreq_policy *policy)
|
|
|
{
|
|
|
+ struct dbs_data *dbs_data = policy->governor_data;
|
|
|
struct common_dbs_data *cdata = dbs_data->cdata;
|
|
|
unsigned int cpu = policy->cpu;
|
|
|
struct cpu_dbs_info *cdbs = cdata->get_cpu_cdbs(cpu);
|
|
@@ -542,45 +542,31 @@ static int cpufreq_governor_limits(struct cpufreq_policy *policy,
|
|
|
int cpufreq_governor_dbs(struct cpufreq_policy *policy,
|
|
|
struct common_dbs_data *cdata, unsigned int event)
|
|
|
{
|
|
|
- struct dbs_data *dbs_data;
|
|
|
- int ret;
|
|
|
+ int ret = -EINVAL;
|
|
|
|
|
|
/* Lock governor to block concurrent initialization of governor */
|
|
|
mutex_lock(&dbs_data_mutex);
|
|
|
|
|
|
- if (have_governor_per_policy())
|
|
|
- dbs_data = policy->governor_data;
|
|
|
- else
|
|
|
- dbs_data = cdata->gdbs_data;
|
|
|
-
|
|
|
- if (!dbs_data && (event != CPUFREQ_GOV_POLICY_INIT)) {
|
|
|
- ret = -EINVAL;
|
|
|
- goto unlock;
|
|
|
- }
|
|
|
-
|
|
|
- switch (event) {
|
|
|
- case CPUFREQ_GOV_POLICY_INIT:
|
|
|
- ret = cpufreq_governor_init(policy, dbs_data, cdata);
|
|
|
- break;
|
|
|
- case CPUFREQ_GOV_POLICY_EXIT:
|
|
|
- ret = cpufreq_governor_exit(policy, dbs_data);
|
|
|
- break;
|
|
|
- case CPUFREQ_GOV_START:
|
|
|
- ret = cpufreq_governor_start(policy, dbs_data);
|
|
|
- break;
|
|
|
- case CPUFREQ_GOV_STOP:
|
|
|
- ret = cpufreq_governor_stop(policy, dbs_data);
|
|
|
- break;
|
|
|
- case CPUFREQ_GOV_LIMITS:
|
|
|
- ret = cpufreq_governor_limits(policy, dbs_data);
|
|
|
- break;
|
|
|
- default:
|
|
|
- ret = -EINVAL;
|
|
|
+ if (event == CPUFREQ_GOV_POLICY_INIT) {
|
|
|
+ ret = cpufreq_governor_init(policy, cdata);
|
|
|
+ } else if (policy->governor_data) {
|
|
|
+ switch (event) {
|
|
|
+ case CPUFREQ_GOV_POLICY_EXIT:
|
|
|
+ ret = cpufreq_governor_exit(policy);
|
|
|
+ break;
|
|
|
+ case CPUFREQ_GOV_START:
|
|
|
+ ret = cpufreq_governor_start(policy);
|
|
|
+ break;
|
|
|
+ case CPUFREQ_GOV_STOP:
|
|
|
+ ret = cpufreq_governor_stop(policy);
|
|
|
+ break;
|
|
|
+ case CPUFREQ_GOV_LIMITS:
|
|
|
+ ret = cpufreq_governor_limits(policy);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-unlock:
|
|
|
mutex_unlock(&dbs_data_mutex);
|
|
|
-
|
|
|
return ret;
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(cpufreq_governor_dbs);
|