[Nexus S Android Development] Ezekeel:
We all know Morfic's popular TEUV kernel which features a low maximum frequency of just 880MHz, but still shows an excellent performance. The secret sauce is the increased bus speed of 220MHz compared to the stock frequency of 200MHz. The problem is that every Nexus S behaves differently because of production tolerances for the CPU and not all devices are able to handle this increased bus speed.

Thus it would be nice to have some way for the user to individually adjust the bus speed to match the overclocking capabilities of their device. Unfortunately with TEUV the bus speed has to be defined on compilation time thus the only way would be to release different versions with different bus speeds which, frankly, would be a pain in the ass. So I implemented a way to change the bus speed on-the-fly while the device is running. In contrast to TEUV not only the bus speed for the maximum frequency but for all states is increased by the same percentage (might change this later, especially for the minimum state).

In '/sys/class/misc/liveoc' change the performance by passing a value from 100 to 120 to 'oc_value' (100 = stock performance, 120 = +20% performance; 100 is default). The bus speed and frequencies for all states will be adjusted accordingly.

I am currently running my Nexus with an increased performance +10% using the stock frequencies 100->110, 200->220, 400->440, 800->880 and 1000->1100 and after increasing the voltage for the maximum state by 25mV 30mV everything is working fine without a reboot for 24h now. The battery drain however seems to be pretty high so it might be a good idea to leave the lowest frequency state untouched. Time and your feedback will tell. Seems like the sleep frequency fix also took care of the high battery drain.

Changes to the source: http://www.pastie.org/2634833

BUGFIX:

The sleep frequency is also adjusted according to the selected OC value, so a proper sleep frequency is chosen when the device is suspended.

Bug fix: http://www.pastie.org/2635644

BUGFIX #2:

When OC value is changed, the minimum and maximum frequency limits set by the user are adjusted according to the new frequencies.

Bugfix: http://www.pastie.org/2691219

BUGFIX #3:

Made sure the bus speeds and frequencies are not changed while a frequency change is currently ongoing.

Bugfix: http://www.pastie.org/2710098

BUGFIX #4:

Instead of a spin lock (which leads to problems) we use a mutex to make sure the bus and frequencies are not changed while a frequency change is ongoing.

Bugfix: http://www.pastie.org/2710386

BUGFIX #5:

If no mutex lock can be obtained, an error value is returned to inform the caller that the frequency was not changed.

Bugfix: http://www.pastie.org/2746226

BUGFIX #6:

1. Reverting back to mutex_lock to make sure no important request like enabling/disabling further frequency changes are skipped.

2. The mutex is unlocked before the CPUfreq stats are resetted. With the above modification this seems necessary to avoid lockups when changing the OC value.

3. The frequencies and bus speed are updated only when the selected OC value actually did change.

Bugfix: http://www.pastie.org/2756640

BUGFIX #7:

Maximum OC value increased to 150.

Bugfix: http://www.pastie.org/2768535

No further patches will be published here. I have set up a git repo for all my tweaks. Each mod has its own branch to keep the tweaks cleanly separated and one can simply pull the latest patches from the corresponding branch.

https://github.com/Ezekeel/GLaDOS-nexus-s/tree/liveoc

Thanks to Morfic for his help.