ARM: tegra: cpuquiet: make userspace governor actions synchronous
[firefly-linux-kernel-4.4.55.git] / drivers / cpuquiet / governors / userspace.c
1 /*
2  * Copyright (c) 2012 NVIDIA CORPORATION.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16  *
17  */
18
19 #include <linux/mutex.h>
20 #include <linux/module.h>
21 #include <linux/cpuquiet.h>
22 #include <linux/sysfs.h>
23
24 static DEFINE_MUTEX(userspace_mutex);
25
26 static int governor_set(unsigned int cpu, bool active)
27 {
28         int err;
29
30         mutex_lock(&userspace_mutex);
31         if (active)
32                 err = cpuquiet_wake_cpu(cpu, true);
33         else
34                 err = cpuquiet_quiesence_cpu(cpu, true);
35         mutex_unlock(&userspace_mutex);
36
37         return err;
38 }
39
40 struct cpuquiet_governor userspace_governor = {
41         .name           = "userspace",
42         .store_active   = governor_set,
43         .owner          = THIS_MODULE,
44 };
45
46 static int __init init_usermode(void)
47 {
48         return cpuquiet_register_governor(&userspace_governor);
49 }
50
51 static void __exit exit_usermode(void)
52 {
53         cpuquiet_unregister_governor(&userspace_governor);
54 }
55
56 MODULE_LICENSE("GPL");
57 #ifdef CONFIG_CPUQUIET_DEFAULT_GOV_USERSPACE
58 fs_initcall(init_usermode);
59 #else
60 module_init(init_usermode);
61 #endif
62 module_exit(exit_usermode);