14 #include <linux/kernel.h>
15 #include <linux/module.h>
22 #include <linux/types.h>
38 static int cpus_using_userspace_governor;
51 pr_debug(
"saving cpu_cur_freq of cpu %u to be %u kHz\n",
60 .notifier_call = userspace_cpufreq_notifier
71 static int cpufreq_set(
struct cpufreq_policy *policy,
unsigned int freq)
75 pr_debug(
"cpufreq_set for cpu %u, freq %u kHz\n", policy->
cpu, freq);
111 static int cpufreq_governor_userspace(
struct cpufreq_policy *policy,
114 unsigned int cpu = policy->
cpu;
124 if (cpus_using_userspace_governor == 0) {
126 &userspace_cpufreq_notifier_block,
129 cpus_using_userspace_governor++;
131 per_cpu(cpu_is_managed, cpu) = 1;
137 "(%u - %u kHz, currently %u kHz)\n",
147 cpus_using_userspace_governor--;
148 if (cpus_using_userspace_governor == 0) {
150 &userspace_cpufreq_notifier_block,
154 per_cpu(cpu_is_managed, cpu) = 0;
155 per_cpu(cpu_min_freq, cpu) = 0;
156 per_cpu(cpu_max_freq, cpu) = 0;
157 per_cpu(cpu_set_freq, cpu) = 0;
158 pr_debug(
"managing cpu %u stopped\n", cpu);
163 pr_debug(
"limit event for cpu %u: %u - %u kHz, "
164 "currently %u kHz, last set to %u kHz\n",
165 cpu, policy->
min, policy->
max,
168 if (policy->
max <
per_cpu(cpu_set_freq, cpu)) {
171 }
else if (policy->
min >
per_cpu(cpu_set_freq, cpu)) {
189 #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE
194 .governor = cpufreq_governor_userspace,
195 .store_setspeed = cpufreq_set,
196 .show_setspeed = show_speed,
200 static int __init cpufreq_gov_userspace_init(
void)
206 static void __exit cpufreq_gov_userspace_exit(
void)
217 #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE