diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-12 16:42:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-12 16:42:43 -0400 |
commit | 702ed6ef375c19d65f2eeeefd3851476f2c4cee4 (patch) | |
tree | fe46588dcc716f64a04310797d9446573614d3fc /drivers | |
parent | 2f41fc806434f8466bb361570589a3f6099ca65d (diff) | |
parent | 58a7295bc8073b9e668c329cb9ceb5b668c2b15d (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
* master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq:
[CPUFREQ] Fix sysfs_create_file return value handling
[CPUFREQ] ondemand: fix tickless accounting and software coordination bug
[CPUFREQ] ondemand: add a check to avoid negative load calculation
[CPUFREQ] Keep userspace governor quiet when it is not being used
[CPUFREQ] Longhaul - Proper register access
[CPUFREQ] Kconfig powernow-k8 driver should depend on ACPI P-States driver
[CPUFREQ] Longhaul - Replace ACPI functions with direct I/O
[CPUFREQ] Longhaul - Remove duplicate multipliers
[CPUFREQ] Longhaul - Embedded "conservative"
[CPUFREQ] acpi-cpufreq: Proper ReadModifyWrite of PERF_CTL MSR
[CPUFREQ] check return value of sysfs_create_file
[CPUFREQ] Longhaul - Check ACPI "BM DMA in progress" bit
[CPUFREQ] Longhaul - Move old_ratio to correct place
[CPUFREQ] Longhaul - VT8237 support
[CPUFREQ] Longhaul - Use all kinds of support
[CPUFREQ] powernow-k8: clarify number of cores.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 18 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 30 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_userspace.c | 23 |
3 files changed, 54 insertions, 17 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index eb37fba9b7ef..0db9e1bda322 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -826,13 +826,21 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
826 | /* set up files for this cpu device */ | 826 | /* set up files for this cpu device */ |
827 | drv_attr = cpufreq_driver->attr; | 827 | drv_attr = cpufreq_driver->attr; |
828 | while ((drv_attr) && (*drv_attr)) { | 828 | while ((drv_attr) && (*drv_attr)) { |
829 | sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); | 829 | ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); |
830 | if (ret) | ||
831 | goto err_out_driver_exit; | ||
830 | drv_attr++; | 832 | drv_attr++; |
831 | } | 833 | } |
832 | if (cpufreq_driver->get) | 834 | if (cpufreq_driver->get){ |
833 | sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); | 835 | ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); |
834 | if (cpufreq_driver->target) | 836 | if (ret) |
835 | sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); | 837 | goto err_out_driver_exit; |
838 | } | ||
839 | if (cpufreq_driver->target){ | ||
840 | ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); | ||
841 | if (ret) | ||
842 | goto err_out_driver_exit; | ||
843 | } | ||
836 | 844 | ||
837 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 845 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
838 | for_each_cpu_mask(j, policy->cpus) { | 846 | for_each_cpu_mask(j, policy->cpus) { |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 8532bb79e5fc..e794527e4925 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -96,15 +96,25 @@ static struct dbs_tuners { | |||
96 | 96 | ||
97 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu) | 97 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu) |
98 | { | 98 | { |
99 | cputime64_t retval; | 99 | cputime64_t idle_time; |
100 | cputime64_t cur_jiffies; | ||
101 | cputime64_t busy_time; | ||
100 | 102 | ||
101 | retval = cputime64_add(kstat_cpu(cpu).cpustat.idle, | 103 | cur_jiffies = jiffies64_to_cputime64(get_jiffies_64()); |
102 | kstat_cpu(cpu).cpustat.iowait); | 104 | busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user, |
105 | kstat_cpu(cpu).cpustat.system); | ||
103 | 106 | ||
104 | if (dbs_tuners_ins.ignore_nice) | 107 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); |
105 | retval = cputime64_add(retval, kstat_cpu(cpu).cpustat.nice); | 108 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); |
109 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); | ||
106 | 110 | ||
107 | return retval; | 111 | if (!dbs_tuners_ins.ignore_nice) { |
112 | busy_time = cputime64_add(busy_time, | ||
113 | kstat_cpu(cpu).cpustat.nice); | ||
114 | } | ||
115 | |||
116 | idle_time = cputime64_sub(cur_jiffies, busy_time); | ||
117 | return idle_time; | ||
108 | } | 118 | } |
109 | 119 | ||
110 | /* | 120 | /* |
@@ -325,7 +335,7 @@ static struct attribute_group dbs_attr_group = { | |||
325 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | 335 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) |
326 | { | 336 | { |
327 | unsigned int idle_ticks, total_ticks; | 337 | unsigned int idle_ticks, total_ticks; |
328 | unsigned int load; | 338 | unsigned int load = 0; |
329 | cputime64_t cur_jiffies; | 339 | cputime64_t cur_jiffies; |
330 | 340 | ||
331 | struct cpufreq_policy *policy; | 341 | struct cpufreq_policy *policy; |
@@ -339,7 +349,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
339 | cur_jiffies = jiffies64_to_cputime64(get_jiffies_64()); | 349 | cur_jiffies = jiffies64_to_cputime64(get_jiffies_64()); |
340 | total_ticks = (unsigned int) cputime64_sub(cur_jiffies, | 350 | total_ticks = (unsigned int) cputime64_sub(cur_jiffies, |
341 | this_dbs_info->prev_cpu_wall); | 351 | this_dbs_info->prev_cpu_wall); |
342 | this_dbs_info->prev_cpu_wall = cur_jiffies; | 352 | this_dbs_info->prev_cpu_wall = get_jiffies_64(); |
353 | |||
343 | if (!total_ticks) | 354 | if (!total_ticks) |
344 | return; | 355 | return; |
345 | /* | 356 | /* |
@@ -370,7 +381,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
370 | if (tmp_idle_ticks < idle_ticks) | 381 | if (tmp_idle_ticks < idle_ticks) |
371 | idle_ticks = tmp_idle_ticks; | 382 | idle_ticks = tmp_idle_ticks; |
372 | } | 383 | } |
373 | load = (100 * (total_ticks - idle_ticks)) / total_ticks; | 384 | if (likely(total_ticks > idle_ticks)) |
385 | load = (100 * (total_ticks - idle_ticks)) / total_ticks; | ||
374 | 386 | ||
375 | /* Check for frequency increase */ | 387 | /* Check for frequency increase */ |
376 | if (load > dbs_tuners_ins.up_threshold) { | 388 | if (load > dbs_tuners_ins.up_threshold) { |
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index a648970338b0..51bedab6c808 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
@@ -37,6 +37,7 @@ static unsigned int cpu_set_freq[NR_CPUS]; /* CPU freq desired by userspace */ | |||
37 | static unsigned int cpu_is_managed[NR_CPUS]; | 37 | static unsigned int cpu_is_managed[NR_CPUS]; |
38 | 38 | ||
39 | static DEFINE_MUTEX (userspace_mutex); | 39 | static DEFINE_MUTEX (userspace_mutex); |
40 | static int cpus_using_userspace_governor; | ||
40 | 41 | ||
41 | #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg) | 42 | #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg) |
42 | 43 | ||
@@ -47,7 +48,11 @@ userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val, | |||
47 | { | 48 | { |
48 | struct cpufreq_freqs *freq = data; | 49 | struct cpufreq_freqs *freq = data; |
49 | 50 | ||
50 | dprintk("saving cpu_cur_freq of cpu %u to be %u kHz\n", freq->cpu, freq->new); | 51 | if (!cpu_is_managed[freq->cpu]) |
52 | return 0; | ||
53 | |||
54 | dprintk("saving cpu_cur_freq of cpu %u to be %u kHz\n", | ||
55 | freq->cpu, freq->new); | ||
51 | cpu_cur_freq[freq->cpu] = freq->new; | 56 | cpu_cur_freq[freq->cpu] = freq->new; |
52 | 57 | ||
53 | return 0; | 58 | return 0; |
@@ -142,6 +147,13 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, | |||
142 | if (rc) | 147 | if (rc) |
143 | goto start_out; | 148 | goto start_out; |
144 | 149 | ||
150 | if (cpus_using_userspace_governor == 0) { | ||
151 | cpufreq_register_notifier( | ||
152 | &userspace_cpufreq_notifier_block, | ||
153 | CPUFREQ_TRANSITION_NOTIFIER); | ||
154 | } | ||
155 | cpus_using_userspace_governor++; | ||
156 | |||
145 | cpu_is_managed[cpu] = 1; | 157 | cpu_is_managed[cpu] = 1; |
146 | cpu_min_freq[cpu] = policy->min; | 158 | cpu_min_freq[cpu] = policy->min; |
147 | cpu_max_freq[cpu] = policy->max; | 159 | cpu_max_freq[cpu] = policy->max; |
@@ -153,6 +165,13 @@ start_out: | |||
153 | break; | 165 | break; |
154 | case CPUFREQ_GOV_STOP: | 166 | case CPUFREQ_GOV_STOP: |
155 | mutex_lock(&userspace_mutex); | 167 | mutex_lock(&userspace_mutex); |
168 | cpus_using_userspace_governor--; | ||
169 | if (cpus_using_userspace_governor == 0) { | ||
170 | cpufreq_unregister_notifier( | ||
171 | &userspace_cpufreq_notifier_block, | ||
172 | CPUFREQ_TRANSITION_NOTIFIER); | ||
173 | } | ||
174 | |||
156 | cpu_is_managed[cpu] = 0; | 175 | cpu_is_managed[cpu] = 0; |
157 | cpu_min_freq[cpu] = 0; | 176 | cpu_min_freq[cpu] = 0; |
158 | cpu_max_freq[cpu] = 0; | 177 | cpu_max_freq[cpu] = 0; |
@@ -198,7 +217,6 @@ EXPORT_SYMBOL(cpufreq_gov_userspace); | |||
198 | 217 | ||
199 | static int __init cpufreq_gov_userspace_init(void) | 218 | static int __init cpufreq_gov_userspace_init(void) |
200 | { | 219 | { |
201 | cpufreq_register_notifier(&userspace_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); | ||
202 | return cpufreq_register_governor(&cpufreq_gov_userspace); | 220 | return cpufreq_register_governor(&cpufreq_gov_userspace); |
203 | } | 221 | } |
204 | 222 | ||
@@ -206,7 +224,6 @@ static int __init cpufreq_gov_userspace_init(void) | |||
206 | static void __exit cpufreq_gov_userspace_exit(void) | 224 | static void __exit cpufreq_gov_userspace_exit(void) |
207 | { | 225 | { |
208 | cpufreq_unregister_governor(&cpufreq_gov_userspace); | 226 | cpufreq_unregister_governor(&cpufreq_gov_userspace); |
209 | cpufreq_unregister_notifier(&userspace_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); | ||
210 | } | 227 | } |
211 | 228 | ||
212 | 229 | ||