Quantcast
Channel: xda-developers - Android Software and Hacking General [Developers Only]
Viewing all articles
Browse latest Browse all 3614

Adreno idler, an idling algorithm for devfreq-based Adreno devices

$
0
0
I'm here to introduce 'Adreno idler' to the world, and for kernel developers out there, how to apply and test.

So what is Adreno idler?
Quote:

It is an idling algorithm,
an efficient workaround for msm-adreno-tz's overheads.

Main goal is to lower the power consumptions while maintaining high-performance.

Since msm-adreno-tz tends to *not* use the lowest frequency even on idle,
Adreno idler replaces msm-adreno-tz's algorithm when it comes to
calculating idle frequency(mostly by ondemand's method).

The higher frequencies are not touched with this algorithm, so high-demanding
games will (most likely) not suffer from worsened performance.
Why have I made it?
Because I don't like every, single, GPU governors out there for our Snapdragon devices.

Let me break it down for you.
msm-adreno-tz: default GPU governor for Snapdragon devices. It's interval/polling mechanism is very efficient, reducing the number of unnecessary frequency switches and maintains high performance. But, even on idle, it *tends* to not use the lowest frequency, resulting in higher power consumption and more battery drains on simple tasks such as watching video/YouTube or browsing the web.
Simple: a GPU governor made by faux123. I was using this on my older, non-devfreq-based devices but faux123's version of devfreq-based Simple GPU governor, it introduced a lot of weird switches and latencies resulting in a lot of lagginess and heat.
simple_ondemand: a devfreq governor made by Samsung, forked from ondemand cpufreq governor. It can be used as a GPU governor if your Snapdragon device uses devfreq governor for GPU frequency scaling. At idle, it goes all the way down to the lowest frequency, which is promising, but if it's under load, it continuously goes up and down, resulting in a similar behavior compared to Simple. Unnecessary number of switches, resulting in lagginess and heat.

So what's the answer?
None! Maybe the ideal solution is to modify msm-adreno-tz's algorithm to utilize the lowest frequency, but because msm-adreno-tz's algorithm is hidden under ARM's TrustZone technology, we can't tweak it much.
Hence, here comes Adreno idler.

Main goal is to lower the power consumptions while maintaining high-performance.

Adreno idler replaces msm-adreno-tz's algorithm when it comes to
calculating idle frequency(mostly by ondemand's method).
The higher frequencies are not touched with this algorithm, so high-demanding
games will (most likely) not suffer from worsened performance.


There are 3 main tunables for Adreno idler.
idleworkload for determining if the given workload is idle,
idlewait for preventing micro-lags,
and downdifferential for final calculation for determining if the GPU can go idle.

Logics are explained very well on the source-code. Go check if you're interested.

How to test and apply
Please go through the testing process.
If your device's stock msm-adreno-tz can go idle very well(it can differ from device to device since it's closed source), Adreno idler is not needed.
So far, it's working as advertised on Galaxy S4 LTE-A and Galaxy Note 3.

Use adb shell and type the following.
Code:

cd /sys/devices/*kgsl*/devfreq/*/
while true; do cat trans_stat; busybox sleep 0.1; done

If you can notice the msm-adreno-tz not using the lowest frequency even on idle, it's time to go try Adreno idler.
Your device MUST use devfreq msm-adreno-tz before applying Adreno idler.
AFAIK, Nexus 5 doesn't use devfreq, but more recent devices will use devfreq.
Go check if drivers/devfreq/governor_msm-adreno-tz.c exists.

I highly recommend to cherry-pick every devfreq/msm-adreno-tz changes on my Git repository to avoid inconsistencies which I did not intend.
Part of Adreno idler uses powersuspend by faux123.
Go apply it first before applying Adreno idler.

https://bitbucket.org/arter97/androi...bab2aeeba223b4
(powersuspend dependency. Just make sure to apply include/linux/powersuspend.h and kernel/power/powersuspend.c changes.)

https://bitbucket.org/arter97/androi...50aa8de45cb217
https://bitbucket.org/arter97/androi...e7fd35b1b268ad
https://bitbucket.org/arter97/androi...e217346b1aa346
https://bitbucket.org/arter97/androi...5274db21a7fd51
https://bitbucket.org/arter97/androi...50a25638955b45
https://bitbucket.org/arter97/androi...71bc1161efacbd
https://bitbucket.org/arter97/androi...9ded312c4ebe1c
https://bitbucket.org/arter97/androi...8224a012e43138
https://bitbucket.org/arter97/androi...15d0b82ec666e5
<-- The main party starts here !-->
https://bitbucket.org/arter97/androi...e9d680e3aaf60a
https://bitbucket.org/arter97/androi...b1ad684399290f
<-- More updates !-->
https://bitbucket.org/arter97/androi...623e07d78e1a8b
https://bitbucket.org/arter97/androi...2d58d4cb7991a6
https://bitbucket.org/arter97/androi...038b1fdaf6a941
https://bitbucket.org/arter97/androi...1463d94b612de3 (This is a must-have commit)
https://bitbucket.org/arter97/androi...c8a6164e3956c2
https://bitbucket.org/arter97/androi...1409e82bc0ba0d

That's it for Adreno idler 1.1.
I'll continuously update in the future.
Make sure to follow my Git and apply changes made to devfreq/msm-adreno-tz/adreno-idler.

After you've applied Adreno idler, turn it on from the defconfig and go through the testing process to check if the Adreno idler is working correctly.
It should ramp down the frequency to the lowest after about 200~500ms when system hits idle.

And you can turn Adreno idler on/off and fine-tune from /sys/module/adreno_idler/parameters.

Benchmark
Ahhhhhhh.. this will be interesting. And it is.

I've tested my ks01lte with watching a movie and playing a game.

1. 15 GB 1080p 2.5 hrs movie w/ HW decoder - Airplane mode ON/Brightness 25%
2. Casual game, leave it for 30 minutes on the same screen - Airplane mode ON/Brightness 100%

1.1. Adreno idler off - 46.3% battery drain, can expect approx. 6hrs 5mins of video playback on 100% battery charge.
1.2. Adreno idler on - 25.5% battery drain, can expect approx. 11hrs 2mins of video playback on 100% battery charge.
2.1. Adreno idler off - 13.4% battery drain, can expect approx, 3hrs 43mins of gameplay on 100% battery charge.
2.2. Adreno idler on - 11.7% battery drain, can expect approx, 4hrs 16mins of gameplay on 100% battery charge.

You decide if Adreno idler is awesome or not.
Enjoy :)

Huge thanks to hsk from Matcl for debugging, analyzing, and suggesting more efficient code.
This would be a piece of crap if it's not for hsk :D

Viewing all articles
Browse latest Browse all 3614

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>