diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2013-02-01 00:42:58 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-02-01 19:29:31 -0500 |
commit | b394058f064848deac7a7cd6942b6521d7b3fe1d (patch) | |
tree | 2e6272ca452cf2d116f00a561344a4672f751063 | |
parent | 4447266b842d27f77b017a59eb9dc38ad7b299f1 (diff) |
cpufreq: governors: Reset tunables only for cpufreq_unregister_governor()
Currently, whenever governor->governor() is called for CPUFRREQ_GOV_START event
we reset few tunables of governor. Which isn't correct, as this routine is
called for every cpu hot-[un]plugging event. We should actually be resetting
these only when the governor module is removed and re-installed.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 4 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_governor.c | 24 | ||||
-rw-r--r-- | include/linux/cpufreq.h | 1 |
3 files changed, 21 insertions, 8 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 1cea7a1eac13..0b4be4481433 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1562,6 +1562,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1562 | policy->cpu, event); | 1562 | policy->cpu, event); |
1563 | ret = policy->governor->governor(policy, event); | 1563 | ret = policy->governor->governor(policy, event); |
1564 | 1564 | ||
1565 | if (!policy->governor->initialized && (event == CPUFREQ_GOV_START)) | ||
1566 | policy->governor->initialized = 1; | ||
1567 | |||
1565 | /* we keep one module reference alive for | 1568 | /* we keep one module reference alive for |
1566 | each CPU governed by this CPU */ | 1569 | each CPU governed by this CPU */ |
1567 | if ((event != CPUFREQ_GOV_START) || ret) | 1570 | if ((event != CPUFREQ_GOV_START) || ret) |
@@ -1585,6 +1588,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor) | |||
1585 | 1588 | ||
1586 | mutex_lock(&cpufreq_governor_mutex); | 1589 | mutex_lock(&cpufreq_governor_mutex); |
1587 | 1590 | ||
1591 | governor->initialized = 0; | ||
1588 | err = -EBUSY; | 1592 | err = -EBUSY; |
1589 | if (__find_governor(governor->name) == NULL) { | 1593 | if (__find_governor(governor->name) == NULL) { |
1590 | err = 0; | 1594 | err = 0; |
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 7aaa9b151940..79795c4bf611 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
@@ -254,11 +254,6 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data, | |||
254 | return rc; | 254 | return rc; |
255 | } | 255 | } |
256 | 256 | ||
257 | /* policy latency is in nS. Convert it to uS first */ | ||
258 | latency = policy->cpuinfo.transition_latency / 1000; | ||
259 | if (latency == 0) | ||
260 | latency = 1; | ||
261 | |||
262 | /* | 257 | /* |
263 | * conservative does not implement micro like ondemand | 258 | * conservative does not implement micro like ondemand |
264 | * governor, thus we are bound to jiffes/HZ | 259 | * governor, thus we are bound to jiffes/HZ |
@@ -270,20 +265,33 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data, | |||
270 | cpufreq_register_notifier(cs_ops->notifier_block, | 265 | cpufreq_register_notifier(cs_ops->notifier_block, |
271 | CPUFREQ_TRANSITION_NOTIFIER); | 266 | CPUFREQ_TRANSITION_NOTIFIER); |
272 | 267 | ||
273 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * | 268 | if (!policy->governor->initialized) |
274 | jiffies_to_usecs(10); | 269 | dbs_data->min_sampling_rate = |
270 | MIN_SAMPLING_RATE_RATIO * | ||
271 | jiffies_to_usecs(10); | ||
275 | } else { | 272 | } else { |
276 | od_dbs_info->rate_mult = 1; | 273 | od_dbs_info->rate_mult = 1; |
277 | od_dbs_info->sample_type = OD_NORMAL_SAMPLE; | 274 | od_dbs_info->sample_type = OD_NORMAL_SAMPLE; |
278 | od_ops->powersave_bias_init_cpu(cpu); | 275 | od_ops->powersave_bias_init_cpu(cpu); |
279 | od_tuners->io_is_busy = od_ops->io_busy(); | 276 | |
277 | if (!policy->governor->initialized) | ||
278 | od_tuners->io_is_busy = od_ops->io_busy(); | ||
280 | } | 279 | } |
281 | 280 | ||
281 | if (policy->governor->initialized) | ||
282 | goto unlock; | ||
283 | |||
284 | /* policy latency is in nS. Convert it to uS first */ | ||
285 | latency = policy->cpuinfo.transition_latency / 1000; | ||
286 | if (latency == 0) | ||
287 | latency = 1; | ||
288 | |||
282 | /* Bring kernel and HW constraints together */ | 289 | /* Bring kernel and HW constraints together */ |
283 | dbs_data->min_sampling_rate = max(dbs_data->min_sampling_rate, | 290 | dbs_data->min_sampling_rate = max(dbs_data->min_sampling_rate, |
284 | MIN_LATENCY_MULTIPLIER * latency); | 291 | MIN_LATENCY_MULTIPLIER * latency); |
285 | *sampling_rate = max(dbs_data->min_sampling_rate, latency * | 292 | *sampling_rate = max(dbs_data->min_sampling_rate, latency * |
286 | LATENCY_MULTIPLIER); | 293 | LATENCY_MULTIPLIER); |
294 | unlock: | ||
287 | mutex_unlock(&dbs_data->mutex); | 295 | mutex_unlock(&dbs_data->mutex); |
288 | 296 | ||
289 | /* Initiate timer time stamp */ | 297 | /* Initiate timer time stamp */ |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index feb360c8aa88..6bf3f2d12c90 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -183,6 +183,7 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu | |||
183 | 183 | ||
184 | struct cpufreq_governor { | 184 | struct cpufreq_governor { |
185 | char name[CPUFREQ_NAME_LEN]; | 185 | char name[CPUFREQ_NAME_LEN]; |
186 | int initialized; | ||
186 | int (*governor) (struct cpufreq_policy *policy, | 187 | int (*governor) (struct cpufreq_policy *policy, |
187 | unsigned int event); | 188 | unsigned int event); |
188 | ssize_t (*show_setspeed) (struct cpufreq_policy *policy, | 189 | ssize_t (*show_setspeed) (struct cpufreq_policy *policy, |