aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenki Pallipadi <venkatesh.pallipadi@intel.com>2007-06-20 17:24:00 -0400
committerDave Jones <davej@redhat.com>2007-06-21 12:57:53 -0400
commitc7f652e0487a35c16f6cd72707232b6a28647a10 (patch)
tree8ef6901d94aa0f168ae4ad07275c3cf15a0b3818
parent689eba77cbd0cfaaa3687cbe23e8b534f8ae0ebb (diff)
[CPUFREQ] Keep userspace governor quiet when it is not being used
Userspace governor registers a frequency change notifier at init time, even when no CPU is set to userspace governor. Make it register only when atleast one CPU is using userspace. Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Signed-off-by: Dave Jones <davej@redhat.com>
-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 860345c7799a..b1348ff9fcf4 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