View Single Post
Posts: 167 | Thanked: 204 times | Joined on Jul 2010
#20
Originally Posted by vi_ View Post
What you could do is load your system to the max (play a movie with mplayer and force it to scale to video output or something), lock to each frequency you want to record then write down what smart reflex chooses as a voltage for each frequency. Thus you could use some relatively sane voltages and just guess for the ones outside the SR range (1000MHz etc). This would allow you to PERHAPS create a voltage under clock profile that is safe for your device that will go up to 1000MHz. Although I think it should be said it really can not recommended to push the processor so hard without adequate cooling.
I could, if there's any real advantage to be had by doing this, or I can take the view that the best case in most situations is to use SR, and that previous testing has shown that, when I'm not using SR (for which the only argument is overclocking, all caveats and disclaimers accepted), the "ideal" profile works in all situations but anything lower seems to cause problems. So, we're in agreement that most of the time, I want SmartReflex and do not want to overclock to the max.

What would be nice, though, and what I am driving at, is if I could have full speed for 20 seconds when I first unlock the phone, bring up the required application (e.g. my browser) and point it at a page (e.g. Facebook). This would not be planned to last more than a minute or two before reverting to sane defaults, and should involve fairly low overhead. The best way to describe what I am aiming at is probably with the current script:

Disclaimer: the following script is posted here for comment and discussion and should not be installed or used by anybody who doesn't know what they are doing. You have been warned!

maemo:~# cat /usr/local/bin/smartreflex
#!/bin/sh

case $1 in
"on")

# This is called when the system gets locked, or taken off charge.
# It should always set sane defaults.

echo "805000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo "500000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo "300000" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo "1" > /sys/power/sr_vdd1_autocomp
echo "1" > /sys/power/sr_vdd2_autocomp
# If we've been turned back on by relocking, then kill any waiting instance.
kill -9 `pgrep -f smartreflex.wait` >/dev/null 2>&1
;;

"off")

# This is called when the system gets unlocked. It temporarily disables SmartReflex,
# permits overclocking to 1100MHz, and reduces the sampling_rate so that the CPU speed
# will boost quickly as the user (for instance) loads a browser and selects a web page.

# It then enters a loop by running "smartreflex wait". This sleeps for 20 seconds, then
# tests whether we're still using a speed above 600MHz. If we are, then allow this to
# persist for up to two minutes / six iterations before reverting to the sane defaults.

echo "0" > /sys/power/sr_vdd1_autocomp
echo "0" > /sys/power/sr_vdd2_autocomp
echo "1100000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo "500000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo "150000" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
/usr/local/bin/smartreflex wait &
exit
;;

"wait")
# While SmartReflex is switched off...
let count=0;
while [ `cat /sys/power/sr_vdd1_autocomp` -ne 1 ]; do
# Wait twenty seconds for user to load whatever he unlocked the phone for
sleep 20;
# We can reenable SmartReflex provided that our current speed is not greater than 600MHz
# NB less than or equal to 600MHz, so we still re-enable SR if locked to 600MHz by a phone call
if [ `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` -le 600000 ]; then
/usr/local/bin/smartreflex on;
exit;
fi;
# Hmm, we're still using our overclocking it seems. Let's use a time limit as well.
let count=$count+1;
if [ "$count" -ge 6 ]; then
# After six iterations, we've been running for two minutes above 600MHz. SmartReflex it is.
/usr/local/bin/smartreflex on;
exit;
fi

done;

;;
esac

Whether it's desirable or not remains moot, but, my intention is that this should mean that when I unlock the phone, we enable an overclock to 1100Mhz on a hair trigger (but do not lock it). When we then fire up Opera Mobile and hit Facebook, we get full speed whilst we're swapping, displaying and messing about. This persists on an "if needed" basis for twenty seconds to two minutes, after which it is disabled to protect both battery life and CPU. Most of the time, it will downgrade after 20 seconds or less, giving me just enough clout to get to my desired application and then relax again. In terms of any overhead caused by the switching, it's pretty darn minimal:
maemo:~# cat test1.sh
let x=1; while [[ "$x" -le "1000" ]]; do smartreflex on; smartreflex off; let x=$x+1; done;

maemo:~# time sh test1.sh
real 0m 55.27s
user 0m 12.05s
sys 0m 30.03s

so, each cycle from SR to overclock and back again costs us approximately one twentieth of a second. Thoughts?
 

The Following User Says Thank You to magick777 For This Useful Post: