[Nexus 7 Original Development] show-p1984:
Knowledge base:

What is tegra_mpdecision?

100% kernel based multi core decision! (should cpu1/2/3 be online or not, do we need the low-power/ninja core now?)

This replaces the stock nvidia hotplug solution.

Check /sys/kernel/tegra_mpdecision/conf/ for the configuration.

startdelay = time until mpdecision starts doing it's magic (20000)

delay = time between checks (130)

pause = if something else plugs in the cpu, fall asleep for 10000ms (10 secs)

scroff_single_core = Force low-power mode if screen is off (1)

enabled = enable(1) or disable(0) mpdecision. This does not affect scroff_single_core!

min_cpus = min cpus to be online, cannot be < 1. Default: 1

max_cpus = max cpus to be online, cannot be > 4. (if you set it to 2 and min_cpus to 1 you will basically have a dualcore) Default: 4

idle_freq = a value against that will be checked if a core +/- is requested. (475000)

lpcpu_up_hsyteresis = minimum number of requests that have to be send in order to switch to low-power mode (4)

lpcpu_down_hsyteresis = minimum number of requests that have to be send in order to switch to g-mode (quadcore-mode). Overridden by a requested freq that is higher than the max supported lp-mode frequency. (2)

If cpu0 is below that value and a core up of another cpu is requested, nothing will happen.

If any other cpu is above that value and a core down of that cpu is requested, nothing will happen. (otherwise it would now put down that cpu even though it is still working, which isn't what we want)

Hot plug thresholds (aka now it gets 'complicated')

This small formula calculates which value will be used: (number_of_cpus_online - 1) * 2

The result of this formula will be the nwns_threshold where a new cpu is hotplugged.

The result of this formula + 1 will be the nwns_threshold where a cpu is unplugged.

nwns_threshold_x = runqueue threshold, if this is reached cpuX will be hot/unplugged

twts_threshold_x = time threshold, this amount of time must have passed for the related action to be taken (hot/unplug)

Example:

One cpu is online.

(1 - 1) * 2 = 0 ergo:

nwns_threshold_0 = cpu1 will be hotplugged at this value

((1 - 1) * 2) + 1 = 1

nwns_threshold_1 = cpu0 will be unplugged at this value

This will regulate when we switch to lp-mode, effectively replacing the quadcore g-mode core with the ninja lp-mode core.

Two cpus are online.

(2 - 1) * 2 = 2 ergo:

nwns_threshold_2 = cpu2 will be hotplugged at this value

((2 - 1) * 2) + 1 = 3

nwns_threshold_3 = cpu1 will be unplugged at this value

etc...

(all times are in ms)

If you want to see the mpdecision magic happening:

adb shell
cat /proc/kmsg | grep 'MPDEC'

mpdecision's input event boost, aka project butter :p

This will boost your min cpu speed if you touch the screen or press a button and gives you full control.

In those events the min cpu freq will be risen to a predefined value (look below) on every online cpu. This boosts overall reaction times and smoothness a lot. (works similar to the qcom mpdecision binary)

Configuration files:

root@android:/sys/kernel/tegra_mpdecision/conf # ls

boost_enabled

boost_freqs

boost_time

All of them work like the usual sysfs files, except one special case:

boost_freqs will list all frequencies from cpu 0 to cpu x. Cpu 3 and any following cpu will share one frequency.

To change those frequencies echo the cpu number + the frequency in khz. To change the boost freq of cpu3 (and 4,5,6,7,8, etc) the echo would look as follows:

echo "3 1026000" > /sys/kernel/tegra_mpdecision/conf/boost_freqs

for cpu0:

echo "0 1026000" > /sys/kernel/tegra_mpdecision/conf/boost_freqs

Defaults:

cat /sys/kernel/tegra_mpdecision/conf/boost_freqs
910000
910000
760000
620000

Recommended governor?

Ondemand.
​

Why do I have no WLAN?

This kernel is too big for our boot.img with WLAN included into the kernel, so it is built as a module. That means it needs to be inserted into the kernel upon boot up, which needs to be automated for maximum comfort = userinit (init.d) support.

The zip adds init.d support to your ramdisk, if that fails for some reason the wlan module cannot be inserted.

if

adb shell lsmod

doesn't show this:

tun 14060 0 - Live 0x00000000
cifs 239646 0 - Live 0x00000000
bcmdhd 433083 0 - Live 0x00000000

Then init.d support is probably missing.

You can test it by going to /system/etc/init.d/ and executing 00wlan.

adb shell
su
. /system/etc/init.d/00wlan

Wait a few seconds and try to enable wifi and repeat the above lsmod command (should now show bcmdhd as live, you can execute 01cifs and 02tun too).

If WLAN now works, init.d support is missing.

You

need to have busybox installed

in order to be able to get init.d support going, this shouldn't be a problem for most people, since it is usually installed when rooting your phone anyway (and who does unlock but not root their phone? :/)

It does not matter if busybox is installed in /system/bin or /system/xbin, my script will detect the location upon flashing and patch the ramdisk accordingly.

If no busybox is found, the script will add init.d support to your ramdisk with the default location: /system/xbin/busybox. All you need to do is install busybox there and reboot your phone.

​