aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_userspace.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-12 16:42:43 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-12 16:42:43 -0400
commit702ed6ef375c19d65f2eeeefd3851476f2c4cee4 (patch)
treefe46588dcc716f64a04310797d9446573614d3fc /drivers/cpufreq/cpufreq_userspace.c
parent2f41fc806434f8466bb361570589a3f6099ca65d (diff)
parent58a7295bc8073b9e668c329cb9ceb5b668c2b15d (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/cpufreq/cpufreq_userspace.c')
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c23
1 files changed, 20 insertions, 3 deletions
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 */
37static unsigned int cpu_is_managed[NR_CPUS]; 37static unsigned int cpu_is_managed[NR_CPUS];
38 38
39static DEFINE_MUTEX (userspace_mutex); 39static DEFINE_MUTEX (userspace_mutex);
40static 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
199static int __init cpufreq_gov_userspace_init(void) 218static 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)
206static void __exit cpufreq_gov_userspace_exit(void) 224static 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