diff options
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 44 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 2 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 20 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_userspace.c | 3 |
4 files changed, 37 insertions, 32 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 1ba4039777e8..bc1088d9b379 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -364,10 +364,12 @@ static ssize_t store_##file_name \ | |||
364 | if (ret != 1) \ | 364 | if (ret != 1) \ |
365 | return -EINVAL; \ | 365 | return -EINVAL; \ |
366 | \ | 366 | \ |
367 | lock_cpu_hotplug(); \ | ||
367 | mutex_lock(&policy->lock); \ | 368 | mutex_lock(&policy->lock); \ |
368 | ret = __cpufreq_set_policy(policy, &new_policy); \ | 369 | ret = __cpufreq_set_policy(policy, &new_policy); \ |
369 | policy->user_policy.object = policy->object; \ | 370 | policy->user_policy.object = policy->object; \ |
370 | mutex_unlock(&policy->lock); \ | 371 | mutex_unlock(&policy->lock); \ |
372 | unlock_cpu_hotplug(); \ | ||
371 | \ | 373 | \ |
372 | return ret ? ret : count; \ | 374 | return ret ? ret : count; \ |
373 | } | 375 | } |
@@ -423,6 +425,8 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy, | |||
423 | if (cpufreq_parse_governor(str_governor, &new_policy.policy, &new_policy.governor)) | 425 | if (cpufreq_parse_governor(str_governor, &new_policy.policy, &new_policy.governor)) |
424 | return -EINVAL; | 426 | return -EINVAL; |
425 | 427 | ||
428 | lock_cpu_hotplug(); | ||
429 | |||
426 | /* Do not use cpufreq_set_policy here or the user_policy.max | 430 | /* Do not use cpufreq_set_policy here or the user_policy.max |
427 | will be wrongly overridden */ | 431 | will be wrongly overridden */ |
428 | mutex_lock(&policy->lock); | 432 | mutex_lock(&policy->lock); |
@@ -432,6 +436,8 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy, | |||
432 | policy->user_policy.governor = policy->governor; | 436 | policy->user_policy.governor = policy->governor; |
433 | mutex_unlock(&policy->lock); | 437 | mutex_unlock(&policy->lock); |
434 | 438 | ||
439 | unlock_cpu_hotplug(); | ||
440 | |||
435 | return ret ? ret : count; | 441 | return ret ? ret : count; |
436 | } | 442 | } |
437 | 443 | ||
@@ -1193,20 +1199,18 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); | |||
1193 | *********************************************************************/ | 1199 | *********************************************************************/ |
1194 | 1200 | ||
1195 | 1201 | ||
1202 | /* Must be called with lock_cpu_hotplug held */ | ||
1196 | int __cpufreq_driver_target(struct cpufreq_policy *policy, | 1203 | int __cpufreq_driver_target(struct cpufreq_policy *policy, |
1197 | unsigned int target_freq, | 1204 | unsigned int target_freq, |
1198 | unsigned int relation) | 1205 | unsigned int relation) |
1199 | { | 1206 | { |
1200 | int retval = -EINVAL; | 1207 | int retval = -EINVAL; |
1201 | 1208 | ||
1202 | lock_cpu_hotplug(); | ||
1203 | dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu, | 1209 | dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu, |
1204 | target_freq, relation); | 1210 | target_freq, relation); |
1205 | if (cpu_online(policy->cpu) && cpufreq_driver->target) | 1211 | if (cpu_online(policy->cpu) && cpufreq_driver->target) |
1206 | retval = cpufreq_driver->target(policy, target_freq, relation); | 1212 | retval = cpufreq_driver->target(policy, target_freq, relation); |
1207 | 1213 | ||
1208 | unlock_cpu_hotplug(); | ||
1209 | |||
1210 | return retval; | 1214 | return retval; |
1211 | } | 1215 | } |
1212 | EXPORT_SYMBOL_GPL(__cpufreq_driver_target); | 1216 | EXPORT_SYMBOL_GPL(__cpufreq_driver_target); |
@@ -1221,17 +1225,23 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1221 | if (!policy) | 1225 | if (!policy) |
1222 | return -EINVAL; | 1226 | return -EINVAL; |
1223 | 1227 | ||
1228 | lock_cpu_hotplug(); | ||
1224 | mutex_lock(&policy->lock); | 1229 | mutex_lock(&policy->lock); |
1225 | 1230 | ||
1226 | ret = __cpufreq_driver_target(policy, target_freq, relation); | 1231 | ret = __cpufreq_driver_target(policy, target_freq, relation); |
1227 | 1232 | ||
1228 | mutex_unlock(&policy->lock); | 1233 | mutex_unlock(&policy->lock); |
1234 | unlock_cpu_hotplug(); | ||
1229 | 1235 | ||
1230 | cpufreq_cpu_put(policy); | 1236 | cpufreq_cpu_put(policy); |
1231 | return ret; | 1237 | return ret; |
1232 | } | 1238 | } |
1233 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); | 1239 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); |
1234 | 1240 | ||
1241 | /* | ||
1242 | * Locking: Must be called with the lock_cpu_hotplug() lock held | ||
1243 | * when "event" is CPUFREQ_GOV_LIMITS | ||
1244 | */ | ||
1235 | 1245 | ||
1236 | static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) | 1246 | static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) |
1237 | { | 1247 | { |
@@ -1253,24 +1263,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) | |||
1253 | } | 1263 | } |
1254 | 1264 | ||
1255 | 1265 | ||
1256 | int cpufreq_governor(unsigned int cpu, unsigned int event) | ||
1257 | { | ||
1258 | int ret = 0; | ||
1259 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | ||
1260 | |||
1261 | if (!policy) | ||
1262 | return -EINVAL; | ||
1263 | |||
1264 | mutex_lock(&policy->lock); | ||
1265 | ret = __cpufreq_governor(policy, event); | ||
1266 | mutex_unlock(&policy->lock); | ||
1267 | |||
1268 | cpufreq_cpu_put(policy); | ||
1269 | return ret; | ||
1270 | } | ||
1271 | EXPORT_SYMBOL_GPL(cpufreq_governor); | ||
1272 | |||
1273 | |||
1274 | int cpufreq_register_governor(struct cpufreq_governor *governor) | 1266 | int cpufreq_register_governor(struct cpufreq_governor *governor) |
1275 | { | 1267 | { |
1276 | struct cpufreq_governor *t; | 1268 | struct cpufreq_governor *t; |
@@ -1338,6 +1330,9 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) | |||
1338 | EXPORT_SYMBOL(cpufreq_get_policy); | 1330 | EXPORT_SYMBOL(cpufreq_get_policy); |
1339 | 1331 | ||
1340 | 1332 | ||
1333 | /* | ||
1334 | * Locking: Must be called with the lock_cpu_hotplug() lock held | ||
1335 | */ | ||
1341 | static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy) | 1336 | static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy) |
1342 | { | 1337 | { |
1343 | int ret = 0; | 1338 | int ret = 0; |
@@ -1432,6 +1427,8 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) | |||
1432 | if (!data) | 1427 | if (!data) |
1433 | return -EINVAL; | 1428 | return -EINVAL; |
1434 | 1429 | ||
1430 | lock_cpu_hotplug(); | ||
1431 | |||
1435 | /* lock this CPU */ | 1432 | /* lock this CPU */ |
1436 | mutex_lock(&data->lock); | 1433 | mutex_lock(&data->lock); |
1437 | 1434 | ||
@@ -1442,6 +1439,8 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) | |||
1442 | data->user_policy.governor = data->governor; | 1439 | data->user_policy.governor = data->governor; |
1443 | 1440 | ||
1444 | mutex_unlock(&data->lock); | 1441 | mutex_unlock(&data->lock); |
1442 | |||
1443 | unlock_cpu_hotplug(); | ||
1445 | cpufreq_cpu_put(data); | 1444 | cpufreq_cpu_put(data); |
1446 | 1445 | ||
1447 | return ret; | 1446 | return ret; |
@@ -1465,6 +1464,7 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1465 | if (!data) | 1464 | if (!data) |
1466 | return -ENODEV; | 1465 | return -ENODEV; |
1467 | 1466 | ||
1467 | lock_cpu_hotplug(); | ||
1468 | mutex_lock(&data->lock); | 1468 | mutex_lock(&data->lock); |
1469 | 1469 | ||
1470 | dprintk("updating policy for CPU %u\n", cpu); | 1470 | dprintk("updating policy for CPU %u\n", cpu); |
@@ -1490,7 +1490,7 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1490 | ret = __cpufreq_set_policy(data, &policy); | 1490 | ret = __cpufreq_set_policy(data, &policy); |
1491 | 1491 | ||
1492 | mutex_unlock(&data->lock); | 1492 | mutex_unlock(&data->lock); |
1493 | 1493 | unlock_cpu_hotplug(); | |
1494 | cpufreq_cpu_put(data); | 1494 | cpufreq_cpu_put(data); |
1495 | return ret; | 1495 | return ret; |
1496 | } | 1496 | } |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index b3ebc8f01975..c4c578defabf 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -525,7 +525,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
525 | break; | 525 | break; |
526 | 526 | ||
527 | case CPUFREQ_GOV_LIMITS: | 527 | case CPUFREQ_GOV_LIMITS: |
528 | lock_cpu_hotplug(); | ||
529 | mutex_lock(&dbs_mutex); | 528 | mutex_lock(&dbs_mutex); |
530 | if (policy->max < this_dbs_info->cur_policy->cur) | 529 | if (policy->max < this_dbs_info->cur_policy->cur) |
531 | __cpufreq_driver_target( | 530 | __cpufreq_driver_target( |
@@ -536,7 +535,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
536 | this_dbs_info->cur_policy, | 535 | this_dbs_info->cur_policy, |
537 | policy->min, CPUFREQ_RELATION_L); | 536 | policy->min, CPUFREQ_RELATION_L); |
538 | mutex_unlock(&dbs_mutex); | 537 | mutex_unlock(&dbs_mutex); |
539 | unlock_cpu_hotplug(); | ||
540 | break; | 538 | break; |
541 | } | 539 | } |
542 | return 0; | 540 | return 0; |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 87299924e735..52cf1f021825 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -239,6 +239,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
239 | total_ticks = (unsigned int) cputime64_sub(cur_jiffies, | 239 | total_ticks = (unsigned int) cputime64_sub(cur_jiffies, |
240 | this_dbs_info->prev_cpu_wall); | 240 | this_dbs_info->prev_cpu_wall); |
241 | this_dbs_info->prev_cpu_wall = cur_jiffies; | 241 | this_dbs_info->prev_cpu_wall = cur_jiffies; |
242 | if (!total_ticks) | ||
243 | return; | ||
242 | /* | 244 | /* |
243 | * Every sampling_rate, we check, if current idle time is less | 245 | * Every sampling_rate, we check, if current idle time is less |
244 | * than 20% (default), then we try to increase frequency | 246 | * than 20% (default), then we try to increase frequency |
@@ -304,7 +306,12 @@ static void do_dbs_timer(void *data) | |||
304 | unsigned int cpu = smp_processor_id(); | 306 | unsigned int cpu = smp_processor_id(); |
305 | struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); | 307 | struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); |
306 | 308 | ||
309 | if (!dbs_info->enable) | ||
310 | return; | ||
311 | |||
312 | lock_cpu_hotplug(); | ||
307 | dbs_check_cpu(dbs_info); | 313 | dbs_check_cpu(dbs_info); |
314 | unlock_cpu_hotplug(); | ||
308 | queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, | 315 | queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, |
309 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | 316 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
310 | } | 317 | } |
@@ -319,11 +326,11 @@ static inline void dbs_timer_init(unsigned int cpu) | |||
319 | return; | 326 | return; |
320 | } | 327 | } |
321 | 328 | ||
322 | static inline void dbs_timer_exit(unsigned int cpu) | 329 | static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) |
323 | { | 330 | { |
324 | struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); | 331 | dbs_info->enable = 0; |
325 | 332 | cancel_delayed_work(&dbs_info->work); | |
326 | cancel_rearming_delayed_workqueue(kondemand_wq, &dbs_info->work); | 333 | flush_workqueue(kondemand_wq); |
327 | } | 334 | } |
328 | 335 | ||
329 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | 336 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, |
@@ -396,8 +403,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
396 | 403 | ||
397 | case CPUFREQ_GOV_STOP: | 404 | case CPUFREQ_GOV_STOP: |
398 | mutex_lock(&dbs_mutex); | 405 | mutex_lock(&dbs_mutex); |
399 | dbs_timer_exit(policy->cpu); | 406 | dbs_timer_exit(this_dbs_info); |
400 | this_dbs_info->enable = 0; | ||
401 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); | 407 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); |
402 | dbs_enable--; | 408 | dbs_enable--; |
403 | if (dbs_enable == 0) | 409 | if (dbs_enable == 0) |
@@ -408,7 +414,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
408 | break; | 414 | break; |
409 | 415 | ||
410 | case CPUFREQ_GOV_LIMITS: | 416 | case CPUFREQ_GOV_LIMITS: |
411 | lock_cpu_hotplug(); | ||
412 | mutex_lock(&dbs_mutex); | 417 | mutex_lock(&dbs_mutex); |
413 | if (policy->max < this_dbs_info->cur_policy->cur) | 418 | if (policy->max < this_dbs_info->cur_policy->cur) |
414 | __cpufreq_driver_target(this_dbs_info->cur_policy, | 419 | __cpufreq_driver_target(this_dbs_info->cur_policy, |
@@ -419,7 +424,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
419 | policy->min, | 424 | policy->min, |
420 | CPUFREQ_RELATION_L); | 425 | CPUFREQ_RELATION_L); |
421 | mutex_unlock(&dbs_mutex); | 426 | mutex_unlock(&dbs_mutex); |
422 | unlock_cpu_hotplug(); | ||
423 | break; | 427 | break; |
424 | } | 428 | } |
425 | return 0; | 429 | return 0; |
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 44ae5e5b94cf..a06c204589cd 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/cpufreq.h> | 20 | #include <linux/cpufreq.h> |
21 | #include <linux/cpu.h> | ||
21 | #include <linux/types.h> | 22 | #include <linux/types.h> |
22 | #include <linux/fs.h> | 23 | #include <linux/fs.h> |
23 | #include <linux/sysfs.h> | 24 | #include <linux/sysfs.h> |
@@ -70,6 +71,7 @@ static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy) | |||
70 | 71 | ||
71 | dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); | 72 | dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); |
72 | 73 | ||
74 | lock_cpu_hotplug(); | ||
73 | mutex_lock(&userspace_mutex); | 75 | mutex_lock(&userspace_mutex); |
74 | if (!cpu_is_managed[policy->cpu]) | 76 | if (!cpu_is_managed[policy->cpu]) |
75 | goto err; | 77 | goto err; |
@@ -92,6 +94,7 @@ static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy) | |||
92 | 94 | ||
93 | err: | 95 | err: |
94 | mutex_unlock(&userspace_mutex); | 96 | mutex_unlock(&userspace_mutex); |
97 | unlock_cpu_hotplug(); | ||
95 | return ret; | 98 | return ret; |
96 | } | 99 | } |
97 | 100 | ||