cpufreq: governors: Fix WARN_ON() for multi-policy platforms

On multi-policy systems there is a single instance of governor for both the
policies (if same governor is chosen for both policies). With the code update
from following patches:

8eeed09 cpufreq: governors: Get rid of dbs_data->enable field
b394058 cpufreq: governors: Reset tunables only for cpufreq_unregister_governor()

We are creating/removing sysfs directory of governor for for every call to
GOV_START and STOP. This would fail for multi-policy system as there is a
per-policy call to START/STOP.

This patch reuses the governor->initialized variable to detect total users of
governor.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Viresh Kumar 2013-02-07 12:51:27 +05:30 коммит произвёл Rafael J. Wysocki
Родитель 4bd4e42819
Коммит 8e53695f7f
2 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@ -1552,8 +1552,10 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
policy->cpu, event); policy->cpu, event);
ret = policy->governor->governor(policy, event); ret = policy->governor->governor(policy, event);
if (!policy->governor->initialized && (event == CPUFREQ_GOV_START)) if (event == CPUFREQ_GOV_START)
policy->governor->initialized = 1; policy->governor->initialized++;
else if (event == CPUFREQ_GOV_STOP)
policy->governor->initialized--;
/* we keep one module reference alive for /* we keep one module reference alive for
each CPU governed by this CPU */ each CPU governed by this CPU */

Просмотреть файл

@ -247,11 +247,13 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
dbs_data->gov_dbs_timer); dbs_data->gov_dbs_timer);
} }
rc = sysfs_create_group(cpufreq_global_kobject, if (!policy->governor->initialized) {
dbs_data->attr_group); rc = sysfs_create_group(cpufreq_global_kobject,
if (rc) { dbs_data->attr_group);
mutex_unlock(&dbs_data->mutex); if (rc) {
return rc; mutex_unlock(&dbs_data->mutex);
return rc;
}
} }
/* /*
@ -262,13 +264,15 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
cs_dbs_info->down_skip = 0; cs_dbs_info->down_skip = 0;
cs_dbs_info->enable = 1; cs_dbs_info->enable = 1;
cs_dbs_info->requested_freq = policy->cur; cs_dbs_info->requested_freq = policy->cur;
cpufreq_register_notifier(cs_ops->notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
if (!policy->governor->initialized) if (!policy->governor->initialized) {
cpufreq_register_notifier(cs_ops->notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
dbs_data->min_sampling_rate = dbs_data->min_sampling_rate =
MIN_SAMPLING_RATE_RATIO * MIN_SAMPLING_RATE_RATIO *
jiffies_to_usecs(10); jiffies_to_usecs(10);
}
} else { } else {
od_dbs_info->rate_mult = 1; od_dbs_info->rate_mult = 1;
od_dbs_info->sample_type = OD_NORMAL_SAMPLE; od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
@ -311,11 +315,13 @@ unlock:
mutex_lock(&dbs_data->mutex); mutex_lock(&dbs_data->mutex);
mutex_destroy(&cpu_cdbs->timer_mutex); mutex_destroy(&cpu_cdbs->timer_mutex);
sysfs_remove_group(cpufreq_global_kobject, if (policy->governor->initialized == 1) {
dbs_data->attr_group); sysfs_remove_group(cpufreq_global_kobject,
if (dbs_data->governor == GOV_CONSERVATIVE) dbs_data->attr_group);
cpufreq_unregister_notifier(cs_ops->notifier_block, if (dbs_data->governor == GOV_CONSERVATIVE)
CPUFREQ_TRANSITION_NOTIFIER); cpufreq_unregister_notifier(cs_ops->notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
}
mutex_unlock(&dbs_data->mutex); mutex_unlock(&dbs_data->mutex);
break; break;