Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
cpufreq: fallback to interactive if governor is not found
Browse files Browse the repository at this point in the history
Nowadays, custom ROMs are starting to set custom governor profiles via
init scripts, often times involving custom governors (like DrunkSauce,
which is impulse on little and ironactive on big). If the user sticks
with the built-in kernel, that is totally fine as everything will get
loaded up properly. However, if the user decides to switch to a custom
kernel and those governors are not present, this function will fail to
find them when and the governor will not change. I attempt to work
around this by modifying how the method handles finding the governor.

Process without this patch:
1. Phone boots with performance governor.
2. Init scripts attempts to write custom governor to sys path.
3. The function cpufreq_parse_governor fails to locate the
   governor and returns -EINVAL since the input was invalid.
4. The phone does not switch from the performance governor.

Process with this patch:
1. Phone boots with performance governor.
2. Init scripts attempts to write the custom governor to sys path.
3. The function cpufreq_parse_governor fails to locate the
   governor but then tries to locate the interactive governor.
4. The interactive governor is then applied.

A couple of notes:
1. If you have a different governor that you want to be set on
   boot, make sure to change interactive to that governor's
   name.
2. This is a little bit of a hack; ideally, it'd be nice to
   only switch to interactive if the current governor is
   performance so that already applied governors/settings
   are not overwritten but there is not really a scenario
   where this will be accidentally be activated since
   custom kernel tweaking apps will only show governors that
   are currently available. Maybe when I have more time will
   I explore this in depth.

Signed-off-by: Nathan Chancellor <[email protected]>
(cherry picked from commit 58ef44b)
  • Loading branch information
nathanchance committed Apr 12, 2018
1 parent 3d2cc0a commit 52d73bc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,27 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
ret = request_module("cpufreq_%s", str_governor);
mutex_lock(&cpufreq_governor_mutex);

/*
* At this point, if the governor was found via module
* search, it will load it. However, if it didn't, we
* are just going to exit without doing anything to
* the governor. Most of the time, this is totally
* fine; the one scenario where it's not is when a ROM
* has a boot script that requests a governor that
* exists in the default kernel but not in this one.
* This kernel (and nearly every other Android kernel)
* has the performance governor as default for boot
* performance which is then changed to another,
* usually interactive. So, instead of just exiting if
* the requested governor wasn't found, let's try
* falling back to interactive before falling out.
*/
if (ret == 0)
t = find_governor(str_governor);
#ifdef CONFIG_CPU_FREQ_GOV_INTERACTIVE
else
t = find_governor("interactive");
#endif
}

if (t != NULL) {
Expand Down

0 comments on commit 52d73bc

Please sign in to comment.