[Note Edge General] AlaskaLinuxUser:
Post #8. kernel - How to add CPU/GPU Governors.

Post #8. kernel - How to add CPU/GPU Governors.

Where to get CPU and GPU governors:

That is a really great question. Essentially, for CPU governors, you can pull them from any kernel by searching github. However, I recommend you pull from a kernel from either the same phone and/or kernel version. If you are using 3.10.40, but you pull from a kernel that is 3.10.84, there may be dependencies that are missing from your older kernel. In the case of the Nightmare example, I had to edit the governor itself to make it work with the kernel I was using.

For sure, if you follow this guide, you can always borrow mine :D

https://github.com/alaskalinuxuser/kernel_samsung_tblte

They will come from the drivers/cpufreq/ folder, and should be named cpufreq_{governor_name.c}. So, if you are looking for Nightmare, you can search github for cpufreq_nightmare.c, or use Google with "github cpufreq_nightmare.c".

GPU governors are a bit more complicated, see below for how to implement one, and then you can better see where to get one.

The non-technical guide to understanding CPU/GPU governors:

http://xdaforums.com/galaxy-s4-tmobile/general/technical-guide-to-understanding-cpu-t3440156

Adding CPU Governors:

Adding a kernel governor can be a Nightmare!

You can read the commit here: https://github.com/alaskalinuxuser/...mmit/19ba1b4f94d04877a5a783843a01c2494ecb1d5c

Okay, so a little play on words, especially since I am adding the Nightmare governor to the kernel, but it did turn out to be a bit of a problem child, fortunately, it was quickly corrected. As you can see, I did the standard additions, as well as adding the cpufreq_nightmare.c file: https://github.com/alaskalinuxuser/...94ecb1d5c/drivers/cpufreq/cpufreq_nightmare.c You can download it there.

The CPU Governor files are in the drivers/cpufreq/ folder, and all start with cpufreq_{DRIVERNAME}.

Added to drivers/cpufreq/Makefile, where the other cpufreq_*'s are:

.............EDITED FOR SPACE.......................
obj-$(CONFIG_CPU_FREQ_GOV_NIGHTMARE)	+= cpufreq_nightmare.o
.............EDITED FOR SPACE.......................

Added to drivers/cpufreq/Kconfig, where the other CPU_FREQ_DEFAULT_GOV_*'s are:

.............EDITED FOR SPACE.......................
config CPU_FREQ_DEFAULT_GOV_NIGHTMARE
bool "nightmare"
select CPU_FREQ_GOV_NIGHTMARE
help
Use the CPUFreq governor 'nightmare' as default. -WJH

Also added to drivers/cpufreq/Kconfig, where the other CPU_FREQ_GOV_*'s are:

.............EDITED FOR SPACE.......................
config CPU_FREQ_GOV_NIGHTMARE
tristate "'nightmare' cpufreq policy governor"
help
'nightmare' - This driver is a modified PegasusQ.

To compile this driver as a module, choose M here: the
module will be called cpufreq_nightmare.

For details, take a look at linux/Documentation/cpu-freq.

If in doubt, say N. -WJH
.............EDITED FOR SPACE.......................

Added to include/linux/cpufreq.h, right where the other CONFIG_CPU_FREQ_DEFAULT_GOV_*'s were :

.............EDITED FOR SPACE.......................
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_NIGHTMARE)
extern struct cpufreq_governor cpufreq_gov_nightmare;
#define CPUFREQ_DEFAULT_GOVERNOR	(&cpufreq_gov_nightmare)
.............EDITED FOR SPACE.......................

Added to arch/arm/configs/apq8084_sec_defconfig, right under "CONFIG_CPU_FREQ_GOV_POWERSAVE":

.............EDITED FOR SPACE.......................
CONFIG_CPU_FREQ_GOV_NIGHTMARE=y
.............EDITED FOR SPACE.......................

Adding GPU governors:

Comming soon.