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 struct cpufreq_policy *policy;
51 struct cpufreq_frequency_table *freq_table;
52 unsigned int target_freq;
53 unsigned int floor_freq;
54 u64 floor_validate_time;
58 static DEFINE_PER_CPU(struct cpufreq_interactive_cpuinfo, cpuinfo);
60 /* Workqueues handle frequency scaling */
61 static struct task_struct *up_task;
62 static struct workqueue_struct *down_wq;
63 static struct work_struct freq_scale_down_work;
64 static cpumask_t up_cpumask;
65 static spinlock_t up_cpumask_lock;
66 static cpumask_t down_cpumask;
67 static spinlock_t down_cpumask_lock;
68 static struct mutex set_speed_lock;
70 /* Hi speed to bump to from lo speed when load burst (default max) */
71 static u64 hispeed_freq;
73 /* Go to hi speed when CPU load at or above this value. */
74 #define DEFAULT_GO_HISPEED_LOAD 85
75 static unsigned long go_hispeed_load;
78 * The minimum amount of time to spend at a frequency before we can ramp down.
80 #define DEFAULT_MIN_SAMPLE_TIME (80 * USEC_PER_MSEC)
81 static unsigned long min_sample_time;
84 * The sample rate of the timer used to increase frequency
86 #define DEFAULT_TIMER_RATE (20 * USEC_PER_MSEC)
87 static unsigned long timer_rate;
90 * Wait this long before raising speed above hispeed, by default a single
93 #define DEFAULT_ABOVE_HISPEED_DELAY DEFAULT_TIMER_RATE
94 static unsigned long above_hispeed_delay_val;
97 * Boost pulse to hispeed on touchscreen input.
100 static int input_boost_val;
102 struct cpufreq_interactive_inputopen {
103 struct input_handle *handle;
104 struct work_struct inputopen_work;
107 static struct cpufreq_interactive_inputopen inputopen;
110 * Non-zero means longer-term speed boost active.
113 static int boost_val;
115 static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
118 #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE
121 struct cpufreq_governor cpufreq_gov_interactive = {
122 .name = "interactive",
123 .governor = cpufreq_governor_interactive,
124 .max_transition_latency = 10000000,
125 .owner = THIS_MODULE,
128 static void cpufreq_interactive_timer(unsigned long data)
130 unsigned int delta_idle;
131 unsigned int delta_time;
133 int load_since_change;
136 struct cpufreq_interactive_cpuinfo *pcpu =
137 &per_cpu(cpuinfo, data);
139 unsigned int new_freq;
145 if (!pcpu->governor_enabled)
149 * Once pcpu->timer_run_time is updated to >= pcpu->idle_exit_time,
150 * this lets idle exit know the current idle time sample has
151 * been processed, and idle exit can generate a new sample and
152 * re-arm the timer. This prevents a concurrent idle
153 * exit on that CPU from writing a new set of info at the same time
154 * the timer function runs (the timer function can't use that info
155 * until more time passes).
157 time_in_idle = pcpu->time_in_idle;
158 idle_exit_time = pcpu->idle_exit_time;
159 now_idle = get_cpu_idle_time_us(data, &pcpu->timer_run_time);
162 /* If we raced with cancelling a timer, skip. */
166 delta_idle = (unsigned int)(now_idle - time_in_idle);
167 delta_time = (unsigned int)(pcpu->timer_run_time - idle_exit_time);
170 * If timer ran less than 1ms after short-term sample started, retry.
172 if (delta_time < 1000)
175 if (delta_idle > delta_time)
178 cpu_load = 100 * (delta_time - delta_idle) / delta_time;
180 delta_idle = (unsigned int)(now_idle - pcpu->target_set_time_in_idle);
181 delta_time = (unsigned int)(pcpu->timer_run_time -
182 pcpu->target_set_time);
184 if ((delta_time == 0) || (delta_idle > delta_time))
185 load_since_change = 0;
188 100 * (delta_time - delta_idle) / delta_time;
191 * Choose greater of short-term load (since last idle timer
192 * started or timer function re-armed itself) or long-term load
193 * (since last frequency change).
195 if (load_since_change > cpu_load)
196 cpu_load = load_since_change;
198 if (cpu_load >= go_hispeed_load || boost_val) {
199 if (pcpu->target_freq <= pcpu->policy->min) {
200 new_freq = hispeed_freq;
202 new_freq = pcpu->policy->max * cpu_load / 100;
204 if (new_freq < hispeed_freq)
205 new_freq = hispeed_freq;
207 if (pcpu->target_freq == hispeed_freq &&
208 new_freq > hispeed_freq &&
209 pcpu->timer_run_time - pcpu->target_set_time
210 < above_hispeed_delay_val) {
211 trace_cpufreq_interactive_notyet(data, cpu_load,
218 new_freq = pcpu->policy->max * cpu_load / 100;
221 if (cpufreq_frequency_table_target(pcpu->policy, pcpu->freq_table,
222 new_freq, CPUFREQ_RELATION_H,
224 pr_warn_once("timer %d: cpufreq_frequency_table_target error\n",
229 new_freq = pcpu->freq_table[index].frequency;
232 * Do not scale below floor_freq unless we have been at or above the
233 * floor frequency for the minimum sample time since last validated.
235 if (new_freq < pcpu->floor_freq) {
236 if (pcpu->timer_run_time - pcpu->target_validate_time
238 trace_cpufreq_interactive_notyet(data, cpu_load,
239 pcpu->target_freq, new_freq);
244 pcpu->floor_freq = new_freq;
245 pcpu->floor_validate_time = pcpu->timer_run_time;
247 if (pcpu->target_freq == new_freq) {
248 trace_cpufreq_interactive_already(data, cpu_load,
249 pcpu->target_freq, new_freq);
250 goto rearm_if_notmax;
253 trace_cpufreq_interactive_target(data, cpu_load, pcpu->target_freq,
255 pcpu->target_set_time_in_idle = now_idle;
256 pcpu->target_set_time = pcpu->timer_run_time;
258 if (new_freq < pcpu->target_freq) {
259 pcpu->target_freq = new_freq;
260 spin_lock_irqsave(&down_cpumask_lock, flags);
261 cpumask_set_cpu(data, &down_cpumask);
262 spin_unlock_irqrestore(&down_cpumask_lock, flags);
263 queue_work(down_wq, &freq_scale_down_work);
265 pcpu->target_freq = new_freq;
266 spin_lock_irqsave(&up_cpumask_lock, flags);
267 cpumask_set_cpu(data, &up_cpumask);
268 spin_unlock_irqrestore(&up_cpumask_lock, flags);
269 wake_up_process(up_task);
274 * Already set max speed and don't see a need to change that,
275 * wait until next idle to re-evaluate, don't need timer.
277 if (pcpu->target_freq == pcpu->policy->max)
281 if (!timer_pending(&pcpu->cpu_timer)) {
283 * If already at min: if that CPU is idle, don't set timer.
284 * Else cancel the timer if that CPU goes idle. We don't
285 * need to re-evaluate speed until the next idle exit.
287 if (pcpu->target_freq == pcpu->policy->min) {
293 pcpu->timer_idlecancel = 1;
296 pcpu->time_in_idle = get_cpu_idle_time_us(
297 data, &pcpu->idle_exit_time);
298 mod_timer(&pcpu->cpu_timer,
299 jiffies + usecs_to_jiffies(timer_rate));
306 static void cpufreq_interactive_idle_start(void)
308 struct cpufreq_interactive_cpuinfo *pcpu =
309 &per_cpu(cpuinfo, smp_processor_id());
312 if (!pcpu->governor_enabled)
317 pending = timer_pending(&pcpu->cpu_timer);
319 if (pcpu->target_freq != pcpu->policy->min) {
322 * Entering idle while not at lowest speed. On some
323 * platforms this can hold the other CPU(s) at that speed
324 * even though the CPU is idle. Set a timer to re-evaluate
325 * speed so this idle CPU doesn't hold the other CPUs above
326 * min indefinitely. This should probably be a quirk of
327 * the CPUFreq driver.
330 pcpu->time_in_idle = get_cpu_idle_time_us(
331 smp_processor_id(), &pcpu->idle_exit_time);
332 pcpu->timer_idlecancel = 0;
333 mod_timer(&pcpu->cpu_timer,
334 jiffies + usecs_to_jiffies(timer_rate));
339 * If at min speed and entering idle after load has
340 * already been evaluated, and a timer has been set just in
341 * case the CPU suddenly goes busy, cancel that timer. The
342 * CPU didn't go busy; we'll recheck things upon idle exit.
344 if (pending && pcpu->timer_idlecancel) {
345 del_timer(&pcpu->cpu_timer);
347 * Ensure last timer run time is after current idle
348 * sample start time, so next idle exit will always
349 * start a new idle sampling period.
351 pcpu->idle_exit_time = 0;
352 pcpu->timer_idlecancel = 0;
358 static void cpufreq_interactive_idle_end(void)
360 struct cpufreq_interactive_cpuinfo *pcpu =
361 &per_cpu(cpuinfo, smp_processor_id());
367 * Arm the timer for 1-2 ticks later if not already, and if the timer
368 * function has already processed the previous load sampling
369 * interval. (If the timer is not pending but has not processed
370 * the previous interval, it is probably racing with us on another
371 * CPU. Let it compute load based on the previous sample and then
372 * re-arm the timer for another interval when it's done, rather
373 * than updating the interval start time to be "now", which doesn't
374 * give the timer function enough time to make a decision on this
377 if (timer_pending(&pcpu->cpu_timer) == 0 &&
378 pcpu->timer_run_time >= pcpu->idle_exit_time &&
379 pcpu->governor_enabled) {
381 get_cpu_idle_time_us(smp_processor_id(),
382 &pcpu->idle_exit_time);
383 pcpu->timer_idlecancel = 0;
384 mod_timer(&pcpu->cpu_timer,
385 jiffies + usecs_to_jiffies(timer_rate));
390 static int cpufreq_interactive_up_task(void *data)
395 struct cpufreq_interactive_cpuinfo *pcpu;
398 set_current_state(TASK_INTERRUPTIBLE);
399 spin_lock_irqsave(&up_cpumask_lock, flags);
401 if (cpumask_empty(&up_cpumask)) {
402 spin_unlock_irqrestore(&up_cpumask_lock, flags);
405 if (kthread_should_stop())
408 spin_lock_irqsave(&up_cpumask_lock, flags);
411 set_current_state(TASK_RUNNING);
412 tmp_mask = up_cpumask;
413 cpumask_clear(&up_cpumask);
414 spin_unlock_irqrestore(&up_cpumask_lock, flags);
416 for_each_cpu(cpu, &tmp_mask) {
418 unsigned int max_freq = 0;
420 pcpu = &per_cpu(cpuinfo, cpu);
423 if (!pcpu->governor_enabled)
426 mutex_lock(&set_speed_lock);
428 for_each_cpu(j, pcpu->policy->cpus) {
429 struct cpufreq_interactive_cpuinfo *pjcpu =
430 &per_cpu(cpuinfo, j);
432 if (pjcpu->target_freq > max_freq)
433 max_freq = pjcpu->target_freq;
436 if (max_freq != pcpu->policy->cur)
437 __cpufreq_driver_target(pcpu->policy,
440 mutex_unlock(&set_speed_lock);
441 trace_cpufreq_interactive_up(cpu, pcpu->target_freq,
449 static void cpufreq_interactive_freq_down(struct work_struct *work)
454 struct cpufreq_interactive_cpuinfo *pcpu;
456 spin_lock_irqsave(&down_cpumask_lock, flags);
457 tmp_mask = down_cpumask;
458 cpumask_clear(&down_cpumask);
459 spin_unlock_irqrestore(&down_cpumask_lock, flags);
461 for_each_cpu(cpu, &tmp_mask) {
463 unsigned int max_freq = 0;
465 pcpu = &per_cpu(cpuinfo, cpu);
468 if (!pcpu->governor_enabled)
471 mutex_lock(&set_speed_lock);
473 for_each_cpu(j, pcpu->policy->cpus) {
474 struct cpufreq_interactive_cpuinfo *pjcpu =
475 &per_cpu(cpuinfo, j);
477 if (pjcpu->target_freq > max_freq)
478 max_freq = pjcpu->target_freq;
481 if (max_freq != pcpu->policy->cur)
482 __cpufreq_driver_target(pcpu->policy, max_freq,
485 mutex_unlock(&set_speed_lock);
486 trace_cpufreq_interactive_down(cpu, pcpu->target_freq,
491 static void cpufreq_interactive_boost(void)
496 struct cpufreq_interactive_cpuinfo *pcpu;
498 trace_cpufreq_interactive_boost(hispeed_freq);
499 spin_lock_irqsave(&up_cpumask_lock, flags);
501 for_each_online_cpu(i) {
502 pcpu = &per_cpu(cpuinfo, i);
504 if (pcpu->target_freq < hispeed_freq) {
505 pcpu->target_freq = hispeed_freq;
506 cpumask_set_cpu(i, &up_cpumask);
507 pcpu->target_set_time_in_idle =
508 get_cpu_idle_time_us(i, &pcpu->target_set_time);
513 * Set floor freq and (re)start timer for when last
517 pcpu->floor_freq = hispeed_freq;
518 pcpu->floor_validate_time = ktime_to_us(ktime_get());
521 spin_unlock_irqrestore(&up_cpumask_lock, flags);
524 wake_up_process(up_task);
528 * Pulsed boost on input event raises CPUs to hispeed_freq and lets
529 * usual algorithm of min_sample_time decide when to allow speed
533 static void cpufreq_interactive_input_event(struct input_handle *handle,
535 unsigned int code, int value)
537 if (input_boost_val && type == EV_SYN && code == SYN_REPORT)
538 cpufreq_interactive_boost();
541 static void cpufreq_interactive_input_open(struct work_struct *w)
543 struct cpufreq_interactive_inputopen *io =
544 container_of(w, struct cpufreq_interactive_inputopen,
548 error = input_open_device(io->handle);
550 input_unregister_handle(io->handle);
553 static int cpufreq_interactive_input_connect(struct input_handler *handler,
554 struct input_dev *dev,
555 const struct input_device_id *id)
557 struct input_handle *handle;
560 pr_info("%s: connect to %s\n", __func__, dev->name);
561 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
566 handle->handler = handler;
567 handle->name = "cpufreq_interactive";
569 error = input_register_handle(handle);
573 inputopen.handle = handle;
574 queue_work(down_wq, &inputopen.inputopen_work);
581 static void cpufreq_interactive_input_disconnect(struct input_handle *handle)
583 input_close_device(handle);
584 input_unregister_handle(handle);
588 static const struct input_device_id cpufreq_interactive_ids[] = {
590 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
591 INPUT_DEVICE_ID_MATCH_ABSBIT,
592 .evbit = { BIT_MASK(EV_ABS) },
593 .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
594 BIT_MASK(ABS_MT_POSITION_X) |
595 BIT_MASK(ABS_MT_POSITION_Y) },
596 }, /* multi-touch touchscreen */
598 .flags = INPUT_DEVICE_ID_MATCH_KEYBIT |
599 INPUT_DEVICE_ID_MATCH_ABSBIT,
600 .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
601 .absbit = { [BIT_WORD(ABS_X)] =
602 BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) },
607 static struct input_handler cpufreq_interactive_input_handler = {
608 .event = cpufreq_interactive_input_event,
609 .connect = cpufreq_interactive_input_connect,
610 .disconnect = cpufreq_interactive_input_disconnect,
611 .name = "cpufreq_interactive",
612 .id_table = cpufreq_interactive_ids,
615 static ssize_t show_hispeed_freq(struct kobject *kobj,
616 struct attribute *attr, char *buf)
618 return sprintf(buf, "%llu\n", hispeed_freq);
621 static ssize_t store_hispeed_freq(struct kobject *kobj,
622 struct attribute *attr, const char *buf,
628 ret = strict_strtoull(buf, 0, &val);
635 static struct global_attr hispeed_freq_attr = __ATTR(hispeed_freq, 0644,
636 show_hispeed_freq, store_hispeed_freq);
639 static ssize_t show_go_hispeed_load(struct kobject *kobj,
640 struct attribute *attr, char *buf)
642 return sprintf(buf, "%lu\n", go_hispeed_load);
645 static ssize_t store_go_hispeed_load(struct kobject *kobj,
646 struct attribute *attr, const char *buf, size_t count)
651 ret = strict_strtoul(buf, 0, &val);
654 go_hispeed_load = val;
658 static struct global_attr go_hispeed_load_attr = __ATTR(go_hispeed_load, 0644,
659 show_go_hispeed_load, store_go_hispeed_load);
661 static ssize_t show_min_sample_time(struct kobject *kobj,
662 struct attribute *attr, char *buf)
664 return sprintf(buf, "%lu\n", min_sample_time);
667 static ssize_t store_min_sample_time(struct kobject *kobj,
668 struct attribute *attr, const char *buf, size_t count)
673 ret = strict_strtoul(buf, 0, &val);
676 min_sample_time = val;
680 static struct global_attr min_sample_time_attr = __ATTR(min_sample_time, 0644,
681 show_min_sample_time, store_min_sample_time);
683 static ssize_t show_above_hispeed_delay(struct kobject *kobj,
684 struct attribute *attr, char *buf)
686 return sprintf(buf, "%lu\n", above_hispeed_delay_val);
689 static ssize_t store_above_hispeed_delay(struct kobject *kobj,
690 struct attribute *attr,
691 const char *buf, size_t count)
696 ret = strict_strtoul(buf, 0, &val);
699 above_hispeed_delay_val = val;
703 define_one_global_rw(above_hispeed_delay);
705 static ssize_t show_timer_rate(struct kobject *kobj,
706 struct attribute *attr, char *buf)
708 return sprintf(buf, "%lu\n", timer_rate);
711 static ssize_t store_timer_rate(struct kobject *kobj,
712 struct attribute *attr, const char *buf, size_t count)
717 ret = strict_strtoul(buf, 0, &val);
724 static struct global_attr timer_rate_attr = __ATTR(timer_rate, 0644,
725 show_timer_rate, store_timer_rate);
727 static ssize_t show_input_boost(struct kobject *kobj, struct attribute *attr,
730 return sprintf(buf, "%u\n", input_boost_val);
733 static ssize_t store_input_boost(struct kobject *kobj, struct attribute *attr,
734 const char *buf, size_t count)
739 ret = strict_strtoul(buf, 0, &val);
742 input_boost_val = val;
746 define_one_global_rw(input_boost);
748 static ssize_t show_boost(struct kobject *kobj, struct attribute *attr,
751 return sprintf(buf, "%d\n", boost_val);
754 static ssize_t store_boost(struct kobject *kobj, struct attribute *attr,
755 const char *buf, size_t count)
760 ret = kstrtoul(buf, 0, &val);
767 cpufreq_interactive_boost();
769 trace_cpufreq_interactive_unboost(hispeed_freq);
774 define_one_global_rw(boost);
776 static struct attribute *interactive_attributes[] = {
777 &hispeed_freq_attr.attr,
778 &go_hispeed_load_attr.attr,
779 &above_hispeed_delay.attr,
780 &min_sample_time_attr.attr,
781 &timer_rate_attr.attr,
787 static struct attribute_group interactive_attr_group = {
788 .attrs = interactive_attributes,
789 .name = "interactive",
792 static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
797 struct cpufreq_interactive_cpuinfo *pcpu;
798 struct cpufreq_frequency_table *freq_table;
801 case CPUFREQ_GOV_START:
802 if (!cpu_online(policy->cpu))
806 cpufreq_frequency_get_table(policy->cpu);
808 for_each_cpu(j, policy->cpus) {
809 pcpu = &per_cpu(cpuinfo, j);
810 pcpu->policy = policy;
811 pcpu->target_freq = policy->cur;
812 pcpu->freq_table = freq_table;
813 pcpu->target_set_time_in_idle =
814 get_cpu_idle_time_us(j,
815 &pcpu->target_set_time);
816 pcpu->floor_freq = pcpu->target_freq;
817 pcpu->floor_validate_time =
818 pcpu->target_set_time;
819 pcpu->governor_enabled = 1;
824 hispeed_freq = policy->max;
827 * Do not register the idle hook and create sysfs
828 * entries if we have already done so.
830 if (atomic_inc_return(&active_count) > 1)
833 rc = sysfs_create_group(cpufreq_global_kobject,
834 &interactive_attr_group);
838 rc = input_register_handler(&cpufreq_interactive_input_handler);
840 pr_warn("%s: failed to register input handler\n",
845 case CPUFREQ_GOV_STOP:
846 for_each_cpu(j, policy->cpus) {
847 pcpu = &per_cpu(cpuinfo, j);
848 pcpu->governor_enabled = 0;
850 del_timer_sync(&pcpu->cpu_timer);
853 * Reset idle exit time since we may cancel the timer
854 * before it can run after the last idle exit time,
855 * to avoid tripping the check in idle exit for a timer
856 * that is trying to run.
858 pcpu->idle_exit_time = 0;
861 flush_work(&freq_scale_down_work);
862 if (atomic_dec_return(&active_count) > 0)
865 input_unregister_handler(&cpufreq_interactive_input_handler);
866 sysfs_remove_group(cpufreq_global_kobject,
867 &interactive_attr_group);
871 case CPUFREQ_GOV_LIMITS:
872 if (policy->max < policy->cur)
873 __cpufreq_driver_target(policy,
874 policy->max, CPUFREQ_RELATION_H);
875 else if (policy->min > policy->cur)
876 __cpufreq_driver_target(policy,
877 policy->min, CPUFREQ_RELATION_L);
883 static int cpufreq_interactive_idle_notifier(struct notifier_block *nb,
889 cpufreq_interactive_idle_start();
892 cpufreq_interactive_idle_end();
899 static struct notifier_block cpufreq_interactive_idle_nb = {
900 .notifier_call = cpufreq_interactive_idle_notifier,
903 static int __init cpufreq_interactive_init(void)
906 struct cpufreq_interactive_cpuinfo *pcpu;
907 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
909 go_hispeed_load = DEFAULT_GO_HISPEED_LOAD;
910 min_sample_time = DEFAULT_MIN_SAMPLE_TIME;
911 above_hispeed_delay_val = DEFAULT_ABOVE_HISPEED_DELAY;
912 timer_rate = DEFAULT_TIMER_RATE;
914 /* Initalize per-cpu timers */
915 for_each_possible_cpu(i) {
916 pcpu = &per_cpu(cpuinfo, i);
917 init_timer(&pcpu->cpu_timer);
918 pcpu->cpu_timer.function = cpufreq_interactive_timer;
919 pcpu->cpu_timer.data = i;
922 up_task = kthread_create(cpufreq_interactive_up_task, NULL,
925 return PTR_ERR(up_task);
927 sched_setscheduler_nocheck(up_task, SCHED_FIFO, ¶m);
928 get_task_struct(up_task);
930 /* No rescuer thread, bind to CPU queuing the work for possibly
931 warm cache (probably doesn't matter much). */
932 down_wq = alloc_workqueue("knteractive_down", 0, 1);
937 INIT_WORK(&freq_scale_down_work,
938 cpufreq_interactive_freq_down);
940 spin_lock_init(&up_cpumask_lock);
941 spin_lock_init(&down_cpumask_lock);
942 mutex_init(&set_speed_lock);
944 idle_notifier_register(&cpufreq_interactive_idle_nb);
945 INIT_WORK(&inputopen.inputopen_work, cpufreq_interactive_input_open);
946 return cpufreq_register_governor(&cpufreq_gov_interactive);
949 put_task_struct(up_task);
953 #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE
954 fs_initcall(cpufreq_interactive_init);
956 module_init(cpufreq_interactive_init);
959 static void __exit cpufreq_interactive_exit(void)
961 cpufreq_unregister_governor(&cpufreq_gov_interactive);
962 kthread_stop(up_task);
963 put_task_struct(up_task);
964 destroy_workqueue(down_wq);
967 module_exit(cpufreq_interactive_exit);
969 MODULE_AUTHOR("Mike Chan <mike@android.com>");
970 MODULE_DESCRIPTION("'cpufreq_interactive' - A cpufreq governor for "
971 "Latency sensitive workloads");
972 MODULE_LICENSE("GPL");