diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 44 |
1 files changed, 22 insertions, 22 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 | } |