aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/cpuidle/governor.c
diff options
context:
space:
mode:
authorJoao Martins <joao.m.martins@oracle.com>2019-09-08 00:45:21 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-09-11 17:36:30 +0200
commitcb5d8c45ab6c3daf8269e550cfb2d5018a876fe3 (patch)
tree0d045a3cc65bd198bf7f139a550005a96b1ef4a5 /drivers/cpuidle/governor.c
parentpowercap: idle_inject: Use higher resolution for idle injection (diff)
downloadwireguard-linux-cb5d8c45ab6c3daf8269e550cfb2d5018a876fe3.tar.xz
wireguard-linux-cb5d8c45ab6c3daf8269e550cfb2d5018a876fe3.zip
cpuidle: allow governor switch on cpuidle_register_driver()
The recently introduced haltpoll driver is largely only useful with haltpoll governor. To allow drivers to associate with a particular idle behaviour, add a @governor property to 'struct cpuidle_driver' and thus allow a cpuidle driver to switch to a *preferred* governor on idle driver registration. We save the previous governor, and when an idle driver is unregistered we switch back to that. The @governor can be overridden by cpuidle.governor= boot param or alternatively be ignored if the governor doesn't exist. Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle/governor.c')
-rw-r--r--drivers/cpuidle/governor.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
index 2e3e14192bee..e9801f26c732 100644
--- a/drivers/cpuidle/governor.c
+++ b/drivers/cpuidle/governor.c
@@ -20,14 +20,15 @@ char param_governor[CPUIDLE_NAME_LEN];
LIST_HEAD(cpuidle_governors);
struct cpuidle_governor *cpuidle_curr_governor;
+struct cpuidle_governor *cpuidle_prev_governor;
/**
- * __cpuidle_find_governor - finds a governor of the specified name
+ * cpuidle_find_governor - finds a governor of the specified name
* @str: the name
*
* Must be called with cpuidle_lock acquired.
*/
-static struct cpuidle_governor * __cpuidle_find_governor(const char *str)
+struct cpuidle_governor *cpuidle_find_governor(const char *str)
{
struct cpuidle_governor *gov;
@@ -87,7 +88,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
return -ENODEV;
mutex_lock(&cpuidle_lock);
- if (__cpuidle_find_governor(gov->name) == NULL) {
+ if (cpuidle_find_governor(gov->name) == NULL) {
ret = 0;
list_add_tail(&gov->governor_list, &cpuidle_governors);
if (!cpuidle_curr_governor ||