static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data)
{
if (have_governor_per_policy())
- return dbs_data->cdata->attr_group_gov_pol;
+ return dbs_data->gov->attr_group_gov_pol;
else
- return dbs_data->cdata->attr_group_gov_sys;
+ return dbs_data->gov->attr_group_gov_sys;
}
void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
{
- struct cpu_dbs_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu);
+ struct cpu_dbs_info *cdbs = dbs_data->gov->get_cpu_cdbs(cpu);
struct od_dbs_tuners *od_tuners = dbs_data->tuners;
struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
struct cpufreq_policy *policy = cdbs->shared->policy;
unsigned int ignore_nice;
unsigned int j;
- if (dbs_data->cdata->governor == GOV_ONDEMAND) {
+ if (dbs_data->gov->governor == GOV_ONDEMAND) {
struct od_cpu_dbs_info_s *od_dbs_info =
- dbs_data->cdata->get_cpu_dbs_info_s(cpu);
+ dbs_data->gov->get_cpu_dbs_info_s(cpu);
/*
* Sometimes, the ondemand governor uses an additional
unsigned int load;
int io_busy = 0;
- j_cdbs = dbs_data->cdata->get_cpu_cdbs(j);
+ j_cdbs = dbs_data->gov->get_cpu_cdbs(j);
/*
* For the purpose of ondemand, waiting for disk IO is
* not that the system is actually idle. So do not add
* the iowait time to the cpu idle time.
*/
- if (dbs_data->cdata->governor == GOV_ONDEMAND)
+ if (dbs_data->gov->governor == GOV_ONDEMAND)
io_busy = od_tuners->io_is_busy;
cur_idle_time = get_cpu_idle_time(j, &cur_wall_time, io_busy);
max_load = load;
}
- dbs_data->cdata->gov_check_cpu(cpu, max_load);
+ dbs_data->gov->gov_check_cpu(cpu, max_load);
}
EXPORT_SYMBOL_GPL(dbs_check_cpu);
shared->last_sample_time = 0;
for_each_cpu(cpu, policy->cpus) {
- struct cpu_dbs_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu);
+ struct cpu_dbs_info *cdbs = dbs_data->gov->get_cpu_cdbs(cpu);
cpufreq_set_update_util_data(cpu, &cdbs->update_util);
}
* ondemand governor isn't updating the sampling rate in parallel.
*/
mutex_lock(&shared->timer_mutex);
- delay = dbs_data->cdata->gov_dbs_timer(policy);
+ delay = dbs_data->gov->gov_dbs_timer(policy);
shared->sample_delay_ns = jiffies_to_nsecs(delay);
mutex_unlock(&shared->timer_mutex);
static void set_sampling_rate(struct dbs_data *dbs_data,
unsigned int sampling_rate)
{
- if (dbs_data->cdata->governor == GOV_CONSERVATIVE) {
+ if (dbs_data->gov->governor == GOV_CONSERVATIVE) {
struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
cs_tuners->sampling_rate = sampling_rate;
} else {
}
static int alloc_common_dbs_info(struct cpufreq_policy *policy,
- struct common_dbs_data *cdata)
+ struct dbs_governor *gov)
{
struct cpu_common_dbs_info *shared;
int j;
/* Set shared for all CPUs, online+offline */
for_each_cpu(j, policy->related_cpus)
- cdata->get_cpu_cdbs(j)->shared = shared;
+ gov->get_cpu_cdbs(j)->shared = shared;
mutex_init(&shared->timer_mutex);
atomic_set(&shared->skip_work, 0);
}
static void free_common_dbs_info(struct cpufreq_policy *policy,
- struct common_dbs_data *cdata)
+ struct dbs_governor *gov)
{
- struct cpu_dbs_info *cdbs = cdata->get_cpu_cdbs(policy->cpu);
+ struct cpu_dbs_info *cdbs = gov->get_cpu_cdbs(policy->cpu);
struct cpu_common_dbs_info *shared = cdbs->shared;
int j;
mutex_destroy(&shared->timer_mutex);
for_each_cpu(j, policy->cpus)
- cdata->get_cpu_cdbs(j)->shared = NULL;
+ gov->get_cpu_cdbs(j)->shared = NULL;
kfree(shared);
}
static int cpufreq_governor_init(struct cpufreq_policy *policy,
- struct common_dbs_data *cdata)
+ struct dbs_governor *gov)
{
- struct dbs_data *dbs_data = cdata->gdbs_data;
+ struct dbs_data *dbs_data = gov->gdbs_data;
unsigned int latency;
int ret;
if (WARN_ON(have_governor_per_policy()))
return -EINVAL;
- ret = alloc_common_dbs_info(policy, cdata);
+ ret = alloc_common_dbs_info(policy, gov);
if (ret)
return ret;
if (!dbs_data)
return -ENOMEM;
- ret = alloc_common_dbs_info(policy, cdata);
+ ret = alloc_common_dbs_info(policy, gov);
if (ret)
goto free_dbs_data;
- dbs_data->cdata = cdata;
+ dbs_data->gov = gov;
dbs_data->usage_count = 1;
- ret = cdata->init(dbs_data, !policy->governor->initialized);
+ ret = gov->init(dbs_data, !policy->governor->initialized);
if (ret)
goto free_common_dbs_info;
latency * LATENCY_MULTIPLIER));
if (!have_governor_per_policy())
- cdata->gdbs_data = dbs_data;
+ gov->gdbs_data = dbs_data;
policy->governor_data = dbs_data;
policy->governor_data = NULL;
if (!have_governor_per_policy())
- cdata->gdbs_data = NULL;
- cdata->exit(dbs_data, !policy->governor->initialized);
+ gov->gdbs_data = NULL;
+ gov->exit(dbs_data, !policy->governor->initialized);
free_common_dbs_info:
- free_common_dbs_info(policy, cdata);
+ free_common_dbs_info(policy, gov);
free_dbs_data:
kfree(dbs_data);
return ret;
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);
+ struct dbs_governor *gov = dbs_data->gov;
+ struct cpu_dbs_info *cdbs = gov->get_cpu_cdbs(policy->cpu);
/* State should be equivalent to INIT */
if (!cdbs->shared || cdbs->shared->policy)
policy->governor_data = NULL;
if (!have_governor_per_policy())
- cdata->gdbs_data = NULL;
+ gov->gdbs_data = NULL;
- cdata->exit(dbs_data, policy->governor->initialized == 1);
+ gov->exit(dbs_data, policy->governor->initialized == 1);
kfree(dbs_data);
} else {
policy->governor_data = NULL;
}
- free_common_dbs_info(policy, cdata);
+ free_common_dbs_info(policy, gov);
return 0;
}
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;
+ struct dbs_governor *gov = dbs_data->gov;
unsigned int sampling_rate, ignore_nice, j, cpu = policy->cpu;
- struct cpu_dbs_info *cdbs = cdata->get_cpu_cdbs(cpu);
+ struct cpu_dbs_info *cdbs = gov->get_cpu_cdbs(cpu);
struct cpu_common_dbs_info *shared = cdbs->shared;
int io_busy = 0;
if (!shared || shared->policy)
return -EBUSY;
- if (cdata->governor == GOV_CONSERVATIVE) {
+ if (gov->governor == GOV_CONSERVATIVE) {
struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
sampling_rate = cs_tuners->sampling_rate;
}
for_each_cpu(j, policy->cpus) {
- struct cpu_dbs_info *j_cdbs = cdata->get_cpu_cdbs(j);
+ struct cpu_dbs_info *j_cdbs = gov->get_cpu_cdbs(j);
unsigned int prev_load;
j_cdbs->prev_cpu_idle =
}
shared->policy = policy;
- if (cdata->governor == GOV_CONSERVATIVE) {
+ if (gov->governor == GOV_CONSERVATIVE) {
struct cs_cpu_dbs_info_s *cs_dbs_info =
- cdata->get_cpu_dbs_info_s(cpu);
+ gov->get_cpu_dbs_info_s(cpu);
cs_dbs_info->down_skip = 0;
cs_dbs_info->requested_freq = policy->cur;
} else {
- struct od_ops *od_ops = cdata->gov_ops;
- struct od_cpu_dbs_info_s *od_dbs_info = cdata->get_cpu_dbs_info_s(cpu);
+ struct od_ops *od_ops = gov->gov_ops;
+ struct od_cpu_dbs_info_s *od_dbs_info = gov->get_cpu_dbs_info_s(cpu);
od_dbs_info->rate_mult = 1;
od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
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_dbs_info *cdbs = dbs_data->gov->get_cpu_cdbs(policy->cpu);
struct cpu_common_dbs_info *shared = cdbs->shared;
/* State should be equivalent to START */
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;
+ struct dbs_governor *gov = dbs_data->gov;
unsigned int cpu = policy->cpu;
- struct cpu_dbs_info *cdbs = cdata->get_cpu_cdbs(cpu);
+ struct cpu_dbs_info *cdbs = gov->get_cpu_cdbs(cpu);
/* State should be equivalent to START */
if (!cdbs->shared || !cdbs->shared->policy)
}
int cpufreq_governor_dbs(struct cpufreq_policy *policy,
- struct common_dbs_data *cdata, unsigned int event)
+ struct dbs_governor *gov, unsigned int event)
{
int ret = -EINVAL;
mutex_lock(&dbs_data_mutex);
if (event == CPUFREQ_GOV_POLICY_INIT) {
- ret = cpufreq_governor_init(policy, cdata);
+ ret = cpufreq_governor_init(policy, gov);
} else if (policy->governor_data) {
switch (event) {
case CPUFREQ_GOV_POLICY_EXIT:
static ssize_t show_##file_name##_gov_sys \
(struct kobject *kobj, struct attribute *attr, char *buf) \
{ \
- struct _gov##_dbs_tuners *tuners = _gov##_dbs_cdata.gdbs_data->tuners; \
+ struct _gov##_dbs_tuners *tuners = _gov##_dbs_gov.gdbs_data->tuners; \
return sprintf(buf, "%u\n", tuners->file_name); \
} \
\
static ssize_t store_##file_name##_gov_sys \
(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \
{ \
- struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \
+ struct dbs_data *dbs_data = _gov##_dbs_gov.gdbs_data; \
return store_##file_name(dbs_data, buf, count); \
} \
\
/* Common Governor data across policies */
struct dbs_data;
-struct common_dbs_data {
+struct dbs_governor {
struct cpufreq_governor gov;
#define GOV_ONDEMAND 0
/* Governor Per policy data */
struct dbs_data {
- struct common_dbs_data *cdata;
+ struct dbs_governor *gov;
unsigned int min_sampling_rate;
int usage_count;
void *tuners;
static ssize_t show_sampling_rate_min_gov_sys \
(struct kobject *kobj, struct attribute *attr, char *buf) \
{ \
- struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \
+ struct dbs_data *dbs_data = _gov##_dbs_gov.gdbs_data; \
return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \
} \
\
extern struct mutex cpufreq_governor_lock;
void dbs_check_cpu(struct dbs_data *dbs_data, int cpu);
int cpufreq_governor_dbs(struct cpufreq_policy *policy,
- struct common_dbs_data *cdata, unsigned int event);
+ struct dbs_governor *gov, unsigned int event);
void od_register_powersave_bias_handler(unsigned int (*f)
(struct cpufreq_policy *, unsigned int, unsigned int),
unsigned int powersave_bias);