diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 136 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 23 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 12 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_performance.c | 9 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_powersave.c | 9 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 11 | ||||
-rw-r--r-- | drivers/cpufreq/freq_table.c | 28 |
7 files changed, 150 insertions, 78 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 56c433e64d58..0c18ac2fe7c2 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -29,7 +29,8 @@ | |||
29 | #include <linux/completion.h> | 29 | #include <linux/completion.h> |
30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
31 | 31 | ||
32 | #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "cpufreq-core", msg) | 32 | #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, \ |
33 | "cpufreq-core", msg) | ||
33 | 34 | ||
34 | /** | 35 | /** |
35 | * The "cpufreq driver" - the arch- or hardware-dependent low | 36 | * The "cpufreq driver" - the arch- or hardware-dependent low |
@@ -41,7 +42,8 @@ static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS]; | |||
41 | static DEFINE_SPINLOCK(cpufreq_driver_lock); | 42 | static DEFINE_SPINLOCK(cpufreq_driver_lock); |
42 | 43 | ||
43 | /* internal prototypes */ | 44 | /* internal prototypes */ |
44 | static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); | 45 | static int __cpufreq_governor(struct cpufreq_policy *policy, |
46 | unsigned int event); | ||
45 | static void handle_update(void *data); | 47 | static void handle_update(void *data); |
46 | 48 | ||
47 | /** | 49 | /** |
@@ -151,7 +153,8 @@ static void cpufreq_debug_disable_ratelimit(void) | |||
151 | spin_unlock_irqrestore(&disable_ratelimit_lock, flags); | 153 | spin_unlock_irqrestore(&disable_ratelimit_lock, flags); |
152 | } | 154 | } |
153 | 155 | ||
154 | void cpufreq_debug_printk(unsigned int type, const char *prefix, const char *fmt, ...) | 156 | void cpufreq_debug_printk(unsigned int type, const char *prefix, |
157 | const char *fmt, ...) | ||
155 | { | 158 | { |
156 | char s[256]; | 159 | char s[256]; |
157 | va_list args; | 160 | va_list args; |
@@ -161,7 +164,8 @@ void cpufreq_debug_printk(unsigned int type, const char *prefix, const char *fmt | |||
161 | WARN_ON(!prefix); | 164 | WARN_ON(!prefix); |
162 | if (type & debug) { | 165 | if (type & debug) { |
163 | spin_lock_irqsave(&disable_ratelimit_lock, flags); | 166 | spin_lock_irqsave(&disable_ratelimit_lock, flags); |
164 | if (!disable_ratelimit && debug_ratelimit && !printk_ratelimit()) { | 167 | if (!disable_ratelimit && debug_ratelimit |
168 | && !printk_ratelimit()) { | ||
165 | spin_unlock_irqrestore(&disable_ratelimit_lock, flags); | 169 | spin_unlock_irqrestore(&disable_ratelimit_lock, flags); |
166 | return; | 170 | return; |
167 | } | 171 | } |
@@ -182,10 +186,12 @@ EXPORT_SYMBOL(cpufreq_debug_printk); | |||
182 | 186 | ||
183 | 187 | ||
184 | module_param(debug, uint, 0644); | 188 | module_param(debug, uint, 0644); |
185 | MODULE_PARM_DESC(debug, "CPUfreq debugging: add 1 to debug core, 2 to debug drivers, and 4 to debug governors."); | 189 | MODULE_PARM_DESC(debug, "CPUfreq debugging: add 1 to debug core," |
190 | " 2 to debug drivers, and 4 to debug governors."); | ||
186 | 191 | ||
187 | module_param(debug_ratelimit, uint, 0644); | 192 | module_param(debug_ratelimit, uint, 0644); |
188 | MODULE_PARM_DESC(debug_ratelimit, "CPUfreq debugging: set to 0 to disable ratelimiting."); | 193 | MODULE_PARM_DESC(debug_ratelimit, "CPUfreq debugging:" |
194 | " set to 0 to disable ratelimiting."); | ||
189 | 195 | ||
190 | #else /* !CONFIG_CPU_FREQ_DEBUG */ | 196 | #else /* !CONFIG_CPU_FREQ_DEBUG */ |
191 | 197 | ||
@@ -219,17 +225,23 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) | |||
219 | if (!l_p_j_ref_freq) { | 225 | if (!l_p_j_ref_freq) { |
220 | l_p_j_ref = loops_per_jiffy; | 226 | l_p_j_ref = loops_per_jiffy; |
221 | l_p_j_ref_freq = ci->old; | 227 | l_p_j_ref_freq = ci->old; |
222 | dprintk("saving %lu as reference value for loops_per_jiffy; freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); | 228 | dprintk("saving %lu as reference value for loops_per_jiffy;" |
229 | "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); | ||
223 | } | 230 | } |
224 | if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) || | 231 | if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) || |
225 | (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) || | 232 | (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) || |
226 | (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { | 233 | (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { |
227 | loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, ci->new); | 234 | loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, |
228 | dprintk("scaling loops_per_jiffy to %lu for frequency %u kHz\n", loops_per_jiffy, ci->new); | 235 | ci->new); |
236 | dprintk("scaling loops_per_jiffy to %lu" | ||
237 | "for frequency %u kHz\n", loops_per_jiffy, ci->new); | ||
229 | } | 238 | } |
230 | } | 239 | } |
231 | #else | 240 | #else |
232 | static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) { return; } | 241 | static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) |
242 | { | ||
243 | return; | ||
244 | } | ||
233 | #endif | 245 | #endif |
234 | 246 | ||
235 | 247 | ||
@@ -316,7 +328,8 @@ static int cpufreq_parse_governor (char *str_governor, unsigned int *policy, | |||
316 | if (!strnicmp(str_governor, "performance", CPUFREQ_NAME_LEN)) { | 328 | if (!strnicmp(str_governor, "performance", CPUFREQ_NAME_LEN)) { |
317 | *policy = CPUFREQ_POLICY_PERFORMANCE; | 329 | *policy = CPUFREQ_POLICY_PERFORMANCE; |
318 | err = 0; | 330 | err = 0; |
319 | } else if (!strnicmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) { | 331 | } else if (!strnicmp(str_governor, "powersave", |
332 | CPUFREQ_NAME_LEN)) { | ||
320 | *policy = CPUFREQ_POLICY_POWERSAVE; | 333 | *policy = CPUFREQ_POLICY_POWERSAVE; |
321 | err = 0; | 334 | err = 0; |
322 | } | 335 | } |
@@ -328,7 +341,8 @@ static int cpufreq_parse_governor (char *str_governor, unsigned int *policy, | |||
328 | t = __find_governor(str_governor); | 341 | t = __find_governor(str_governor); |
329 | 342 | ||
330 | if (t == NULL) { | 343 | if (t == NULL) { |
331 | char *name = kasprintf(GFP_KERNEL, "cpufreq_%s", str_governor); | 344 | char *name = kasprintf(GFP_KERNEL, "cpufreq_%s", |
345 | str_governor); | ||
332 | 346 | ||
333 | if (name) { | 347 | if (name) { |
334 | int ret; | 348 | int ret; |
@@ -361,7 +375,8 @@ extern struct sysdev_class cpu_sysdev_class; | |||
361 | 375 | ||
362 | 376 | ||
363 | /** | 377 | /** |
364 | * cpufreq_per_cpu_attr_read() / show_##file_name() - print out cpufreq information | 378 | * cpufreq_per_cpu_attr_read() / show_##file_name() - |
379 | * print out cpufreq information | ||
365 | * | 380 | * |
366 | * Write out information from cpufreq_driver->policy[cpu]; object must be | 381 | * Write out information from cpufreq_driver->policy[cpu]; object must be |
367 | * "unsigned int". | 382 | * "unsigned int". |
@@ -380,7 +395,8 @@ show_one(scaling_min_freq, min); | |||
380 | show_one(scaling_max_freq, max); | 395 | show_one(scaling_max_freq, max); |
381 | show_one(scaling_cur_freq, cur); | 396 | show_one(scaling_cur_freq, cur); |
382 | 397 | ||
383 | static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy); | 398 | static int __cpufreq_set_policy(struct cpufreq_policy *data, |
399 | struct cpufreq_policy *policy); | ||
384 | 400 | ||
385 | /** | 401 | /** |
386 | * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access | 402 | * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access |
@@ -416,7 +432,8 @@ store_one(scaling_max_freq,max); | |||
416 | /** | 432 | /** |
417 | * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware | 433 | * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware |
418 | */ | 434 | */ |
419 | static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, char *buf) | 435 | static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, |
436 | char *buf) | ||
420 | { | 437 | { |
421 | unsigned int cur_freq = cpufreq_get(policy->cpu); | 438 | unsigned int cur_freq = cpufreq_get(policy->cpu); |
422 | if (!cur_freq) | 439 | if (!cur_freq) |
@@ -428,7 +445,8 @@ static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, char *buf) | |||
428 | /** | 445 | /** |
429 | * show_scaling_governor - show the current policy for the specified CPU | 446 | * show_scaling_governor - show the current policy for the specified CPU |
430 | */ | 447 | */ |
431 | static ssize_t show_scaling_governor (struct cpufreq_policy * policy, char *buf) | 448 | static ssize_t show_scaling_governor (struct cpufreq_policy * policy, |
449 | char *buf) | ||
432 | { | 450 | { |
433 | if(policy->policy == CPUFREQ_POLICY_POWERSAVE) | 451 | if(policy->policy == CPUFREQ_POLICY_POWERSAVE) |
434 | return sprintf(buf, "powersave\n"); | 452 | return sprintf(buf, "powersave\n"); |
@@ -458,7 +476,8 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy, | |||
458 | if (ret != 1) | 476 | if (ret != 1) |
459 | return -EINVAL; | 477 | return -EINVAL; |
460 | 478 | ||
461 | if (cpufreq_parse_governor(str_governor, &new_policy.policy, &new_policy.governor)) | 479 | if (cpufreq_parse_governor(str_governor, &new_policy.policy, |
480 | &new_policy.governor)) | ||
462 | return -EINVAL; | 481 | return -EINVAL; |
463 | 482 | ||
464 | lock_cpu_hotplug(); | 483 | lock_cpu_hotplug(); |
@@ -474,7 +493,10 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy, | |||
474 | 493 | ||
475 | unlock_cpu_hotplug(); | 494 | unlock_cpu_hotplug(); |
476 | 495 | ||
477 | return ret ? ret : count; | 496 | if (ret) |
497 | return ret; | ||
498 | else | ||
499 | return count; | ||
478 | } | 500 | } |
479 | 501 | ||
480 | /** | 502 | /** |
@@ -488,7 +510,7 @@ static ssize_t show_scaling_driver (struct cpufreq_policy * policy, char *buf) | |||
488 | /** | 510 | /** |
489 | * show_scaling_available_governors - show the available CPUfreq governors | 511 | * show_scaling_available_governors - show the available CPUfreq governors |
490 | */ | 512 | */ |
491 | static ssize_t show_scaling_available_governors (struct cpufreq_policy * policy, | 513 | static ssize_t show_scaling_available_governors (struct cpufreq_policy *policy, |
492 | char *buf) | 514 | char *buf) |
493 | { | 515 | { |
494 | ssize_t i = 0; | 516 | ssize_t i = 0; |
@@ -574,7 +596,11 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf) | |||
574 | policy = cpufreq_cpu_get(policy->cpu); | 596 | policy = cpufreq_cpu_get(policy->cpu); |
575 | if (!policy) | 597 | if (!policy) |
576 | return -EINVAL; | 598 | return -EINVAL; |
577 | ret = fattr->show ? fattr->show(policy,buf) : -EIO; | 599 | if (fattr->show) |
600 | ret = fattr->show(policy, buf); | ||
601 | else | ||
602 | ret = -EIO; | ||
603 | |||
578 | cpufreq_cpu_put(policy); | 604 | cpufreq_cpu_put(policy); |
579 | return ret; | 605 | return ret; |
580 | } | 606 | } |
@@ -588,7 +614,11 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr, | |||
588 | policy = cpufreq_cpu_get(policy->cpu); | 614 | policy = cpufreq_cpu_get(policy->cpu); |
589 | if (!policy) | 615 | if (!policy) |
590 | return -EINVAL; | 616 | return -EINVAL; |
591 | ret = fattr->store ? fattr->store(policy,buf,count) : -EIO; | 617 | if (fattr->store) |
618 | ret = fattr->store(policy, buf, count); | ||
619 | else | ||
620 | ret = -EIO; | ||
621 | |||
592 | cpufreq_cpu_put(policy); | 622 | cpufreq_cpu_put(policy); |
593 | return ret; | 623 | return ret; |
594 | } | 624 | } |
@@ -911,7 +941,8 @@ static void handle_update(void *data) | |||
911 | * We adjust to current frequency first, and need to clean up later. So either call | 941 | * We adjust to current frequency first, and need to clean up later. So either call |
912 | * to cpufreq_update_policy() or schedule handle_update()). | 942 | * to cpufreq_update_policy() or schedule handle_update()). |
913 | */ | 943 | */ |
914 | static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigned int new_freq) | 944 | static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, |
945 | unsigned int new_freq) | ||
915 | { | 946 | { |
916 | struct cpufreq_freqs freqs; | 947 | struct cpufreq_freqs freqs; |
917 | 948 | ||
@@ -936,16 +967,16 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne | |||
936 | unsigned int cpufreq_quick_get(unsigned int cpu) | 967 | unsigned int cpufreq_quick_get(unsigned int cpu) |
937 | { | 968 | { |
938 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | 969 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); |
939 | unsigned int ret = 0; | 970 | unsigned int ret_freq = 0; |
940 | 971 | ||
941 | if (policy) { | 972 | if (policy) { |
942 | mutex_lock(&policy->lock); | 973 | mutex_lock(&policy->lock); |
943 | ret = policy->cur; | 974 | ret_freq = policy->cur; |
944 | mutex_unlock(&policy->lock); | 975 | mutex_unlock(&policy->lock); |
945 | cpufreq_cpu_put(policy); | 976 | cpufreq_cpu_put(policy); |
946 | } | 977 | } |
947 | 978 | ||
948 | return (ret); | 979 | return (ret_freq); |
949 | } | 980 | } |
950 | EXPORT_SYMBOL(cpufreq_quick_get); | 981 | EXPORT_SYMBOL(cpufreq_quick_get); |
951 | 982 | ||
@@ -959,7 +990,7 @@ EXPORT_SYMBOL(cpufreq_quick_get); | |||
959 | unsigned int cpufreq_get(unsigned int cpu) | 990 | unsigned int cpufreq_get(unsigned int cpu) |
960 | { | 991 | { |
961 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | 992 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); |
962 | unsigned int ret = 0; | 993 | unsigned int ret_freq = 0; |
963 | 994 | ||
964 | if (!policy) | 995 | if (!policy) |
965 | return 0; | 996 | return 0; |
@@ -969,12 +1000,14 @@ unsigned int cpufreq_get(unsigned int cpu) | |||
969 | 1000 | ||
970 | mutex_lock(&policy->lock); | 1001 | mutex_lock(&policy->lock); |
971 | 1002 | ||
972 | ret = cpufreq_driver->get(cpu); | 1003 | ret_freq = cpufreq_driver->get(cpu); |
973 | 1004 | ||
974 | if (ret && policy->cur && !(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) { | 1005 | if (ret_freq && policy->cur && |
975 | /* verify no discrepancy between actual and saved value exists */ | 1006 | !(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) { |
976 | if (unlikely(ret != policy->cur)) { | 1007 | /* verify no discrepancy between actual and |
977 | cpufreq_out_of_sync(cpu, policy->cur, ret); | 1008 | saved value exists */ |
1009 | if (unlikely(ret_freq != policy->cur)) { | ||
1010 | cpufreq_out_of_sync(cpu, policy->cur, ret_freq); | ||
978 | schedule_work(&policy->update); | 1011 | schedule_work(&policy->update); |
979 | } | 1012 | } |
980 | } | 1013 | } |
@@ -984,7 +1017,7 @@ unsigned int cpufreq_get(unsigned int cpu) | |||
984 | out: | 1017 | out: |
985 | cpufreq_cpu_put(policy); | 1018 | cpufreq_cpu_put(policy); |
986 | 1019 | ||
987 | return (ret); | 1020 | return (ret_freq); |
988 | } | 1021 | } |
989 | EXPORT_SYMBOL(cpufreq_get); | 1022 | EXPORT_SYMBOL(cpufreq_get); |
990 | 1023 | ||
@@ -996,7 +1029,7 @@ EXPORT_SYMBOL(cpufreq_get); | |||
996 | static int cpufreq_suspend(struct sys_device * sysdev, pm_message_t pmsg) | 1029 | static int cpufreq_suspend(struct sys_device * sysdev, pm_message_t pmsg) |
997 | { | 1030 | { |
998 | int cpu = sysdev->id; | 1031 | int cpu = sysdev->id; |
999 | unsigned int ret = 0; | 1032 | int ret = 0; |
1000 | unsigned int cur_freq = 0; | 1033 | unsigned int cur_freq = 0; |
1001 | struct cpufreq_policy *cpu_policy; | 1034 | struct cpufreq_policy *cpu_policy; |
1002 | 1035 | ||
@@ -1078,7 +1111,7 @@ out: | |||
1078 | static int cpufreq_resume(struct sys_device * sysdev) | 1111 | static int cpufreq_resume(struct sys_device * sysdev) |
1079 | { | 1112 | { |
1080 | int cpu = sysdev->id; | 1113 | int cpu = sysdev->id; |
1081 | unsigned int ret = 0; | 1114 | int ret = 0; |
1082 | struct cpufreq_policy *cpu_policy; | 1115 | struct cpufreq_policy *cpu_policy; |
1083 | 1116 | ||
1084 | dprintk("resuming cpu %u\n", cpu); | 1117 | dprintk("resuming cpu %u\n", cpu); |
@@ -1299,17 +1332,20 @@ EXPORT_SYMBOL_GPL(cpufreq_driver_getavg); | |||
1299 | * when "event" is CPUFREQ_GOV_LIMITS | 1332 | * when "event" is CPUFREQ_GOV_LIMITS |
1300 | */ | 1333 | */ |
1301 | 1334 | ||
1302 | static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) | 1335 | static int __cpufreq_governor(struct cpufreq_policy *policy, |
1336 | unsigned int event) | ||
1303 | { | 1337 | { |
1304 | int ret; | 1338 | int ret; |
1305 | 1339 | ||
1306 | if (!try_module_get(policy->governor->owner)) | 1340 | if (!try_module_get(policy->governor->owner)) |
1307 | return -EINVAL; | 1341 | return -EINVAL; |
1308 | 1342 | ||
1309 | dprintk("__cpufreq_governor for CPU %u, event %u\n", policy->cpu, event); | 1343 | dprintk("__cpufreq_governor for CPU %u, event %u\n", |
1344 | policy->cpu, event); | ||
1310 | ret = policy->governor->governor(policy, event); | 1345 | ret = policy->governor->governor(policy, event); |
1311 | 1346 | ||
1312 | /* we keep one module reference alive for each CPU governed by this CPU */ | 1347 | /* we keep one module reference alive for |
1348 | each CPU governed by this CPU */ | ||
1313 | if ((event != CPUFREQ_GOV_START) || ret) | 1349 | if ((event != CPUFREQ_GOV_START) || ret) |
1314 | module_put(policy->governor->owner); | 1350 | module_put(policy->governor->owner); |
1315 | if ((event == CPUFREQ_GOV_STOP) && !ret) | 1351 | if ((event == CPUFREQ_GOV_STOP) && !ret) |
@@ -1385,9 +1421,12 @@ EXPORT_SYMBOL(cpufreq_get_policy); | |||
1385 | 1421 | ||
1386 | 1422 | ||
1387 | /* | 1423 | /* |
1424 | * data : current policy. | ||
1425 | * policy : policy to be set. | ||
1388 | * Locking: Must be called with the lock_cpu_hotplug() lock held | 1426 | * Locking: Must be called with the lock_cpu_hotplug() lock held |
1389 | */ | 1427 | */ |
1390 | static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy) | 1428 | static int __cpufreq_set_policy(struct cpufreq_policy *data, |
1429 | struct cpufreq_policy *policy) | ||
1391 | { | 1430 | { |
1392 | int ret = 0; | 1431 | int ret = 0; |
1393 | 1432 | ||
@@ -1395,7 +1434,8 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_poli | |||
1395 | dprintk("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu, | 1434 | dprintk("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu, |
1396 | policy->min, policy->max); | 1435 | policy->min, policy->max); |
1397 | 1436 | ||
1398 | memcpy(&policy->cpuinfo, &data->cpuinfo, sizeof(struct cpufreq_cpuinfo)); | 1437 | memcpy(&policy->cpuinfo, &data->cpuinfo, |
1438 | sizeof(struct cpufreq_cpuinfo)); | ||
1399 | 1439 | ||
1400 | if (policy->min > data->min && policy->min > policy->max) { | 1440 | if (policy->min > data->min && policy->min > policy->max) { |
1401 | ret = -EINVAL; | 1441 | ret = -EINVAL; |
@@ -1428,7 +1468,8 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_poli | |||
1428 | data->min = policy->min; | 1468 | data->min = policy->min; |
1429 | data->max = policy->max; | 1469 | data->max = policy->max; |
1430 | 1470 | ||
1431 | dprintk("new min and max freqs are %u - %u kHz\n", data->min, data->max); | 1471 | dprintk("new min and max freqs are %u - %u kHz\n", |
1472 | data->min, data->max); | ||
1432 | 1473 | ||
1433 | if (cpufreq_driver->setpolicy) { | 1474 | if (cpufreq_driver->setpolicy) { |
1434 | data->policy = policy->policy; | 1475 | data->policy = policy->policy; |
@@ -1449,10 +1490,12 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_poli | |||
1449 | data->governor = policy->governor; | 1490 | data->governor = policy->governor; |
1450 | if (__cpufreq_governor(data, CPUFREQ_GOV_START)) { | 1491 | if (__cpufreq_governor(data, CPUFREQ_GOV_START)) { |
1451 | /* new governor failed, so re-start old one */ | 1492 | /* new governor failed, so re-start old one */ |
1452 | dprintk("starting governor %s failed\n", data->governor->name); | 1493 | dprintk("starting governor %s failed\n", |
1494 | data->governor->name); | ||
1453 | if (old_gov) { | 1495 | if (old_gov) { |
1454 | data->governor = old_gov; | 1496 | data->governor = old_gov; |
1455 | __cpufreq_governor(data, CPUFREQ_GOV_START); | 1497 | __cpufreq_governor(data, |
1498 | CPUFREQ_GOV_START); | ||
1456 | } | 1499 | } |
1457 | ret = -EINVAL; | 1500 | ret = -EINVAL; |
1458 | goto error_out; | 1501 | goto error_out; |
@@ -1542,7 +1585,8 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1542 | data->cur = policy.cur; | 1585 | data->cur = policy.cur; |
1543 | } else { | 1586 | } else { |
1544 | if (data->cur != policy.cur) | 1587 | if (data->cur != policy.cur) |
1545 | cpufreq_out_of_sync(cpu, data->cur, policy.cur); | 1588 | cpufreq_out_of_sync(cpu, data->cur, |
1589 | policy.cur); | ||
1546 | } | 1590 | } |
1547 | } | 1591 | } |
1548 | 1592 | ||
@@ -1646,8 +1690,10 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
1646 | 1690 | ||
1647 | /* if all ->init() calls failed, unregister */ | 1691 | /* if all ->init() calls failed, unregister */ |
1648 | if (ret) { | 1692 | if (ret) { |
1649 | dprintk("no CPU initialized for driver %s\n", driver_data->name); | 1693 | dprintk("no CPU initialized for driver %s\n", |
1650 | sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver); | 1694 | driver_data->name); |
1695 | sysdev_driver_unregister(&cpu_sysdev_class, | ||
1696 | &cpufreq_sysdev_driver); | ||
1651 | 1697 | ||
1652 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1698 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
1653 | cpufreq_driver = NULL; | 1699 | cpufreq_driver = NULL; |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 8fe13ec1e50b..29905b4bf8c8 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -44,15 +44,17 @@ | |||
44 | * latency of the processor. The governor will work on any processor with | 44 | * latency of the processor. The governor will work on any processor with |
45 | * transition latency <= 10mS, using appropriate sampling | 45 | * transition latency <= 10mS, using appropriate sampling |
46 | * rate. | 46 | * rate. |
47 | * For CPUs with transition latency > 10mS (mostly drivers with CPUFREQ_ETERNAL) | 47 | * For CPUs with transition latency > 10mS (mostly drivers |
48 | * this governor will not work. | 48 | * with CPUFREQ_ETERNAL), this governor will not work. |
49 | * All times here are in uS. | 49 | * All times here are in uS. |
50 | */ | 50 | */ |
51 | static unsigned int def_sampling_rate; | 51 | static unsigned int def_sampling_rate; |
52 | #define MIN_SAMPLING_RATE_RATIO (2) | 52 | #define MIN_SAMPLING_RATE_RATIO (2) |
53 | /* for correct statistics, we need at least 10 ticks between each measure */ | 53 | /* for correct statistics, we need at least 10 ticks between each measure */ |
54 | #define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) | 54 | #define MIN_STAT_SAMPLING_RATE \ |
55 | #define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | 55 | (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) |
56 | #define MIN_SAMPLING_RATE \ | ||
57 | (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | ||
56 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) | 58 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) |
57 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) | 59 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) |
58 | #define DEF_SAMPLING_DOWN_FACTOR (1) | 60 | #define DEF_SAMPLING_DOWN_FACTOR (1) |
@@ -103,11 +105,16 @@ static struct dbs_tuners dbs_tuners_ins = { | |||
103 | 105 | ||
104 | static inline unsigned int get_cpu_idle_time(unsigned int cpu) | 106 | static inline unsigned int get_cpu_idle_time(unsigned int cpu) |
105 | { | 107 | { |
106 | return kstat_cpu(cpu).cpustat.idle + | 108 | unsigned int add_nice = 0, ret; |
109 | |||
110 | if (dbs_tuners_ins.ignore_nice) | ||
111 | add_nice = kstat_cpu(cpu).cpustat.nice; | ||
112 | |||
113 | ret = kstat_cpu(cpu).cpustat.idle + | ||
107 | kstat_cpu(cpu).cpustat.iowait + | 114 | kstat_cpu(cpu).cpustat.iowait + |
108 | ( dbs_tuners_ins.ignore_nice ? | 115 | add_nice; |
109 | kstat_cpu(cpu).cpustat.nice : | 116 | |
110 | 0); | 117 | return ret; |
111 | } | 118 | } |
112 | 119 | ||
113 | /************************** sysfs interface ************************/ | 120 | /************************** sysfs interface ************************/ |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index cbde076b5715..048ec8b1f406 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -41,8 +41,10 @@ | |||
41 | static unsigned int def_sampling_rate; | 41 | static unsigned int def_sampling_rate; |
42 | #define MIN_SAMPLING_RATE_RATIO (2) | 42 | #define MIN_SAMPLING_RATE_RATIO (2) |
43 | /* for correct statistics, we need at least 10 ticks between each measure */ | 43 | /* for correct statistics, we need at least 10 ticks between each measure */ |
44 | #define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) | 44 | #define MIN_STAT_SAMPLING_RATE \ |
45 | #define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | 45 | (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) |
46 | #define MIN_SAMPLING_RATE \ | ||
47 | (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | ||
46 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) | 48 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) |
47 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) | 49 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) |
48 | #define TRANSITION_LATENCY_LIMIT (10 * 1000) | 50 | #define TRANSITION_LATENCY_LIMIT (10 * 1000) |
@@ -202,7 +204,8 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
202 | ret = sscanf(buf, "%u", &input); | 204 | ret = sscanf(buf, "%u", &input); |
203 | 205 | ||
204 | mutex_lock(&dbs_mutex); | 206 | mutex_lock(&dbs_mutex); |
205 | if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) { | 207 | if (ret != 1 || input > MAX_SAMPLING_RATE |
208 | || input < MIN_SAMPLING_RATE) { | ||
206 | mutex_unlock(&dbs_mutex); | 209 | mutex_unlock(&dbs_mutex); |
207 | return -EINVAL; | 210 | return -EINVAL; |
208 | } | 211 | } |
@@ -496,7 +499,8 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
496 | if (dbs_enable == 1) { | 499 | if (dbs_enable == 1) { |
497 | kondemand_wq = create_workqueue("kondemand"); | 500 | kondemand_wq = create_workqueue("kondemand"); |
498 | if (!kondemand_wq) { | 501 | if (!kondemand_wq) { |
499 | printk(KERN_ERR "Creation of kondemand failed\n"); | 502 | printk(KERN_ERR |
503 | "Creation of kondemand failed\n"); | ||
500 | dbs_enable--; | 504 | dbs_enable--; |
501 | mutex_unlock(&dbs_mutex); | 505 | mutex_unlock(&dbs_mutex); |
502 | return -ENOSPC; | 506 | return -ENOSPC; |
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c index de91e3371ef8..e8e1451ef1c1 100644 --- a/drivers/cpufreq/cpufreq_performance.c +++ b/drivers/cpufreq/cpufreq_performance.c | |||
@@ -15,7 +15,8 @@ | |||
15 | #include <linux/cpufreq.h> | 15 | #include <linux/cpufreq.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | 17 | ||
18 | #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "performance", msg) | 18 | #define dprintk(msg...) \ |
19 | cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "performance", msg) | ||
19 | 20 | ||
20 | 21 | ||
21 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, | 22 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, |
@@ -24,8 +25,10 @@ static int cpufreq_governor_performance(struct cpufreq_policy *policy, | |||
24 | switch (event) { | 25 | switch (event) { |
25 | case CPUFREQ_GOV_START: | 26 | case CPUFREQ_GOV_START: |
26 | case CPUFREQ_GOV_LIMITS: | 27 | case CPUFREQ_GOV_LIMITS: |
27 | dprintk("setting to %u kHz because of event %u\n", policy->max, event); | 28 | dprintk("setting to %u kHz because of event %u\n", |
28 | __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); | 29 | policy->max, event); |
30 | __cpufreq_driver_target(policy, policy->max, | ||
31 | CPUFREQ_RELATION_H); | ||
29 | break; | 32 | break; |
30 | default: | 33 | default: |
31 | break; | 34 | break; |
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c index 0a2596044e65..13fe06b94b0a 100644 --- a/drivers/cpufreq/cpufreq_powersave.c +++ b/drivers/cpufreq/cpufreq_powersave.c | |||
@@ -15,7 +15,8 @@ | |||
15 | #include <linux/cpufreq.h> | 15 | #include <linux/cpufreq.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | 17 | ||
18 | #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "powersave", msg) | 18 | #define dprintk(msg...) \ |
19 | cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "powersave", msg) | ||
19 | 20 | ||
20 | static int cpufreq_governor_powersave(struct cpufreq_policy *policy, | 21 | static int cpufreq_governor_powersave(struct cpufreq_policy *policy, |
21 | unsigned int event) | 22 | unsigned int event) |
@@ -23,8 +24,10 @@ static int cpufreq_governor_powersave(struct cpufreq_policy *policy, | |||
23 | switch (event) { | 24 | switch (event) { |
24 | case CPUFREQ_GOV_START: | 25 | case CPUFREQ_GOV_START: |
25 | case CPUFREQ_GOV_LIMITS: | 26 | case CPUFREQ_GOV_LIMITS: |
26 | dprintk("setting to %u kHz because of event %u\n", policy->min, event); | 27 | dprintk("setting to %u kHz because of event %u\n", |
27 | __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); | 28 | policy->min, event); |
29 | __cpufreq_driver_target(policy, policy->min, | ||
30 | CPUFREQ_RELATION_L); | ||
28 | break; | 31 | break; |
29 | default: | 32 | default: |
30 | break; | 33 | break; |
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index c2ecc599dc5f..6742b1adf2c8 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -351,8 +351,8 @@ __init cpufreq_stats_init(void) | |||
351 | 351 | ||
352 | register_hotcpu_notifier(&cpufreq_stat_cpu_notifier); | 352 | register_hotcpu_notifier(&cpufreq_stat_cpu_notifier); |
353 | for_each_online_cpu(cpu) { | 353 | for_each_online_cpu(cpu) { |
354 | cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_ONLINE, | 354 | cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, |
355 | (void *)(long)cpu); | 355 | CPU_ONLINE, (void *)(long)cpu); |
356 | } | 356 | } |
357 | return 0; | 357 | return 0; |
358 | } | 358 | } |
@@ -368,14 +368,15 @@ __exit cpufreq_stats_exit(void) | |||
368 | unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); | 368 | unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); |
369 | lock_cpu_hotplug(); | 369 | lock_cpu_hotplug(); |
370 | for_each_online_cpu(cpu) { | 370 | for_each_online_cpu(cpu) { |
371 | cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_DEAD, | 371 | cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, |
372 | (void *)(long)cpu); | 372 | CPU_DEAD, (void *)(long)cpu); |
373 | } | 373 | } |
374 | unlock_cpu_hotplug(); | 374 | unlock_cpu_hotplug(); |
375 | } | 375 | } |
376 | 376 | ||
377 | MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); | 377 | MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); |
378 | MODULE_DESCRIPTION ("'cpufreq_stats' - A driver to export cpufreq stats through sysfs filesystem"); | 378 | MODULE_DESCRIPTION ("'cpufreq_stats' - A driver to export cpufreq stats" |
379 | "through sysfs filesystem"); | ||
379 | MODULE_LICENSE ("GPL"); | 380 | MODULE_LICENSE ("GPL"); |
380 | 381 | ||
381 | module_init(cpufreq_stats_init); | 382 | module_init(cpufreq_stats_init); |
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 551f4ccf87fd..e7490925fdcf 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -9,7 +9,8 @@ | |||
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/cpufreq.h> | 10 | #include <linux/cpufreq.h> |
11 | 11 | ||
12 | #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "freq-table", msg) | 12 | #define dprintk(msg...) \ |
13 | cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "freq-table", msg) | ||
13 | 14 | ||
14 | /********************************************************************* | 15 | /********************************************************************* |
15 | * FREQUENCY TABLE HELPERS * | 16 | * FREQUENCY TABLE HELPERS * |
@@ -29,7 +30,8 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | |||
29 | 30 | ||
30 | continue; | 31 | continue; |
31 | } | 32 | } |
32 | dprintk("table entry %u: %u kHz, %u index\n", i, freq, table[i].index); | 33 | dprintk("table entry %u: %u kHz, %u index\n", |
34 | i, freq, table[i].index); | ||
33 | if (freq < min_freq) | 35 | if (freq < min_freq) |
34 | min_freq = freq; | 36 | min_freq = freq; |
35 | if (freq > max_freq) | 37 | if (freq > max_freq) |
@@ -54,13 +56,14 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | |||
54 | unsigned int i; | 56 | unsigned int i; |
55 | unsigned int count = 0; | 57 | unsigned int count = 0; |
56 | 58 | ||
57 | dprintk("request for verification of policy (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); | 59 | dprintk("request for verification of policy (%u - %u kHz) for cpu %u\n", |
60 | policy->min, policy->max, policy->cpu); | ||
58 | 61 | ||
59 | if (!cpu_online(policy->cpu)) | 62 | if (!cpu_online(policy->cpu)) |
60 | return -EINVAL; | 63 | return -EINVAL; |
61 | 64 | ||
62 | cpufreq_verify_within_limits(policy, | 65 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, |
63 | policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); | 66 | policy->cpuinfo.max_freq); |
64 | 67 | ||
65 | for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | 68 | for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { |
66 | unsigned int freq = table[i].frequency; | 69 | unsigned int freq = table[i].frequency; |
@@ -75,10 +78,11 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | |||
75 | if (!count) | 78 | if (!count) |
76 | policy->max = next_larger; | 79 | policy->max = next_larger; |
77 | 80 | ||
78 | cpufreq_verify_within_limits(policy, | 81 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, |
79 | policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); | 82 | policy->cpuinfo.max_freq); |
80 | 83 | ||
81 | dprintk("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); | 84 | dprintk("verification lead to (%u - %u kHz) for cpu %u\n", |
85 | policy->min, policy->max, policy->cpu); | ||
82 | 86 | ||
83 | return 0; | 87 | return 0; |
84 | } | 88 | } |
@@ -101,7 +105,8 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
101 | }; | 105 | }; |
102 | unsigned int i; | 106 | unsigned int i; |
103 | 107 | ||
104 | dprintk("request for target %u kHz (relation: %u) for cpu %u\n", target_freq, relation, policy->cpu); | 108 | dprintk("request for target %u kHz (relation: %u) for cpu %u\n", |
109 | target_freq, relation, policy->cpu); | ||
105 | 110 | ||
106 | switch (relation) { | 111 | switch (relation) { |
107 | case CPUFREQ_RELATION_H: | 112 | case CPUFREQ_RELATION_H: |
@@ -192,7 +197,10 @@ static ssize_t show_available_freqs (struct cpufreq_policy *policy, char *buf) | |||
192 | } | 197 | } |
193 | 198 | ||
194 | struct freq_attr cpufreq_freq_attr_scaling_available_freqs = { | 199 | struct freq_attr cpufreq_freq_attr_scaling_available_freqs = { |
195 | .attr = { .name = "scaling_available_frequencies", .mode = 0444, .owner=THIS_MODULE }, | 200 | .attr = { .name = "scaling_available_frequencies", |
201 | .mode = 0444, | ||
202 | .owner=THIS_MODULE | ||
203 | }, | ||
196 | .show = show_available_freqs, | 204 | .show = show_available_freqs, |
197 | }; | 205 | }; |
198 | EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs); | 206 | EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs); |