aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/Kconfig27
-rw-r--r--drivers/cpufreq/cpufreq.c34
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c19
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c22
-rw-r--r--drivers/cpufreq/cpufreq_stats.c18
5 files changed, 77 insertions, 43 deletions
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 993fa7b89253..721f86f4f008 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -56,10 +56,6 @@ config CPU_FREQ_STAT_DETAILS
56 56
57 If in doubt, say N. 57 If in doubt, say N.
58 58
59# Note that it is not currently possible to set the other governors (such as ondemand)
60# as the default, since if they fail to initialise, cpufreq will be
61# left in an undefined state.
62
63choice 59choice
64 prompt "Default CPUFreq governor" 60 prompt "Default CPUFreq governor"
65 default CPU_FREQ_DEFAULT_GOV_USERSPACE if CPU_FREQ_SA1100 || CPU_FREQ_SA1110 61 default CPU_FREQ_DEFAULT_GOV_USERSPACE if CPU_FREQ_SA1100 || CPU_FREQ_SA1110
@@ -85,6 +81,29 @@ config CPU_FREQ_DEFAULT_GOV_USERSPACE
85 program shall be able to set the CPU dynamically without having 81 program shall be able to set the CPU dynamically without having
86 to enable the userspace governor manually. 82 to enable the userspace governor manually.
87 83
84config CPU_FREQ_DEFAULT_GOV_ONDEMAND
85 bool "ondemand"
86 select CPU_FREQ_GOV_ONDEMAND
87 select CPU_FREQ_GOV_PERFORMANCE
88 help
89 Use the CPUFreq governor 'ondemand' as default. This allows
90 you to get a full dynamic frequency capable system by simply
91 loading your cpufreq low-level hardware driver.
92 Be aware that not all cpufreq drivers support the ondemand
93 governor. If unsure have a look at the help section of the
94 driver. Fallback governor will be the performance governor.
95
96config CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
97 bool "conservative"
98 select CPU_FREQ_GOV_CONSERVATIVE
99 select CPU_FREQ_GOV_PERFORMANCE
100 help
101 Use the CPUFreq governor 'conservative' as default. This allows
102 you to get a full dynamic frequency capable system by simply
103 loading your cpufreq low-level hardware driver.
104 Be aware that not all cpufreq drivers support the conservative
105 governor. If unsure have a look at the help section of the
106 driver. Fallback governor will be the performance governor.
88endchoice 107endchoice
89 108
90config CPU_FREQ_GOV_PERFORMANCE 109config CPU_FREQ_GOV_PERFORMANCE
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 2ce3de5e84af..5e626b12b97e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -763,6 +763,8 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
763 init_completion(&policy->kobj_unregister); 763 init_completion(&policy->kobj_unregister);
764 INIT_WORK(&policy->update, handle_update); 764 INIT_WORK(&policy->update, handle_update);
765 765
766 /* Set governor before ->init, so that driver could check it */
767 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
766 /* call driver. From then on the cpufreq must be able 768 /* call driver. From then on the cpufreq must be able
767 * to accept all calls to ->verify and ->setpolicy for this CPU 769 * to accept all calls to ->verify and ->setpolicy for this CPU
768 */ 770 */
@@ -1109,12 +1111,7 @@ unsigned int cpufreq_quick_get(unsigned int cpu)
1109 unsigned int ret_freq = 0; 1111 unsigned int ret_freq = 0;
1110 1112
1111 if (policy) { 1113 if (policy) {
1112 if (unlikely(lock_policy_rwsem_read(cpu)))
1113 return ret_freq;
1114
1115 ret_freq = policy->cur; 1114 ret_freq = policy->cur;
1116
1117 unlock_policy_rwsem_read(cpu);
1118 cpufreq_cpu_put(policy); 1115 cpufreq_cpu_put(policy);
1119 } 1116 }
1120 1117
@@ -1483,6 +1480,31 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
1483{ 1480{
1484 int ret; 1481 int ret;
1485 1482
1483 /* Only must be defined when default governor is known to have latency
1484 restrictions, like e.g. conservative or ondemand.
1485 That this is the case is already ensured in Kconfig
1486 */
1487#ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE
1488 struct cpufreq_governor *gov = &cpufreq_gov_performance;
1489#else
1490 struct cpufreq_governor *gov = NULL;
1491#endif
1492
1493 if (policy->governor->max_transition_latency &&
1494 policy->cpuinfo.transition_latency >
1495 policy->governor->max_transition_latency) {
1496 if (!gov)
1497 return -EINVAL;
1498 else {
1499 printk(KERN_WARNING "%s governor failed, too long"
1500 " transition latency of HW, fallback"
1501 " to %s governor\n",
1502 policy->governor->name,
1503 gov->name);
1504 policy->governor = gov;
1505 }
1506 }
1507
1486 if (!try_module_get(policy->governor->owner)) 1508 if (!try_module_get(policy->governor->owner))
1487 return -EINVAL; 1509 return -EINVAL;
1488 1510
@@ -1703,7 +1725,7 @@ int cpufreq_update_policy(unsigned int cpu)
1703} 1725}
1704EXPORT_SYMBOL(cpufreq_update_policy); 1726EXPORT_SYMBOL(cpufreq_update_policy);
1705 1727
1706static int cpufreq_cpu_callback(struct notifier_block *nfb, 1728static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
1707 unsigned long action, void *hcpu) 1729 unsigned long action, void *hcpu)
1708{ 1730{
1709 unsigned int cpu = (unsigned long)hcpu; 1731 unsigned int cpu = (unsigned long)hcpu;
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 26f440ccc3fb..4bd33ce8a6f3 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -58,7 +58,7 @@ static unsigned int def_sampling_rate;
58#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 58#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
59#define DEF_SAMPLING_DOWN_FACTOR (1) 59#define DEF_SAMPLING_DOWN_FACTOR (1)
60#define MAX_SAMPLING_DOWN_FACTOR (10) 60#define MAX_SAMPLING_DOWN_FACTOR (10)
61#define TRANSITION_LATENCY_LIMIT (10 * 1000) 61#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
62 62
63static void do_dbs_timer(struct work_struct *work); 63static void do_dbs_timer(struct work_struct *work);
64 64
@@ -466,9 +466,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
466 (!policy->cur)) 466 (!policy->cur))
467 return -EINVAL; 467 return -EINVAL;
468 468
469 if (policy->cpuinfo.transition_latency >
470 (TRANSITION_LATENCY_LIMIT * 1000))
471 return -EINVAL;
472 if (this_dbs_info->enable) /* Already enabled */ 469 if (this_dbs_info->enable) /* Already enabled */
473 break; 470 break;
474 471
@@ -551,15 +548,17 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
551 return 0; 548 return 0;
552} 549}
553 550
554static struct cpufreq_governor cpufreq_gov_dbs = { 551struct cpufreq_governor cpufreq_gov_conservative = {
555 .name = "conservative", 552 .name = "conservative",
556 .governor = cpufreq_governor_dbs, 553 .governor = cpufreq_governor_dbs,
557 .owner = THIS_MODULE, 554 .max_transition_latency = TRANSITION_LATENCY_LIMIT,
555 .owner = THIS_MODULE,
558}; 556};
557EXPORT_SYMBOL(cpufreq_gov_conservative);
559 558
560static int __init cpufreq_gov_dbs_init(void) 559static int __init cpufreq_gov_dbs_init(void)
561{ 560{
562 return cpufreq_register_governor(&cpufreq_gov_dbs); 561 return cpufreq_register_governor(&cpufreq_gov_conservative);
563} 562}
564 563
565static void __exit cpufreq_gov_dbs_exit(void) 564static void __exit cpufreq_gov_dbs_exit(void)
@@ -567,7 +566,7 @@ static void __exit cpufreq_gov_dbs_exit(void)
567 /* Make sure that the scheduled work is indeed not running */ 566 /* Make sure that the scheduled work is indeed not running */
568 flush_scheduled_work(); 567 flush_scheduled_work();
569 568
570 cpufreq_unregister_governor(&cpufreq_gov_dbs); 569 cpufreq_unregister_governor(&cpufreq_gov_conservative);
571} 570}
572 571
573 572
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index e794527e4925..369f44595150 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -47,7 +47,7 @@ static unsigned int def_sampling_rate;
47 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) 47 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
48#define MAX_SAMPLING_RATE (500 * def_sampling_rate) 48#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
49#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 49#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
50#define TRANSITION_LATENCY_LIMIT (10 * 1000) 50#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
51 51
52static void do_dbs_timer(struct work_struct *work); 52static void do_dbs_timer(struct work_struct *work);
53 53
@@ -508,12 +508,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
508 if ((!cpu_online(cpu)) || (!policy->cur)) 508 if ((!cpu_online(cpu)) || (!policy->cur))
509 return -EINVAL; 509 return -EINVAL;
510 510
511 if (policy->cpuinfo.transition_latency >
512 (TRANSITION_LATENCY_LIMIT * 1000)) {
513 printk(KERN_WARNING "ondemand governor failed to load "
514 "due to too long transition latency\n");
515 return -EINVAL;
516 }
517 if (this_dbs_info->enable) /* Already enabled */ 511 if (this_dbs_info->enable) /* Already enabled */
518 break; 512 break;
519 513
@@ -585,11 +579,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
585 return 0; 579 return 0;
586} 580}
587 581
588static struct cpufreq_governor cpufreq_gov_dbs = { 582struct cpufreq_governor cpufreq_gov_ondemand = {
589 .name = "ondemand", 583 .name = "ondemand",
590 .governor = cpufreq_governor_dbs, 584 .governor = cpufreq_governor_dbs,
591 .owner = THIS_MODULE, 585 .max_transition_latency = TRANSITION_LATENCY_LIMIT,
586 .owner = THIS_MODULE,
592}; 587};
588EXPORT_SYMBOL(cpufreq_gov_ondemand);
593 589
594static int __init cpufreq_gov_dbs_init(void) 590static int __init cpufreq_gov_dbs_init(void)
595{ 591{
@@ -598,12 +594,12 @@ static int __init cpufreq_gov_dbs_init(void)
598 printk(KERN_ERR "Creation of kondemand failed\n"); 594 printk(KERN_ERR "Creation of kondemand failed\n");
599 return -EFAULT; 595 return -EFAULT;
600 } 596 }
601 return cpufreq_register_governor(&cpufreq_gov_dbs); 597 return cpufreq_register_governor(&cpufreq_gov_ondemand);
602} 598}
603 599
604static void __exit cpufreq_gov_dbs_exit(void) 600static void __exit cpufreq_gov_dbs_exit(void)
605{ 601{
606 cpufreq_unregister_governor(&cpufreq_gov_dbs); 602 cpufreq_unregister_governor(&cpufreq_gov_ondemand);
607 destroy_workqueue(kondemand_wq); 603 destroy_workqueue(kondemand_wq);
608} 604}
609 605
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 917b9bab9ccb..8a45d0f93e26 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -164,8 +164,7 @@ freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq)
164 return -1; 164 return -1;
165} 165}
166 166
167static void 167static void __cpuexit cpufreq_stats_free_table(unsigned int cpu)
168cpufreq_stats_free_table (unsigned int cpu)
169{ 168{
170 struct cpufreq_stats *stat = cpufreq_stats_table[cpu]; 169 struct cpufreq_stats *stat = cpufreq_stats_table[cpu];
171 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 170 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
@@ -305,8 +304,9 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val,
305 return 0; 304 return 0;
306} 305}
307 306
308static int cpufreq_stat_cpu_callback(struct notifier_block *nfb, 307static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
309 unsigned long action, void *hcpu) 308 unsigned long action,
309 void *hcpu)
310{ 310{
311 unsigned int cpu = (unsigned long)hcpu; 311 unsigned int cpu = (unsigned long)hcpu;
312 312
@@ -323,7 +323,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
323 return NOTIFY_OK; 323 return NOTIFY_OK;
324} 324}
325 325
326static struct notifier_block cpufreq_stat_cpu_notifier = 326static struct notifier_block cpufreq_stat_cpu_notifier __cpuinitdata =
327{ 327{
328 .notifier_call = cpufreq_stat_cpu_callback, 328 .notifier_call = cpufreq_stat_cpu_callback,
329}; 329};
@@ -356,8 +356,7 @@ __init cpufreq_stats_init(void)
356 356
357 register_hotcpu_notifier(&cpufreq_stat_cpu_notifier); 357 register_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
358 for_each_online_cpu(cpu) { 358 for_each_online_cpu(cpu) {
359 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, 359 cpufreq_update_policy(cpu);
360 CPU_ONLINE, (void *)(long)cpu);
361 } 360 }
362 return 0; 361 return 0;
363} 362}
@@ -372,13 +371,12 @@ __exit cpufreq_stats_exit(void)
372 CPUFREQ_TRANSITION_NOTIFIER); 371 CPUFREQ_TRANSITION_NOTIFIER);
373 unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); 372 unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
374 for_each_online_cpu(cpu) { 373 for_each_online_cpu(cpu) {
375 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, 374 cpufreq_stats_free_table(cpu);
376 CPU_DEAD, (void *)(long)cpu);
377 } 375 }
378} 376}
379 377
380MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); 378MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>");
381MODULE_DESCRIPTION ("'cpufreq_stats' - A driver to export cpufreq stats" 379MODULE_DESCRIPTION ("'cpufreq_stats' - A driver to export cpufreq stats "
382 "through sysfs filesystem"); 380 "through sysfs filesystem");
383MODULE_LICENSE ("GPL"); 381MODULE_LICENSE ("GPL");
384 382