2 * drivers/cpufreq/cpufreq_interactive.c
4 * Copyright (C) 2010 Google, Inc.
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * Author: Mike Chan (mike@android.com)
19 #include <linux/cpu.h>
20 #include <linux/cpumask.h>
21 #include <linux/cpufreq.h>
22 #include <linux/module.h>
23 #include <linux/mutex.h>
24 #include <linux/sched.h>
25 #include <linux/sched/rt.h>
26 #include <linux/tick.h>
27 #include <linux/time.h>
28 #include <linux/timer.h>
29 #include <linux/workqueue.h>
30 #include <linux/kthread.h>
31 #include <linux/mutex.h>
32 #include <linux/slab.h>
33 #include <linux/input.h>
34 #include <asm/cputime.h>
36 #define CREATE_TRACE_POINTS
37 #include <trace/events/cpufreq_interactive.h>
39 static atomic_t active_count = ATOMIC_INIT(0);
41 struct cpufreq_interactive_cpuinfo {
42 struct timer_list cpu_timer;
49 u64 target_set_time_in_idle;
50 u64 target_validate_time;
51 struct cpufreq_policy *policy;
52 struct cpufreq_frequency_table *freq_table;
53 unsigned int target_freq;
57 static DEFINE_PER_CPU(struct cpufreq_interactive_cpuinfo, cpuinfo);
59 /* Workqueues handle frequency scaling */
60 static struct task_struct *up_task;
61 static struct workqueue_struct *down_wq;
62 static struct work_struct freq_scale_down_work;
63 static cpumask_t up_cpumask;
64 static spinlock_t up_cpumask_lock;
65 static cpumask_t down_cpumask;
66 static spinlock_t down_cpumask_lock;
67 static struct mutex set_speed_lock;
69 /* Hi speed to bump to from lo speed when load burst (default max) */
70 static u64 hispeed_freq;
72 /* Go to hi speed when CPU load at or above this value. */
73 #define DEFAULT_GO_HISPEED_LOAD 85
74 static unsigned long go_hispeed_load;
77 * The minimum amount of time to spend at a frequency before we can ramp down.
79 #define DEFAULT_MIN_SAMPLE_TIME (80 * USEC_PER_MSEC)
80 static unsigned long min_sample_time;
83 * The sample rate of the timer used to increase frequency
85 #define DEFAULT_TIMER_RATE (20 * USEC_PER_MSEC)
86 static unsigned long timer_rate;
89 * Wait this long before raising speed above hispeed, by default a single
92 #define DEFAULT_ABOVE_HISPEED_DELAY DEFAULT_TIMER_RATE
93 static unsigned long above_hispeed_delay_val;
96 * Boost pulse to hispeed on touchscreen input.
99 static int input_boost_val;
101 struct cpufreq_interactive_inputopen {
102 struct input_handle *handle;
103 struct work_struct inputopen_work;
106 static struct cpufreq_interactive_inputopen inputopen;
109 * Non-zero means longer-term speed boost active.
112 static int boost_val;
114 static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
117 #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE
120 struct cpufreq_governor cpufreq_gov_interactive = {
121 .name = "interactive",
122 .governor = cpufreq_governor_interactive,
123 .max_transition_latency = 10000000,
124 .owner = THIS_MODULE,
127 static void cpufreq_interactive_timer(unsigned long data)
129 unsigned int delta_idle;
130 unsigned int delta_time;
132 int load_since_change;
135 struct cpufreq_interactive_cpuinfo *pcpu =
136 &per_cpu(cpuinfo, data);
138 unsigned int new_freq;
144 if (!pcpu->governor_enabled)
148 * Once pcpu->timer_run_time is updated to >= pcpu->idle_exit_time,
149 * this lets idle exit know the current idle time sample has
150 * been processed, and idle exit can generate a new sample and
151 * re-arm the timer. This prevents a concurrent idle
152 * exit on that CPU from writing a new set of info at the same time
153 * the timer function runs (the timer function can't use that info
154 * until more time passes).
156 time_in_idle = pcpu->time_in_idle;
157 idle_exit_time = pcpu->idle_exit_time;
158 now_idle = get_cpu_idle_time_us(data, &pcpu->timer_run_time);
161 /* If we raced with cancelling a timer, skip. */
165 delta_idle = (unsigned int)(now_idle - time_in_idle);
166 delta_time = (unsigned int)(pcpu->timer_run_time - idle_exit_time);
169 * If timer ran less than 1ms after short-term sample started, retry.
171 if (delta_time < 1000)
174 if (delta_idle > delta_time)
177 cpu_load = 100 * (delta_time - delta_idle) / delta_time;
179 delta_idle = (unsigned int)(now_idle - pcpu->target_set_time_in_idle);
180 delta_time = (unsigned int)(pcpu->timer_run_time -
181 pcpu->target_set_time);
183 if ((delta_time == 0) || (delta_idle > delta_time))
184 load_since_change = 0;
187 100 * (delta_time - delta_idle) / delta_time;
190 * Choose greater of short-term load (since last idle timer
191 * started or timer function re-armed itself) or long-term load
192 * (since last frequency change).
194 if (load_since_change > cpu_load)
195 cpu_load = load_since_change;
197 if (cpu_load >= go_hispeed_load || boost_val) {
198 if (pcpu->target_freq <= pcpu->policy->min) {
199 new_freq = hispeed_freq;
201 new_freq = pcpu->policy->max * cpu_load / 100;
203 if (new_freq < hispeed_freq)
204 new_freq = hispeed_freq;
206 if (pcpu->target_freq == hispeed_freq &&
207 new_freq > hispeed_freq &&
208 pcpu->timer_run_time - pcpu->target_set_time
209 < above_hispeed_delay_val) {
210 trace_cpufreq_interactive_notyet(data, cpu_load,
217 new_freq = pcpu->policy->max * cpu_load / 100;
220 if (cpufreq_frequency_table_target(pcpu->policy, pcpu->freq_table,
221 new_freq, CPUFREQ_RELATION_H,
223 pr_warn_once("timer %d: cpufreq_frequency_table_target error\n",
228 new_freq = pcpu->freq_table[index].frequency;
231 * Do not scale down unless we have been at this frequency for the
232 * minimum sample time since last validated.
234 if (new_freq < pcpu->target_freq) {
235 if (pcpu->timer_run_time - pcpu->target_validate_time
237 trace_cpufreq_interactive_notyet(data, cpu_load,
238 pcpu->target_freq, new_freq);
243 pcpu->target_validate_time = pcpu->timer_run_time;
245 if (pcpu->target_freq == new_freq) {
246 trace_cpufreq_interactive_already(data, cpu_load,
247 pcpu->target_freq, new_freq);
248 goto rearm_if_notmax;
251 trace_cpufreq_interactive_target(data, cpu_load, pcpu->target_freq,
253 pcpu->target_set_time_in_idle = now_idle;
254 pcpu->target_set_time = pcpu->timer_run_time;
256 if (new_freq < pcpu->target_freq) {
257 pcpu->target_freq = new_freq;
258 spin_lock_irqsave(&down_cpumask_lock, flags);
259 cpumask_set_cpu(data, &down_cpumask);
260 spin_unlock_irqrestore(&down_cpumask_lock, flags);
261 queue_work(down_wq, &freq_scale_down_work);
263 pcpu->target_freq = new_freq;
264 spin_lock_irqsave(&up_cpumask_lock, flags);
265 cpumask_set_cpu(data, &up_cpumask);
266 spin_unlock_irqrestore(&up_cpumask_lock, flags);
267 wake_up_process(up_task);
272 * Already set max speed and don't see a need to change that,
273 * wait until next idle to re-evaluate, don't need timer.
275 if (pcpu->target_freq == pcpu->policy->max)
279 if (!timer_pending(&pcpu->cpu_timer)) {
281 * If already at min: if that CPU is idle, don't set timer.
282 * Else cancel the timer if that CPU goes idle. We don't
283 * need to re-evaluate speed until the next idle exit.
285 if (pcpu->target_freq == pcpu->policy->min) {
291 pcpu->timer_idlecancel = 1;
294 pcpu->time_in_idle = get_cpu_idle_time_us(
295 data, &pcpu->idle_exit_time);
296 mod_timer(&pcpu->cpu_timer,
297 jiffies + usecs_to_jiffies(timer_rate));
304 static void cpufreq_interactive_idle_start(void)
306 struct cpufreq_interactive_cpuinfo *pcpu =
307 &per_cpu(cpuinfo, smp_processor_id());
310 if (!pcpu->governor_enabled)
315 pending = timer_pending(&pcpu->cpu_timer);
317 if (pcpu->target_freq != pcpu->policy->min) {
320 * Entering idle while not at lowest speed. On some
321 * platforms this can hold the other CPU(s) at that speed
322 * even though the CPU is idle. Set a timer to re-evaluate
323 * speed so this idle CPU doesn't hold the other CPUs above
324 * min indefinitely. This should probably be a quirk of
325 * the CPUFreq driver.
328 pcpu->time_in_idle = get_cpu_idle_time_us(
329 smp_processor_id(), &pcpu->idle_exit_time);
330 pcpu->timer_idlecancel = 0;
331 mod_timer(&pcpu->cpu_timer,
332 jiffies + usecs_to_jiffies(timer_rate));
337 * If at min speed and entering idle after load has
338 * already been evaluated, and a timer has been set just in
339 * case the CPU suddenly goes busy, cancel that timer. The
340 * CPU didn't go busy; we'll recheck things upon idle exit.
342 if (pending && pcpu->timer_idlecancel) {
343 del_timer(&pcpu->cpu_timer);
345 * Ensure last timer run time is after current idle
346 * sample start time, so next idle exit will always
347 * start a new idle sampling period.
349 pcpu->idle_exit_time = 0;
350 pcpu->timer_idlecancel = 0;
356 static void cpufreq_interactive_idle_end(void)
358 struct cpufreq_interactive_cpuinfo *pcpu =
359 &per_cpu(cpuinfo, smp_processor_id());
365 * Arm the timer for 1-2 ticks later if not already, and if the timer
366 * function has already processed the previous load sampling
367 * interval. (If the timer is not pending but has not processed
368 * the previous interval, it is probably racing with us on another
369 * CPU. Let it compute load based on the previous sample and then
370 * re-arm the timer for another interval when it's done, rather
371 * than updating the interval start time to be "now", which doesn't
372 * give the timer function enough time to make a decision on this
375 if (timer_pending(&pcpu->cpu_timer) == 0 &&
376 pcpu->timer_run_time >= pcpu->idle_exit_time &&
377 pcpu->governor_enabled) {
379 get_cpu_idle_time_us(smp_processor_id(),
380 &pcpu->idle_exit_time);
381 pcpu->timer_idlecancel = 0;
382 mod_timer(&pcpu->cpu_timer,
383 jiffies + usecs_to_jiffies(timer_rate));
388 static int cpufreq_interactive_up_task(void *data)
393 struct cpufreq_interactive_cpuinfo *pcpu;
396 set_current_state(TASK_INTERRUPTIBLE);
397 spin_lock_irqsave(&up_cpumask_lock, flags);
399 if (cpumask_empty(&up_cpumask)) {
400 spin_unlock_irqrestore(&up_cpumask_lock, flags);
403 if (kthread_should_stop())
406 spin_lock_irqsave(&up_cpumask_lock, flags);
409 set_current_state(TASK_RUNNING);
410 tmp_mask = up_cpumask;
411 cpumask_clear(&up_cpumask);
412 spin_unlock_irqrestore(&up_cpumask_lock, flags);
414 for_each_cpu(cpu, &tmp_mask) {
416 unsigned int max_freq = 0;
418 pcpu = &per_cpu(cpuinfo, cpu);
421 if (!pcpu->governor_enabled)
424 mutex_lock(&set_speed_lock);
426 for_each_cpu(j, pcpu->policy->cpus) {
427 struct cpufreq_interactive_cpuinfo *pjcpu =
428 &per_cpu(cpuinfo, j);
430 if (pjcpu->target_freq > max_freq)
431 max_freq = pjcpu->target_freq;
434 if (max_freq != pcpu->policy->cur)
435 __cpufreq_driver_target(pcpu->policy,
438 mutex_unlock(&set_speed_lock);
439 trace_cpufreq_interactive_up(cpu, pcpu->target_freq,
447 static void cpufreq_interactive_freq_down(struct work_struct *work)
452 struct cpufreq_interactive_cpuinfo *pcpu;
454 spin_lock_irqsave(&down_cpumask_lock, flags);
455 tmp_mask = down_cpumask;
456 cpumask_clear(&down_cpumask);
457 spin_unlock_irqrestore(&down_cpumask_lock, flags);
459 for_each_cpu(cpu, &tmp_mask) {
461 unsigned int max_freq = 0;
463 pcpu = &per_cpu(cpuinfo, cpu);
466 if (!pcpu->governor_enabled)
469 mutex_lock(&set_speed_lock);
471 for_each_cpu(j, pcpu->policy->cpus) {
472 struct cpufreq_interactive_cpuinfo *pjcpu =
473 &per_cpu(cpuinfo, j);
475 if (pjcpu->target_freq > max_freq)
476 max_freq = pjcpu->target_freq;
479 if (max_freq != pcpu->policy->cur)
480 __cpufreq_driver_target(pcpu->policy, max_freq,
483 mutex_unlock(&set_speed_lock);
484 trace_cpufreq_interactive_down(cpu, pcpu->target_freq,
489 static void cpufreq_interactive_boost(void)
494 struct cpufreq_interactive_cpuinfo *pcpu;
496 trace_cpufreq_interactive_boost(hispeed_freq);
497 spin_lock_irqsave(&up_cpumask_lock, flags);
499 for_each_online_cpu(i) {
500 pcpu = &per_cpu(cpuinfo, i);
502 if (pcpu->target_freq < hispeed_freq) {
503 pcpu->target_freq = hispeed_freq;
504 cpumask_set_cpu(i, &up_cpumask);
505 pcpu->target_set_time_in_idle =
506 get_cpu_idle_time_us(i, &pcpu->target_set_time);
511 * Refresh time at which current (possibly being
512 * boosted) speed last validated (reset timer for
513 * allowing speed to drop).
516 pcpu->target_validate_time = ktime_to_us(ktime_get());
519 spin_unlock_irqrestore(&up_cpumask_lock, flags);
522 wake_up_process(up_task);
526 * Pulsed boost on input event raises CPUs to hispeed_freq and lets
527 * usual algorithm of min_sample_time decide when to allow speed
531 static void cpufreq_interactive_input_event(struct input_handle *handle,
533 unsigned int code, int value)
535 if (input_boost_val && type == EV_SYN && code == SYN_REPORT)
536 cpufreq_interactive_boost();
539 static void cpufreq_interactive_input_open(struct work_struct *w)
541 struct cpufreq_interactive_inputopen *io =
542 container_of(w, struct cpufreq_interactive_inputopen,
546 error = input_open_device(io->handle);
548 input_unregister_handle(io->handle);
551 static int cpufreq_interactive_input_connect(struct input_handler *handler,
552 struct input_dev *dev,
553 const struct input_device_id *id)
555 struct input_handle *handle;
558 pr_info("%s: connect to %s\n", __func__, dev->name);
559 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
564 handle->handler = handler;
565 handle->name = "cpufreq_interactive";
567 error = input_register_handle(handle);
571 inputopen.handle = handle;
572 queue_work(down_wq, &inputopen.inputopen_work);
579 static void cpufreq_interactive_input_disconnect(struct input_handle *handle)
581 input_close_device(handle);
582 input_unregister_handle(handle);
586 static const struct input_device_id cpufreq_interactive_ids[] = {
588 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
589 INPUT_DEVICE_ID_MATCH_ABSBIT,
590 .evbit = { BIT_MASK(EV_ABS) },
591 .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
592 BIT_MASK(ABS_MT_POSITION_X) |
593 BIT_MASK(ABS_MT_POSITION_Y) },
594 }, /* multi-touch touchscreen */
596 .flags = INPUT_DEVICE_ID_MATCH_KEYBIT |
597 INPUT_DEVICE_ID_MATCH_ABSBIT,
598 .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
599 .absbit = { [BIT_WORD(ABS_X)] =
600 BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) },
605 static struct input_handler cpufreq_interactive_input_handler = {
606 .event = cpufreq_interactive_input_event,
607 .connect = cpufreq_interactive_input_connect,
608 .disconnect = cpufreq_interactive_input_disconnect,
609 .name = "cpufreq_interactive",
610 .id_table = cpufreq_interactive_ids,
613 static ssize_t show_hispeed_freq(struct kobject *kobj,
614 struct attribute *attr, char *buf)
616 return sprintf(buf, "%llu\n", hispeed_freq);
619 static ssize_t store_hispeed_freq(struct kobject *kobj,
620 struct attribute *attr, const char *buf,
626 ret = strict_strtoull(buf, 0, &val);
633 static struct global_attr hispeed_freq_attr = __ATTR(hispeed_freq, 0644,
634 show_hispeed_freq, store_hispeed_freq);
637 static ssize_t show_go_hispeed_load(struct kobject *kobj,
638 struct attribute *attr, char *buf)
640 return sprintf(buf, "%lu\n", go_hispeed_load);
643 static ssize_t store_go_hispeed_load(struct kobject *kobj,
644 struct attribute *attr, const char *buf, size_t count)
649 ret = strict_strtoul(buf, 0, &val);
652 go_hispeed_load = val;
656 static struct global_attr go_hispeed_load_attr = __ATTR(go_hispeed_load, 0644,
657 show_go_hispeed_load, store_go_hispeed_load);
659 static ssize_t show_min_sample_time(struct kobject *kobj,
660 struct attribute *attr, char *buf)
662 return sprintf(buf, "%lu\n", min_sample_time);
665 static ssize_t store_min_sample_time(struct kobject *kobj,
666 struct attribute *attr, const char *buf, size_t count)
671 ret = strict_strtoul(buf, 0, &val);
674 min_sample_time = val;
678 static struct global_attr min_sample_time_attr = __ATTR(min_sample_time, 0644,
679 show_min_sample_time, store_min_sample_time);
681 static ssize_t show_above_hispeed_delay(struct kobject *kobj,
682 struct attribute *attr, char *buf)
684 return sprintf(buf, "%lu\n", above_hispeed_delay_val);
687 static ssize_t store_above_hispeed_delay(struct kobject *kobj,
688 struct attribute *attr,
689 const char *buf, size_t count)
694 ret = strict_strtoul(buf, 0, &val);
697 above_hispeed_delay_val = val;
701 define_one_global_rw(above_hispeed_delay);
703 static ssize_t show_timer_rate(struct kobject *kobj,
704 struct attribute *attr, char *buf)
706 return sprintf(buf, "%lu\n", timer_rate);
709 static ssize_t store_timer_rate(struct kobject *kobj,
710 struct attribute *attr, const char *buf, size_t count)
715 ret = strict_strtoul(buf, 0, &val);
722 static struct global_attr timer_rate_attr = __ATTR(timer_rate, 0644,
723 show_timer_rate, store_timer_rate);
725 static ssize_t show_input_boost(struct kobject *kobj, struct attribute *attr,
728 return sprintf(buf, "%u\n", input_boost_val);
731 static ssize_t store_input_boost(struct kobject *kobj, struct attribute *attr,
732 const char *buf, size_t count)
737 ret = strict_strtoul(buf, 0, &val);
740 input_boost_val = val;
744 define_one_global_rw(input_boost);
746 static ssize_t show_boost(struct kobject *kobj, struct attribute *attr,
749 return sprintf(buf, "%d\n", boost_val);
752 static ssize_t store_boost(struct kobject *kobj, struct attribute *attr,
753 const char *buf, size_t count)
758 ret = kstrtoul(buf, 0, &val);
765 cpufreq_interactive_boost();
767 trace_cpufreq_interactive_unboost(hispeed_freq);
772 define_one_global_rw(boost);
774 static struct attribute *interactive_attributes[] = {
775 &hispeed_freq_attr.attr,
776 &go_hispeed_load_attr.attr,
777 &above_hispeed_delay.attr,
778 &min_sample_time_attr.attr,
779 &timer_rate_attr.attr,
785 static struct attribute_group interactive_attr_group = {
786 .attrs = interactive_attributes,
787 .name = "interactive",
790 static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
795 struct cpufreq_interactive_cpuinfo *pcpu;
796 struct cpufreq_frequency_table *freq_table;
799 case CPUFREQ_GOV_START:
800 if (!cpu_online(policy->cpu))
804 cpufreq_frequency_get_table(policy->cpu);
806 for_each_cpu(j, policy->cpus) {
807 pcpu = &per_cpu(cpuinfo, j);
808 pcpu->policy = policy;
809 pcpu->target_freq = policy->cur;
810 pcpu->freq_table = freq_table;
811 pcpu->target_set_time_in_idle =
812 get_cpu_idle_time_us(j,
813 &pcpu->target_set_time);
814 pcpu->target_validate_time =
815 pcpu->target_set_time;
816 pcpu->governor_enabled = 1;
821 hispeed_freq = policy->max;
824 * Do not register the idle hook and create sysfs
825 * entries if we have already done so.
827 if (atomic_inc_return(&active_count) > 1)
830 rc = sysfs_create_group(cpufreq_global_kobject,
831 &interactive_attr_group);
835 rc = input_register_handler(&cpufreq_interactive_input_handler);
837 pr_warn("%s: failed to register input handler\n",
842 case CPUFREQ_GOV_STOP:
843 for_each_cpu(j, policy->cpus) {
844 pcpu = &per_cpu(cpuinfo, j);
845 pcpu->governor_enabled = 0;
847 del_timer_sync(&pcpu->cpu_timer);
850 * Reset idle exit time since we may cancel the timer
851 * before it can run after the last idle exit time,
852 * to avoid tripping the check in idle exit for a timer
853 * that is trying to run.
855 pcpu->idle_exit_time = 0;
858 flush_work(&freq_scale_down_work);
859 if (atomic_dec_return(&active_count) > 0)
862 input_unregister_handler(&cpufreq_interactive_input_handler);
863 sysfs_remove_group(cpufreq_global_kobject,
864 &interactive_attr_group);
868 case CPUFREQ_GOV_LIMITS:
869 if (policy->max < policy->cur)
870 __cpufreq_driver_target(policy,
871 policy->max, CPUFREQ_RELATION_H);
872 else if (policy->min > policy->cur)
873 __cpufreq_driver_target(policy,
874 policy->min, CPUFREQ_RELATION_L);
880 static int cpufreq_interactive_idle_notifier(struct notifier_block *nb,
886 cpufreq_interactive_idle_start();
889 cpufreq_interactive_idle_end();
896 static struct notifier_block cpufreq_interactive_idle_nb = {
897 .notifier_call = cpufreq_interactive_idle_notifier,
900 static int __init cpufreq_interactive_init(void)
903 struct cpufreq_interactive_cpuinfo *pcpu;
904 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
906 go_hispeed_load = DEFAULT_GO_HISPEED_LOAD;
907 min_sample_time = DEFAULT_MIN_SAMPLE_TIME;
908 above_hispeed_delay_val = DEFAULT_ABOVE_HISPEED_DELAY;
909 timer_rate = DEFAULT_TIMER_RATE;
911 /* Initalize per-cpu timers */
912 for_each_possible_cpu(i) {
913 pcpu = &per_cpu(cpuinfo, i);
914 init_timer(&pcpu->cpu_timer);
915 pcpu->cpu_timer.function = cpufreq_interactive_timer;
916 pcpu->cpu_timer.data = i;
919 up_task = kthread_create(cpufreq_interactive_up_task, NULL,
922 return PTR_ERR(up_task);
924 sched_setscheduler_nocheck(up_task, SCHED_FIFO, ¶m);
925 get_task_struct(up_task);
927 /* No rescuer thread, bind to CPU queuing the work for possibly
928 warm cache (probably doesn't matter much). */
929 down_wq = alloc_workqueue("knteractive_down", 0, 1);
934 INIT_WORK(&freq_scale_down_work,
935 cpufreq_interactive_freq_down);
937 spin_lock_init(&up_cpumask_lock);
938 spin_lock_init(&down_cpumask_lock);
939 mutex_init(&set_speed_lock);
941 idle_notifier_register(&cpufreq_interactive_idle_nb);
942 INIT_WORK(&inputopen.inputopen_work, cpufreq_interactive_input_open);
943 return cpufreq_register_governor(&cpufreq_gov_interactive);
946 put_task_struct(up_task);
950 #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE
951 fs_initcall(cpufreq_interactive_init);
953 module_init(cpufreq_interactive_init);
956 static void __exit cpufreq_interactive_exit(void)
958 cpufreq_unregister_governor(&cpufreq_gov_interactive);
959 kthread_stop(up_task);
960 put_task_struct(up_task);
961 destroy_workqueue(down_wq);
964 module_exit(cpufreq_interactive_exit);
966 MODULE_AUTHOR("Mike Chan <mike@android.com>");
967 MODULE_DESCRIPTION("'cpufreq_interactive' - A cpufreq governor for "
968 "Latency sensitive workloads");
969 MODULE_LICENSE("GPL");