aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:52:23 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:52:23 -0500
commitbe9bf30c73184e0f1e4e0a50fb193d2a551bf75e (patch)
treeb94e1b39d59fa10b26fd740993ded00708de08e1 /drivers
parentace48471736a4b00753c74633f430c4a3a7d89cb (diff)
parent84f0b1ef8c013b33dea9bbc2521094dd29110cf0 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
* master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq: [CPUFREQ] kzalloc conversion for gx-suspmod [CPUFREQ] Whitespace cleanup [CPUFREQ] Mark longhaul driver as broken. [PATCH] cpufreq: fix section mismatch warnings [CPUFREQ] Fix the p4-clockmod N60 errata workaround. [CPUFREQ] Fix handling for CPU hotplug [CPUFREQ] powernow-k8: Let cpufreq driver handle affected CPUs [CPUFREQ] Lots of whitespace & CodingStyle cleanup. [CPUFREQ] Remove duplicate cpuinfo struct [CPUFREQ] Silence powernow-k8 warning on k7's.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpufreq/cpufreq.c105
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c86
-rw-r--r--drivers/cpufreq/cpufreq_performance.c2
-rw-r--r--drivers/cpufreq/cpufreq_powersave.c2
-rw-r--r--drivers/cpufreq/cpufreq_stats.c8
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c12
-rw-r--r--drivers/cpufreq/freq_table.c12
7 files changed, 136 insertions, 91 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 9582de1c9cad..aed80e6aec6d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -5,7 +5,9 @@
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 * 6 *
7 * Oct 2005 - Ashok Raj <ashok.raj@intel.com> 7 * Oct 2005 - Ashok Raj <ashok.raj@intel.com>
8 * Added handling for CPU hotplug 8 * Added handling for CPU hotplug
9 * Feb 2006 - Jacob Shin <jacob.shin@amd.com>
10 * Fix handling for CPU hotplug -- affected CPUs
9 * 11 *
10 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 13 * it under the terms of the GNU General Public License version 2 as
@@ -44,8 +46,8 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
44static void handle_update(void *data); 46static void handle_update(void *data);
45 47
46/** 48/**
47 * Two notifier lists: the "policy" list is involved in the 49 * Two notifier lists: the "policy" list is involved in the
48 * validation process for a new CPU frequency policy; the 50 * validation process for a new CPU frequency policy; the
49 * "transition" list for kernel code that needs to handle 51 * "transition" list for kernel code that needs to handle
50 * changes to devices when the CPU clock speed changes. 52 * changes to devices when the CPU clock speed changes.
51 * The mutex locks both lists. 53 * The mutex locks both lists.
@@ -151,7 +153,7 @@ void cpufreq_debug_printk(unsigned int type, const char *prefix, const char *fmt
151 va_list args; 153 va_list args;
152 unsigned int len; 154 unsigned int len;
153 unsigned long flags; 155 unsigned long flags;
154 156
155 WARN_ON(!prefix); 157 WARN_ON(!prefix);
156 if (type & debug) { 158 if (type & debug) {
157 spin_lock_irqsave(&disable_ratelimit_lock, flags); 159 spin_lock_irqsave(&disable_ratelimit_lock, flags);
@@ -198,7 +200,7 @@ static inline void cpufreq_debug_disable_ratelimit(void) { return; }
198 * 200 *
199 * This function alters the system "loops_per_jiffy" for the clock 201 * This function alters the system "loops_per_jiffy" for the clock
200 * speed change. Note that loops_per_jiffy cannot be updated on SMP 202 * speed change. Note that loops_per_jiffy cannot be updated on SMP
201 * systems as each CPU might be scaled differently. So, use the arch 203 * systems as each CPU might be scaled differently. So, use the arch
202 * per-CPU loops_per_jiffy value wherever possible. 204 * per-CPU loops_per_jiffy value wherever possible.
203 */ 205 */
204#ifndef CONFIG_SMP 206#ifndef CONFIG_SMP
@@ -233,7 +235,7 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) {
233 * 235 *
234 * This function calls the transition notifiers and the "adjust_jiffies" 236 * This function calls the transition notifiers and the "adjust_jiffies"
235 * function. It is called twice on all CPU frequency changes that have 237 * function. It is called twice on all CPU frequency changes that have
236 * external effects. 238 * external effects.
237 */ 239 */
238void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) 240void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
239{ 241{
@@ -251,7 +253,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
251 switch (state) { 253 switch (state) {
252 254
253 case CPUFREQ_PRECHANGE: 255 case CPUFREQ_PRECHANGE:
254 /* detect if the driver reported a value as "old frequency" 256 /* detect if the driver reported a value as "old frequency"
255 * which is not equal to what the cpufreq core thinks is 257 * which is not equal to what the cpufreq core thinks is
256 * "old frequency". 258 * "old frequency".
257 */ 259 */
@@ -335,11 +337,11 @@ extern struct sysdev_class cpu_sysdev_class;
335 * "unsigned int". 337 * "unsigned int".
336 */ 338 */
337 339
338#define show_one(file_name, object) \ 340#define show_one(file_name, object) \
339static ssize_t show_##file_name \ 341static ssize_t show_##file_name \
340(struct cpufreq_policy * policy, char *buf) \ 342(struct cpufreq_policy * policy, char *buf) \
341{ \ 343{ \
342 return sprintf (buf, "%u\n", policy->object); \ 344 return sprintf (buf, "%u\n", policy->object); \
343} 345}
344 346
345show_one(cpuinfo_min_freq, cpuinfo.min_freq); 347show_one(cpuinfo_min_freq, cpuinfo.min_freq);
@@ -404,8 +406,8 @@ static ssize_t show_scaling_governor (struct cpufreq_policy * policy, char *buf)
404/** 406/**
405 * store_scaling_governor - store policy for the specified CPU 407 * store_scaling_governor - store policy for the specified CPU
406 */ 408 */
407static ssize_t store_scaling_governor (struct cpufreq_policy * policy, 409static ssize_t store_scaling_governor (struct cpufreq_policy * policy,
408 const char *buf, size_t count) 410 const char *buf, size_t count)
409{ 411{
410 unsigned int ret = -EINVAL; 412 unsigned int ret = -EINVAL;
411 char str_governor[16]; 413 char str_governor[16];
@@ -528,7 +530,7 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf)
528 return ret; 530 return ret;
529} 531}
530 532
531static ssize_t store(struct kobject * kobj, struct attribute * attr, 533static ssize_t store(struct kobject * kobj, struct attribute * attr,
532 const char * buf, size_t count) 534 const char * buf, size_t count)
533{ 535{
534 struct cpufreq_policy * policy = to_policy(kobj); 536 struct cpufreq_policy * policy = to_policy(kobj);
@@ -564,7 +566,7 @@ static struct kobj_type ktype_cpufreq = {
564/** 566/**
565 * cpufreq_add_dev - add a CPU device 567 * cpufreq_add_dev - add a CPU device
566 * 568 *
567 * Adds the cpufreq interface for a CPU device. 569 * Adds the cpufreq interface for a CPU device.
568 */ 570 */
569static int cpufreq_add_dev (struct sys_device * sys_dev) 571static int cpufreq_add_dev (struct sys_device * sys_dev)
570{ 572{
@@ -573,8 +575,12 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
573 struct cpufreq_policy new_policy; 575 struct cpufreq_policy new_policy;
574 struct cpufreq_policy *policy; 576 struct cpufreq_policy *policy;
575 struct freq_attr **drv_attr; 577 struct freq_attr **drv_attr;
578 struct sys_device *cpu_sys_dev;
576 unsigned long flags; 579 unsigned long flags;
577 unsigned int j; 580 unsigned int j;
581#ifdef CONFIG_SMP
582 struct cpufreq_policy *managed_policy;
583#endif
578 584
579 if (cpu_is_offline(cpu)) 585 if (cpu_is_offline(cpu))
580 return 0; 586 return 0;
@@ -587,8 +593,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
587 * CPU because it is in the same boat. */ 593 * CPU because it is in the same boat. */
588 policy = cpufreq_cpu_get(cpu); 594 policy = cpufreq_cpu_get(cpu);
589 if (unlikely(policy)) { 595 if (unlikely(policy)) {
590 dprintk("CPU already managed, adding link\n"); 596 cpufreq_cpu_put(policy);
591 sysfs_create_link(&sys_dev->kobj, &policy->kobj, "cpufreq");
592 cpufreq_debug_enable_ratelimit(); 597 cpufreq_debug_enable_ratelimit();
593 return 0; 598 return 0;
594 } 599 }
@@ -623,6 +628,32 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
623 goto err_out; 628 goto err_out;
624 } 629 }
625 630
631#ifdef CONFIG_SMP
632 for_each_cpu_mask(j, policy->cpus) {
633 if (cpu == j)
634 continue;
635
636 /* check for existing affected CPUs. They may not be aware
637 * of it due to CPU Hotplug.
638 */
639 managed_policy = cpufreq_cpu_get(j);
640 if (unlikely(managed_policy)) {
641 spin_lock_irqsave(&cpufreq_driver_lock, flags);
642 managed_policy->cpus = policy->cpus;
643 cpufreq_cpu_data[cpu] = managed_policy;
644 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
645
646 dprintk("CPU already managed, adding link\n");
647 sysfs_create_link(&sys_dev->kobj,
648 &managed_policy->kobj, "cpufreq");
649
650 cpufreq_debug_enable_ratelimit();
651 mutex_unlock(&policy->lock);
652 ret = 0;
653 goto err_out_driver_exit; /* call driver->exit() */
654 }
655 }
656#endif
626 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); 657 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
627 658
628 /* prepare interface data */ 659 /* prepare interface data */
@@ -650,6 +681,21 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
650 for_each_cpu_mask(j, policy->cpus) 681 for_each_cpu_mask(j, policy->cpus)
651 cpufreq_cpu_data[j] = policy; 682 cpufreq_cpu_data[j] = policy;
652 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 683 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
684
685 /* symlink affected CPUs */
686 for_each_cpu_mask(j, policy->cpus) {
687 if (j == cpu)
688 continue;
689 if (!cpu_online(j))
690 continue;
691
692 dprintk("CPU already managed, adding link\n");
693 cpufreq_cpu_get(cpu);
694 cpu_sys_dev = get_cpu_sysdev(j);
695 sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
696 "cpufreq");
697 }
698
653 policy->governor = NULL; /* to assure that the starting sequence is 699 policy->governor = NULL; /* to assure that the starting sequence is
654 * run in cpufreq_set_policy */ 700 * run in cpufreq_set_policy */
655 mutex_unlock(&policy->lock); 701 mutex_unlock(&policy->lock);
@@ -724,10 +770,11 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
724 770
725#ifdef CONFIG_SMP 771#ifdef CONFIG_SMP
726 /* if this isn't the CPU which is the parent of the kobj, we 772 /* if this isn't the CPU which is the parent of the kobj, we
727 * only need to unlink, put and exit 773 * only need to unlink, put and exit
728 */ 774 */
729 if (unlikely(cpu != data->cpu)) { 775 if (unlikely(cpu != data->cpu)) {
730 dprintk("removing link\n"); 776 dprintk("removing link\n");
777 cpu_clear(cpu, data->cpus);
731 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 778 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
732 sysfs_remove_link(&sys_dev->kobj, "cpufreq"); 779 sysfs_remove_link(&sys_dev->kobj, "cpufreq");
733 cpufreq_cpu_put(data); 780 cpufreq_cpu_put(data);
@@ -740,7 +787,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
740 if (!kobject_get(&data->kobj)) { 787 if (!kobject_get(&data->kobj)) {
741 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 788 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
742 cpufreq_debug_enable_ratelimit(); 789 cpufreq_debug_enable_ratelimit();
743 return -EFAULT; 790 return -EFAULT;
744 } 791 }
745 792
746#ifdef CONFIG_SMP 793#ifdef CONFIG_SMP
@@ -783,7 +830,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
783 kobject_put(&data->kobj); 830 kobject_put(&data->kobj);
784 831
785 /* we need to make sure that the underlying kobj is actually 832 /* we need to make sure that the underlying kobj is actually
786 * not referenced anymore by anybody before we proceed with 833 * not referenced anymore by anybody before we proceed with
787 * unloading. 834 * unloading.
788 */ 835 */
789 dprintk("waiting for dropping of refcount\n"); 836 dprintk("waiting for dropping of refcount\n");
@@ -831,7 +878,7 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne
831} 878}
832 879
833 880
834/** 881/**
835 * cpufreq_quick_get - get the CPU frequency (in kHz) frpm policy->cur 882 * cpufreq_quick_get - get the CPU frequency (in kHz) frpm policy->cur
836 * @cpu: CPU number 883 * @cpu: CPU number
837 * 884 *
@@ -855,7 +902,7 @@ unsigned int cpufreq_quick_get(unsigned int cpu)
855EXPORT_SYMBOL(cpufreq_quick_get); 902EXPORT_SYMBOL(cpufreq_quick_get);
856 903
857 904
858/** 905/**
859 * cpufreq_get - get the current CPU frequency (in kHz) 906 * cpufreq_get - get the current CPU frequency (in kHz)
860 * @cpu: CPU number 907 * @cpu: CPU number
861 * 908 *
@@ -1072,7 +1119,7 @@ static struct sysdev_driver cpufreq_sysdev_driver = {
1072 * @nb: notifier function to register 1119 * @nb: notifier function to register
1073 * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER 1120 * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER
1074 * 1121 *
1075 * Add a driver to one of two lists: either a list of drivers that 1122 * Add a driver to one of two lists: either a list of drivers that
1076 * are notified about clock rate changes (once before and once after 1123 * are notified about clock rate changes (once before and once after
1077 * the transition), or a list of drivers that are notified about 1124 * the transition), or a list of drivers that are notified about
1078 * changes in cpufreq policy. 1125 * changes in cpufreq policy.
@@ -1225,7 +1272,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
1225 return -EINVAL; 1272 return -EINVAL;
1226 1273
1227 mutex_lock(&cpufreq_governor_mutex); 1274 mutex_lock(&cpufreq_governor_mutex);
1228 1275
1229 list_for_each_entry(t, &cpufreq_governor_list, governor_list) { 1276 list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
1230 if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) { 1277 if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) {
1231 mutex_unlock(&cpufreq_governor_mutex); 1278 mutex_unlock(&cpufreq_governor_mutex);
@@ -1234,7 +1281,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
1234 } 1281 }
1235 list_add(&governor->governor_list, &cpufreq_governor_list); 1282 list_add(&governor->governor_list, &cpufreq_governor_list);
1236 1283
1237 mutex_unlock(&cpufreq_governor_mutex); 1284 mutex_unlock(&cpufreq_governor_mutex);
1238 return 0; 1285 return 0;
1239} 1286}
1240EXPORT_SYMBOL_GPL(cpufreq_register_governor); 1287EXPORT_SYMBOL_GPL(cpufreq_register_governor);
@@ -1497,9 +1544,9 @@ static struct notifier_block cpufreq_cpu_notifier =
1497 * @driver_data: A struct cpufreq_driver containing the values# 1544 * @driver_data: A struct cpufreq_driver containing the values#
1498 * submitted by the CPU Frequency driver. 1545 * submitted by the CPU Frequency driver.
1499 * 1546 *
1500 * Registers a CPU Frequency driver to this core code. This code 1547 * Registers a CPU Frequency driver to this core code. This code
1501 * returns zero on success, -EBUSY when another driver got here first 1548 * returns zero on success, -EBUSY when another driver got here first
1502 * (and isn't unregistered in the meantime). 1549 * (and isn't unregistered in the meantime).
1503 * 1550 *
1504 */ 1551 */
1505int cpufreq_register_driver(struct cpufreq_driver *driver_data) 1552int cpufreq_register_driver(struct cpufreq_driver *driver_data)
@@ -1560,7 +1607,7 @@ EXPORT_SYMBOL_GPL(cpufreq_register_driver);
1560/** 1607/**
1561 * cpufreq_unregister_driver - unregister the current CPUFreq driver 1608 * cpufreq_unregister_driver - unregister the current CPUFreq driver
1562 * 1609 *
1563 * Unregister the current CPUFreq driver. Only call this if you have 1610 * Unregister the current CPUFreq driver. Only call this if you have
1564 * the right to do so, i.e. if you have succeeded in initialising before! 1611 * the right to do so, i.e. if you have succeeded in initialising before!
1565 * Returns zero if successful, and -EINVAL if the cpufreq_driver is 1612 * Returns zero if successful, and -EINVAL if the cpufreq_driver is
1566 * currently not initialised. 1613 * currently not initialised.
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 9ee9411f186f..69aa1db8336c 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -38,17 +38,17 @@
38#define MIN_FREQUENCY_UP_THRESHOLD (11) 38#define MIN_FREQUENCY_UP_THRESHOLD (11)
39#define MAX_FREQUENCY_UP_THRESHOLD (100) 39#define MAX_FREQUENCY_UP_THRESHOLD (100)
40 40
41/* 41/*
42 * The polling frequency of this governor depends on the capability of 42 * The polling frequency of this governor depends on the capability of
43 * the processor. Default polling frequency is 1000 times the transition 43 * the processor. Default polling frequency is 1000 times the transition
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 with CPUFREQ_ETERNAL)
48 * this governor will not work. 48 * this governor will not work.
49 * All times here are in uS. 49 * All times here are in uS.
50 */ 50 */
51static unsigned int def_sampling_rate; 51static 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 (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
@@ -62,28 +62,28 @@ static unsigned int def_sampling_rate;
62static void do_dbs_timer(void *data); 62static void do_dbs_timer(void *data);
63 63
64struct cpu_dbs_info_s { 64struct cpu_dbs_info_s {
65 struct cpufreq_policy *cur_policy; 65 struct cpufreq_policy *cur_policy;
66 unsigned int prev_cpu_idle_up; 66 unsigned int prev_cpu_idle_up;
67 unsigned int prev_cpu_idle_down; 67 unsigned int prev_cpu_idle_down;
68 unsigned int enable; 68 unsigned int enable;
69}; 69};
70static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); 70static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
71 71
72static unsigned int dbs_enable; /* number of CPUs using this policy */ 72static unsigned int dbs_enable; /* number of CPUs using this policy */
73 73
74static DEFINE_MUTEX (dbs_mutex); 74static DEFINE_MUTEX (dbs_mutex);
75static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); 75static DECLARE_WORK (dbs_work, do_dbs_timer, NULL);
76 76
77struct dbs_tuners { 77struct dbs_tuners {
78 unsigned int sampling_rate; 78 unsigned int sampling_rate;
79 unsigned int sampling_down_factor; 79 unsigned int sampling_down_factor;
80 unsigned int up_threshold; 80 unsigned int up_threshold;
81 unsigned int ignore_nice; 81 unsigned int ignore_nice;
82}; 82};
83 83
84static struct dbs_tuners dbs_tuners_ins = { 84static struct dbs_tuners dbs_tuners_ins = {
85 .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, 85 .up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
86 .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, 86 .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR,
87}; 87};
88 88
89static inline unsigned int get_cpu_idle_time(unsigned int cpu) 89static inline unsigned int get_cpu_idle_time(unsigned int cpu)
@@ -106,8 +106,8 @@ static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
106 return sprintf (buf, "%u\n", MIN_SAMPLING_RATE); 106 return sprintf (buf, "%u\n", MIN_SAMPLING_RATE);
107} 107}
108 108
109#define define_one_ro(_name) \ 109#define define_one_ro(_name) \
110static struct freq_attr _name = \ 110static struct freq_attr _name = \
111__ATTR(_name, 0444, show_##_name, NULL) 111__ATTR(_name, 0444, show_##_name, NULL)
112 112
113define_one_ro(sampling_rate_max); 113define_one_ro(sampling_rate_max);
@@ -125,7 +125,7 @@ show_one(sampling_down_factor, sampling_down_factor);
125show_one(up_threshold, up_threshold); 125show_one(up_threshold, up_threshold);
126show_one(ignore_nice_load, ignore_nice); 126show_one(ignore_nice_load, ignore_nice);
127 127
128static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, 128static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
129 const char *buf, size_t count) 129 const char *buf, size_t count)
130{ 130{
131 unsigned int input; 131 unsigned int input;
@@ -144,7 +144,7 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
144 return count; 144 return count;
145} 145}
146 146
147static ssize_t store_sampling_rate(struct cpufreq_policy *unused, 147static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
148 const char *buf, size_t count) 148 const char *buf, size_t count)
149{ 149{
150 unsigned int input; 150 unsigned int input;
@@ -163,7 +163,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
163 return count; 163 return count;
164} 164}
165 165
166static ssize_t store_up_threshold(struct cpufreq_policy *unused, 166static ssize_t store_up_threshold(struct cpufreq_policy *unused,
167 const char *buf, size_t count) 167 const char *buf, size_t count)
168{ 168{
169 unsigned int input; 169 unsigned int input;
@@ -171,7 +171,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
171 ret = sscanf (buf, "%u", &input); 171 ret = sscanf (buf, "%u", &input);
172 172
173 mutex_lock(&dbs_mutex); 173 mutex_lock(&dbs_mutex);
174 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || 174 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD ||
175 input < MIN_FREQUENCY_UP_THRESHOLD) { 175 input < MIN_FREQUENCY_UP_THRESHOLD) {
176 mutex_unlock(&dbs_mutex); 176 mutex_unlock(&dbs_mutex);
177 return -EINVAL; 177 return -EINVAL;
@@ -190,14 +190,14 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
190 int ret; 190 int ret;
191 191
192 unsigned int j; 192 unsigned int j;
193 193
194 ret = sscanf (buf, "%u", &input); 194 ret = sscanf (buf, "%u", &input);
195 if ( ret != 1 ) 195 if ( ret != 1 )
196 return -EINVAL; 196 return -EINVAL;
197 197
198 if ( input > 1 ) 198 if ( input > 1 )
199 input = 1; 199 input = 1;
200 200
201 mutex_lock(&dbs_mutex); 201 mutex_lock(&dbs_mutex);
202 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ 202 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */
203 mutex_unlock(&dbs_mutex); 203 mutex_unlock(&dbs_mutex);
@@ -259,16 +259,16 @@ static void dbs_check_cpu(int cpu)
259 return; 259 return;
260 260
261 policy = this_dbs_info->cur_policy; 261 policy = this_dbs_info->cur_policy;
262 /* 262 /*
263 * Every sampling_rate, we check, if current idle time is less 263 * Every sampling_rate, we check, if current idle time is less
264 * than 20% (default), then we try to increase frequency 264 * than 20% (default), then we try to increase frequency
265 * Every sampling_rate*sampling_down_factor, we look for a the lowest 265 * Every sampling_rate*sampling_down_factor, we look for a the lowest
266 * frequency which can sustain the load while keeping idle time over 266 * frequency which can sustain the load while keeping idle time over
267 * 30%. If such a frequency exist, we try to decrease to this frequency. 267 * 30%. If such a frequency exist, we try to decrease to this frequency.
268 * 268 *
269 * Any frequency increase takes it to the maximum frequency. 269 * Any frequency increase takes it to the maximum frequency.
270 * Frequency reduction happens at minimum steps of 270 * Frequency reduction happens at minimum steps of
271 * 5% (default) of current frequency 271 * 5% (default) of current frequency
272 */ 272 */
273 273
274 /* Check for frequency increase */ 274 /* Check for frequency increase */
@@ -298,14 +298,14 @@ static void dbs_check_cpu(int cpu)
298 struct cpu_dbs_info_s *j_dbs_info; 298 struct cpu_dbs_info_s *j_dbs_info;
299 299
300 j_dbs_info = &per_cpu(cpu_dbs_info, j); 300 j_dbs_info = &per_cpu(cpu_dbs_info, j);
301 j_dbs_info->prev_cpu_idle_down = 301 j_dbs_info->prev_cpu_idle_down =
302 j_dbs_info->prev_cpu_idle_up; 302 j_dbs_info->prev_cpu_idle_up;
303 } 303 }
304 /* if we are already at full speed then break out early */ 304 /* if we are already at full speed then break out early */
305 if (policy->cur == policy->max) 305 if (policy->cur == policy->max)
306 return; 306 return;
307 307
308 __cpufreq_driver_target(policy, policy->max, 308 __cpufreq_driver_target(policy, policy->max,
309 CPUFREQ_RELATION_H); 309 CPUFREQ_RELATION_H);
310 return; 310 return;
311 } 311 }
@@ -347,7 +347,7 @@ static void dbs_check_cpu(int cpu)
347 * policy. To be safe, we focus 10 points under the threshold. 347 * policy. To be safe, we focus 10 points under the threshold.
348 */ 348 */
349 freq_next = ((total_ticks - idle_ticks) * 100) / total_ticks; 349 freq_next = ((total_ticks - idle_ticks) * 100) / total_ticks;
350 freq_next = (freq_next * policy->cur) / 350 freq_next = (freq_next * policy->cur) /
351 (dbs_tuners_ins.up_threshold - 10); 351 (dbs_tuners_ins.up_threshold - 10);
352 352
353 if (freq_next <= ((policy->cur * 95) / 100)) 353 if (freq_next <= ((policy->cur * 95) / 100))
@@ -355,15 +355,15 @@ static void dbs_check_cpu(int cpu)
355} 355}
356 356
357static void do_dbs_timer(void *data) 357static void do_dbs_timer(void *data)
358{ 358{
359 int i; 359 int i;
360 mutex_lock(&dbs_mutex); 360 mutex_lock(&dbs_mutex);
361 for_each_online_cpu(i) 361 for_each_online_cpu(i)
362 dbs_check_cpu(i); 362 dbs_check_cpu(i);
363 schedule_delayed_work(&dbs_work, 363 schedule_delayed_work(&dbs_work,
364 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 364 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
365 mutex_unlock(&dbs_mutex); 365 mutex_unlock(&dbs_mutex);
366} 366}
367 367
368static inline void dbs_timer_init(void) 368static inline void dbs_timer_init(void)
369{ 369{
@@ -390,7 +390,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
390 390
391 switch (event) { 391 switch (event) {
392 case CPUFREQ_GOV_START: 392 case CPUFREQ_GOV_START:
393 if ((!cpu_online(cpu)) || 393 if ((!cpu_online(cpu)) ||
394 (!policy->cur)) 394 (!policy->cur))
395 return -EINVAL; 395 return -EINVAL;
396 396
@@ -399,13 +399,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
399 return -EINVAL; 399 return -EINVAL;
400 if (this_dbs_info->enable) /* Already enabled */ 400 if (this_dbs_info->enable) /* Already enabled */
401 break; 401 break;
402 402
403 mutex_lock(&dbs_mutex); 403 mutex_lock(&dbs_mutex);
404 for_each_cpu_mask(j, policy->cpus) { 404 for_each_cpu_mask(j, policy->cpus) {
405 struct cpu_dbs_info_s *j_dbs_info; 405 struct cpu_dbs_info_s *j_dbs_info;
406 j_dbs_info = &per_cpu(cpu_dbs_info, j); 406 j_dbs_info = &per_cpu(cpu_dbs_info, j);
407 j_dbs_info->cur_policy = policy; 407 j_dbs_info->cur_policy = policy;
408 408
409 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); 409 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j);
410 j_dbs_info->prev_cpu_idle_down 410 j_dbs_info->prev_cpu_idle_down
411 = j_dbs_info->prev_cpu_idle_up; 411 = j_dbs_info->prev_cpu_idle_up;
@@ -435,7 +435,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
435 435
436 dbs_timer_init(); 436 dbs_timer_init();
437 } 437 }
438 438
439 mutex_unlock(&dbs_mutex); 439 mutex_unlock(&dbs_mutex);
440 break; 440 break;
441 441
@@ -448,9 +448,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
448 * Stop the timerschedule work, when this governor 448 * Stop the timerschedule work, when this governor
449 * is used for first time 449 * is used for first time
450 */ 450 */
451 if (dbs_enable == 0) 451 if (dbs_enable == 0)
452 dbs_timer_exit(); 452 dbs_timer_exit();
453 453
454 mutex_unlock(&dbs_mutex); 454 mutex_unlock(&dbs_mutex);
455 455
456 break; 456 break;
@@ -460,11 +460,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
460 if (policy->max < this_dbs_info->cur_policy->cur) 460 if (policy->max < this_dbs_info->cur_policy->cur)
461 __cpufreq_driver_target( 461 __cpufreq_driver_target(
462 this_dbs_info->cur_policy, 462 this_dbs_info->cur_policy,
463 policy->max, CPUFREQ_RELATION_H); 463 policy->max, CPUFREQ_RELATION_H);
464 else if (policy->min > this_dbs_info->cur_policy->cur) 464 else if (policy->min > this_dbs_info->cur_policy->cur)
465 __cpufreq_driver_target( 465 __cpufreq_driver_target(
466 this_dbs_info->cur_policy, 466 this_dbs_info->cur_policy,
467 policy->min, CPUFREQ_RELATION_L); 467 policy->min, CPUFREQ_RELATION_L);
468 mutex_unlock(&dbs_mutex); 468 mutex_unlock(&dbs_mutex);
469 break; 469 break;
470 } 470 }
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c
index 8d536b40deb8..de91e3371ef8 100644
--- a/drivers/cpufreq/cpufreq_performance.c
+++ b/drivers/cpufreq/cpufreq_performance.c
@@ -32,7 +32,7 @@ static int cpufreq_governor_performance(struct cpufreq_policy *policy,
32 } 32 }
33 return 0; 33 return 0;
34} 34}
35 35
36struct cpufreq_governor cpufreq_gov_performance = { 36struct cpufreq_governor cpufreq_gov_performance = {
37 .name = "performance", 37 .name = "performance",
38 .governor = cpufreq_governor_performance, 38 .governor = cpufreq_governor_performance,
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c
index c85edda7feb0..0a2596044e65 100644
--- a/drivers/cpufreq/cpufreq_powersave.c
+++ b/drivers/cpufreq/cpufreq_powersave.c
@@ -31,7 +31,7 @@ static int cpufreq_governor_powersave(struct cpufreq_policy *policy,
31 } 31 }
32 return 0; 32 return 0;
33} 33}
34 34
35static struct cpufreq_governor cpufreq_gov_powersave = { 35static struct cpufreq_governor cpufreq_gov_powersave = {
36 .name = "powersave", 36 .name = "powersave",
37 .governor = cpufreq_governor_powersave, 37 .governor = cpufreq_governor_powersave,
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 0bddb8e694d9..9694b6ed3268 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -2,7 +2,7 @@
2 * drivers/cpufreq/cpufreq_stats.c 2 * drivers/cpufreq/cpufreq_stats.c
3 * 3 *
4 * Copyright (C) 2003-2004 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>. 4 * Copyright (C) 2003-2004 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>.
5 * (C) 2004 Zou Nan hai <nanhai.zou@intel.com>. 5 * (C) 2004 Zou Nan hai <nanhai.zou@intel.com>.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -90,7 +90,7 @@ show_time_in_state(struct cpufreq_policy *policy, char *buf)
90 return 0; 90 return 0;
91 cpufreq_stats_update(stat->cpu); 91 cpufreq_stats_update(stat->cpu);
92 for (i = 0; i < stat->state_num; i++) { 92 for (i = 0; i < stat->state_num; i++) {
93 len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], 93 len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
94 (unsigned long long)cputime64_to_clock_t(stat->time_in_state[i])); 94 (unsigned long long)cputime64_to_clock_t(stat->time_in_state[i]));
95 } 95 }
96 return len; 96 return len;
@@ -171,7 +171,7 @@ cpufreq_stats_free_table (unsigned int cpu)
171{ 171{
172 struct cpufreq_stats *stat = cpufreq_stats_table[cpu]; 172 struct cpufreq_stats *stat = cpufreq_stats_table[cpu];
173 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 173 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
174 if (policy && policy->cpu == cpu) 174 if (policy && policy->cpu == cpu)
175 sysfs_remove_group(&policy->kobj, &stats_attr_group); 175 sysfs_remove_group(&policy->kobj, &stats_attr_group);
176 if (stat) { 176 if (stat) {
177 kfree(stat->time_in_state); 177 kfree(stat->time_in_state);
@@ -303,7 +303,7 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val,
303 return 0; 303 return 0;
304} 304}
305 305
306static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb, 306static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
307 unsigned long action, void *hcpu) 307 unsigned long action, void *hcpu)
308{ 308{
309 unsigned int cpu = (unsigned long)hcpu; 309 unsigned int cpu = (unsigned long)hcpu;
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c
index 92a0be22a2a9..071ee4f1bbf2 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -41,7 +41,7 @@ static DEFINE_MUTEX (userspace_mutex);
41#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg) 41#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg)
42 42
43/* keep track of frequency transitions */ 43/* keep track of frequency transitions */
44static int 44static int
45userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val, 45userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
46 void *data) 46 void *data)
47{ 47{
@@ -58,7 +58,7 @@ static struct notifier_block userspace_cpufreq_notifier_block = {
58}; 58};
59 59
60 60
61/** 61/**
62 * cpufreq_set - set the CPU frequency 62 * cpufreq_set - set the CPU frequency
63 * @freq: target frequency in kHz 63 * @freq: target frequency in kHz
64 * @cpu: CPU for which the frequency is to be set 64 * @cpu: CPU for which the frequency is to be set
@@ -103,8 +103,8 @@ static ssize_t show_speed (struct cpufreq_policy *policy, char *buf)
103 return sprintf (buf, "%u\n", cpu_cur_freq[policy->cpu]); 103 return sprintf (buf, "%u\n", cpu_cur_freq[policy->cpu]);
104} 104}
105 105
106static ssize_t 106static ssize_t
107store_speed (struct cpufreq_policy *policy, const char *buf, size_t count) 107store_speed (struct cpufreq_policy *policy, const char *buf, size_t count)
108{ 108{
109 unsigned int freq = 0; 109 unsigned int freq = 0;
110 unsigned int ret; 110 unsigned int ret;
@@ -118,7 +118,7 @@ store_speed (struct cpufreq_policy *policy, const char *buf, size_t count)
118 return count; 118 return count;
119} 119}
120 120
121static struct freq_attr freq_attr_scaling_setspeed = 121static struct freq_attr freq_attr_scaling_setspeed =
122{ 122{
123 .attr = { .name = "scaling_setspeed", .mode = 0644, .owner = THIS_MODULE }, 123 .attr = { .name = "scaling_setspeed", .mode = 0644, .owner = THIS_MODULE },
124 .show = show_speed, 124 .show = show_speed,
@@ -135,7 +135,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
135 return -EINVAL; 135 return -EINVAL;
136 BUG_ON(!policy->cur); 136 BUG_ON(!policy->cur);
137 mutex_lock(&userspace_mutex); 137 mutex_lock(&userspace_mutex);
138 cpu_is_managed[cpu] = 1; 138 cpu_is_managed[cpu] = 1;
139 cpu_min_freq[cpu] = policy->min; 139 cpu_min_freq[cpu] = policy->min;
140 cpu_max_freq[cpu] = policy->max; 140 cpu_max_freq[cpu] = policy->max;
141 cpu_cur_freq[cpu] = policy->cur; 141 cpu_cur_freq[cpu] = policy->cur;
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index ba460bdea60f..a4818ce88919 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -59,9 +59,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
59 if (!cpu_online(policy->cpu)) 59 if (!cpu_online(policy->cpu))
60 return -EINVAL; 60 return -EINVAL;
61 61
62 cpufreq_verify_within_limits(policy, 62 cpufreq_verify_within_limits(policy,
63 policy->cpuinfo.min_freq, 63 policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
64 policy->cpuinfo.max_freq);
65 64
66 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 65 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
67 unsigned int freq = table[i].frequency; 66 unsigned int freq = table[i].frequency;
@@ -76,9 +75,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
76 if (!count) 75 if (!count)
77 policy->max = next_larger; 76 policy->max = next_larger;
78 77
79 cpufreq_verify_within_limits(policy, 78 cpufreq_verify_within_limits(policy,
80 policy->cpuinfo.min_freq, 79 policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
81 policy->cpuinfo.max_freq);
82 80
83 dprintk("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); 81 dprintk("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu);
84 82
@@ -199,7 +197,7 @@ EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs);
199 * if you use these, you must assure that the frequency table is valid 197 * if you use these, you must assure that the frequency table is valid
200 * all the time between get_attr and put_attr! 198 * all the time between get_attr and put_attr!
201 */ 199 */
202void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, 200void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
203 unsigned int cpu) 201 unsigned int cpu)
204{ 202{
205 dprintk("setting show_table for cpu %u to %p\n", cpu, table); 203 dprintk("setting show_table for cpu %u to %p\n", cpu, table);