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

Search This thread

arter97

Recognized Developer
Oct 14, 2012
3,890
34,674
26
Seoul
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?
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/andro...mits/adebe9f7080df129d4cd5128fdbab2aeeba223b4
(powersuspend dependency. Just make sure to apply include/linux/powersuspend.h and kernel/power/powersuspend.c changes.)

https://bitbucket.org/arter97/andro...mits/79945454ce9c82afa9288ebf8250aa8de45cb217
https://bitbucket.org/arter97/andro...mits/573933b0606872729161321042e7fd35b1b268ad
https://bitbucket.org/arter97/andro...mits/522e2814fa84b5404de8f246ebe217346b1aa346
https://bitbucket.org/arter97/andro...mits/04113ad70a03ce05eb8e52b8ca5274db21a7fd51
https://bitbucket.org/arter97/andro...mits/bc40eaf6c9e17e8f47cb52f20a50a25638955b45
https://bitbucket.org/arter97/andro...mits/c0a48acef7a34c30cd3edc03e971bc1161efacbd
https://bitbucket.org/arter97/andro...mits/8996dbf8714866d325ecaef5489ded312c4ebe1c
https://bitbucket.org/arter97/andro...mits/3bce70ca80c1a095d3c644c14e8224a012e43138
https://bitbucket.org/arter97/andro...mits/123d953787a9e31830956a740415d0b82ec666e5
<-- The main party starts here !-->
https://bitbucket.org/arter97/andro...mits/22d0b352f54a00029cfa18c368e9d680e3aaf60a
https://bitbucket.org/arter97/andro...mits/28c79e6018fd761245303feb51b1ad684399290f
<-- More updates !-->
https://bitbucket.org/arter97/andro...mits/6a001e2993138a7e44371632ab623e07d78e1a8b
https://bitbucket.org/arter97/andro...mits/b75554aa37be5dce5a83974d362d58d4cb7991a6
https://bitbucket.org/arter97/andro...mits/72b75f62452486c482dfd009ad038b1fdaf6a941
https://bitbucket.org/arter97/andro...mits/423c55f7ef34f73c0913a70f5d1463d94b612de3 (This is a must-have commit)
https://bitbucket.org/arter97/andro...mits/c9fd20d3185ca0594c0175a3d1c8a6164e3956c2
https://bitbucket.org/arter97/andro...mits/d66cd80d6ca422fc1398bb0c821409e82bc0ba0d

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
 
Last edited:

Kiryo24

Senior Member
Feb 21, 2014
239
52
@arter97
How much is your web browsing time approximately?

Sent from my GT-I9506 using XDA Free mobile app
 
Last edited:

freakingprime

Senior Member
Jul 2, 2012
274
44
If I don't use "Force 2D GPU Rendering", is this idler still effective? I almost do light usage: facebook, web browsing, no games.
 

MR.Samo

Senior Member
Jan 9, 2012
444
246
Arter just want to tel you that this is a big thing, am already testing and i think that iam seeing a difference in browsing battery life, anyway too early to tell...

We are so lucky to have a freaking genius developer for our note 3..
 

andip71

Recognized Developer
Apr 22, 2008
17,113
67,652
Potsdam
OnePlus 5
Google Pixel 7 Pro
Is it possible that this gives advantage only on the Samsung devices mentioned and not on the OnePlus?

Sent from my A0001
Oneplus msm-adreno-tz governor correctly scales down to minimum frequency when idle.

So at least the difference should not be expected to be very big.

So far the theory ☺

Andi
 

Top Liked Posts