yashsingh1/xdaforums huggingface dataset:
[Nexus S Android Development] franciscofranco:
Ok reverted that cpu_idle backport and now I get some stats, but no deep_idle:

idle state total (average)

===================================================

IDLE 74804ms (4ms)

DEEP IDLE (TOP=ON) 0ms (0ms)

DEEP IDLE (TOP=OFF) 0ms (0ms)

And yes it's enabled.
[Nexus S Android Development] FloHimself:
do you get a reboot if you open and close the cam app?
[Nexus S Android Development] franciscofranco:
Nah, never, and I use my camera quite a lot, and I already tested a lot of scenarios. Just tested everything again, both back and front camera, shuting down the screen while camera open, after closing camera, nothing at all, just perfect... but I can't get deep_idle either top=on or top=off to show some stats, both show at 0ms while IDLE 375715ms (5ms) for example.

EDIT: Ok now **** hit the fan, after all that closing and opening camera app and shuting screen off etc my device is ****ing slow and sluggish, this has never happened with me before. I'll re-add cpu_idle 3.1 backport and see if this issue happens again, which I doubt.

EDIT: I don't have this issue with the cpu_idle 3.1 backport. So either it's that cpu_idle code from .35 that is ****ed up or it's the camera app code. I only got the sluggish issue after using the front camera and taking a photo with it.
[Nexus S Android Development] FloHimself:
Ok, I managed to compile this stock kernel, with deep idle as the only modification and it gives me the very same behavior as the CM based kernel.

My guess: none of the > 2.3.3 kernels out here have a working implementation of deep idle.
[Nexus S Android Development] morfic:
Deep idle works, but with the reboot issue.

You beat me to starting a clean tree like that. With just oc added and then deep idle up to bug fix #10 I can very reliably reboot the phone after camera use.

I think I will still create the stock tree, so I can test for reboots more easily.

So if this works for Ezekeel on 2.3.3, we forward port from 2.3.3 or backport from 3.x?

tempted to say reverting minimum needed to make Deep idle work.
[Nexus S Android Development] comradesven:
I'm just throwing this into the mix but I'm wondering if you or anybody has some ideas about why the deep idle code here doesn't appear to work on a Samsung Galaxy S.

Here's an example cpuidle.c on a stock Samsung-released source tree. It's not my sources (I'm using the implementation from imoseyon's tree here with the patches from this thread he didn't put in yet) but it already has some didle code in it and CONFIG_CPU_DIDLE is exposed in Kconfig. In the stock defconfig it's disabled by default but the kernel builds with it enabled. However after applying the patches here and looking at the sysfs stats the phone never leaves idle for didle.

Perhaps someone knows what the deal is with CONFIG_S5P_INTERNAL_DMA and CONFIG_S5P_RP as well. After patching the first is mentioned in the resulting cpuidle.c and there's some code that is ifdef'd to run if both it and CONFIG_CPU_DIDLE are selected. The second depends on the first not being selected. I've been toggling didle, dma, and rp in my .config and nothing works.

I'll do some more investigation when I get a chance and report back but hopefully it's something pretty simple. Might be that Samsung's didle code is sufficient and thanks to your patches I can probably implement a sysfs stats thing now.
[Nexus S Android Development] FloHimself:
You could at first verify if check_power_clock_gating() prevents the CPU from entering deep idle by adding some debug output to it:

135 /* check power gating */
136 val = __raw_readl(S5P_NORMAL_CFG);
137
138 printk(KERN_INFO "%s: S5PV210_PD_LCD=%u, S5PV210_PD_CAM=%u, S5PV210_PD_TV=%u, S5PV210_PD_MFC=%u, S5PV210_PD_G3D=%u\n",
139 __func__,
140 !!(val & S5PV210_PD_LCD),
141 !!(val & S5PV210_PD_CAM),
142 !!(val & S5PV210_PD_TV),
143 !!(val & S5PV210_PD_MFC),
144 !!(val & S5PV210_PD_G3D));
145
146 if (val & (S5PV210_PD_LCD | S5PV210_PD_CAM | S5PV210_PD_TV
147 | S5PV210_PD_MFC | S5PV210_PD_G3D))
148 return 1;

This should print kernel messages like:

<6>check_power_clock_gating: S5PV210_PD_LCD=0, S5PV210_PD_CAM=1, S5PV210_PD_TV=0, S5PV210_PD_MFC=0, S5PV210_PD_G3D=0

In this example the camera is preventing the device from entering deep idle...
[Nexus S Android Development] Ezekeel:
I am on the go right now and cannot do much, but one thing you could try is put that code regarding the APPL lock I removed in bugfix #6 back in. In my opinion I should be not necessary, but maybe I am wrong. Also, did someone try Netatchys latest kernel and put DEEP IDLE in - maybe the answer lies somewhere in some mod he put in.

When I am at home I will backup all stuff from my device (Nandroid backups everything not on the sdcard, right?) and test out your kernels with the latest CM7.1 (I do not need to wipe data on update from CM7.03, right?). If I also get reboots I will get a copy of netarchys latest kernel and put DEEP IDLE in. If that reboots too I will update my reference kernel one by one with Netatchys patches and see when the problems start (Does 2.3.4 already run with CM7.1?).
[Nexus S Android Development] steve.garon:
I'm curious about that camera bug that everyone is talking about. I've been using the camera a lot and haven't had reboots for the past week and a half.

Is there step by step to make it crash? I'll test if my kernel suffers from that.
[Nexus S Android Development] brenix:
Same here.. No issues of lag/reboots and I was using it a bunch on Halloween..
[Nexus S Android Development] Ezekeel:
If you think everything is working, post your idle_stats. Also provide info about the hardware model, kernel, ROM, governor and governor parameters.
[Nexus S Android Development] brenix:
Ok, here are some tests I ran... Maybe this could be of use..

FYI, I'm working off franciscofranco's kernel sources with these tests.

Test 1 (No modifications): idle_stats did not show anything for IDLE neither TOP=ON/OFF. No issues with lag etc..

Test 2 (Reverted cpuidle backport from 3.1): idle_stats reports TOP=OFF time. Here is the output:

idle state total (average)

==========================

IDLE 363854ms (1ms)

DEEP IDLE (TOP=ON) 0ms (0ms)

DEEP IDLE (TOP=OFF) 51176ms (165ms)

However, about 20-25 seconds after the screen turned off, idle_stats was not being updated anymore and the screen would not wake properly..Although adb shell was still responsive...

Test 3 (Added the APPL lock code back into cpuidle.c): Same issues as in the second test..

Running with a min/max freq of 1000/1100 using Lazy... I also tried a different governor but same results..
[Nexus S Android Development] Ezekeel:
I updated to CM7.1 and Netarchy 2.3.5 and after a lot of testing found the problem.

Notifications using 'pm_notifier_call_chain' when entering/leaving DEEP IDLE have been removed.

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

Test kernel: http://www.multiupload.com/K8ZXS5HTLS
[Nexus S Android Development] franciscofranco:
Why exactly was that causing problems?
[Nexus S Android Development] Ezekeel:
Entering/leaving DEEP IDLE happens much more frequently than entering/leaving SLEEP. Maybe the problem was the additional overhead, maybe (probably) it did more than just modify the behavior for CPUfreq but also for some other kernel modules. It did solve all the problems on the Netarchy 2.3.5 kernel for me (try the test kernel if you like), so until some further problems arise I will not mess with that again.
[Nexus S Android Development] brenix:
Just tried it here and working good... good find!
[Nexus S Android Development] franciscofranco:
I'm gonna test it just now. I'm glad we all could help you out with information, and very nice find ;)
[Nexus S Android Development] franciscofranco:
idle state total (average)

===================================================

IDLE 710478ms (6ms)

DEEP IDLE (TOP=ON) 0ms (0ms)

DEEP IDLE (TOP=OFF) 621813ms (6ms)

Now that works fine. Tried camera app, no issues, listened to 10m of music, not even a 1% drop, tried other apps, tried wifi. Everything works fine and thats the stats. Based on those stats is that the behavior you were looking for?
[Nexus S Android Development] FloHimself:
Here it works, too! Nice work Ezekeel. The only problem remain for me is that my stock ROM enables the cam at boot. But that's not a deep idle problem...

Update: Just by typing this message, my device freezed... :(

Update: But it hasn't freezed because of deep idle... it's working! :)
[Nexus S Android Development] Lazat:
I'm to stupid to use the sysfs to call the deep idle stats, any hints how to write in terminal or adb to show the stats? Tried cat idle_stats but that didn't work xD
[Nexus S Android Development] Ezekeel:
That looks fine to me.

I guess you tried mp3 playback. MortPlayer gives me about 10ms average residency for mp3 and 20ms for FLACs. You might want to try using another music player which gives you less wakeups for even better battery life. But with idle_stats and reset_stats people can investigate that on their own.

cat /sys/class/misc/deepidle/idle_stats
[Nexus S Android Development] FloHimself:
Ezekeel, my kernel still freezes... is your current netarchy tree published yet? are the BLD fixes for i9023 are included in the last test kernel?
[Nexus S Android Development] Ezekeel:
I simply took Netarchy's 2.3.5 BFS kernel from his git, put in the latest patches for DEEP IDLE and added lazy. You have to take a look at his git and changelog for details.

I have not decided yet how to proceed from here. Netarchy's kernel is missing some of my tweaks like Touch Wake, BLX and LiveOC so I would have to put these in to use it as a daily driver and as my new reference kernel. Problem is, he seems pretty busy nowadays and updates are not often. I could fork the stock kernel and essentially make my own kernel, but then I would have to add all that stuff Netarchy and others already have to make it an efficient daily driver. Also, ICS is around the corner and there probably will be a lot of changes, so everything I start now will be wasted work by then. I am actually tempted to go back to CM7.03 and 2.3.3 once the kinks in DEEP IDLE are worked out and wait for the ICS kernel to be released.
[Nexus S Android Development] steve.garon:
So ... It turns out that my idle_stats stay at 0ms for all of them. Looks like that the 3.1 backport of cpuidle that I pulled from someone ( I think franscicofranco ) prevent deepidle from working.

The + side is that my kernel does not crash on idle and that the battery life is still great. Although, battery life might be better on deep idle...

Now the dilemma, what should I take off, deepidle or 3.1 cpuidle??

Ezekeel, have you had a look at that 3.1 backport of cpuidle? (link to my commit) Your input on this would really be appreciated.
[Nexus S Android Development] brenix:
The latest deep idle patch resolved the issues with the 3.1 cpuidle backport... at least in my case..

I also see the idle_stats now
[Nexus S Android Development] sTiCkY88:
meh if only there's a fix for radio using half of my battery..
[Nexus S Android Development] Ezekeel:
Updated the initial post with source code.

No... except of course you work for Google or Samsung and can get me a free Nexus Prime since otherwise I will not get one. My Nexus S is just about 4 month old and I cannot sell it, because then I would not be able to provide support/bugfixes for my tweaks anymore. And if I buy a second phone for this price my girlfriend would kill me. :D

Do you know, what the problem was? I only heard something about wakeup problems from sleep.
[Nexus S Android Development] brenix:
Hmm..I've just tried implementing this and have ran into this same issue..The phone boots and interacts fine until the screen turns off for a few seconds. When you try to turn it back on, it doesn't wake up...

Great work on this though.. Very exciting!
[Nexus S Android Development] morfic:
This is still our biggest sinner.
[Nexus S Android Development] morfic:
It attempts to IDLE even under load.

It is apparent in just about everything, from scrolling in the launcher, opening apps to the obvious benchmarks.

EDIT: It seems to affect the GPU most. Running a benchmark, CPU scores are almost normal, but 3D ends up being 1/4th of before.
[Nexus S Android Development] intheb0x:
even on this kernel of yours?

T144-NS-11102011 (1.44GHz with 240MHz bus/gpu)

are you saying its slow and sluggish?
[Nexus S Android Development] morfic:
slow and sluggish is almost not strong enough a language to describe it, it certainly tries to idle the gpu when it should be using it.

the screen off animation is slow motion.

Testing it in TEUV right now, since there are a few differences in code i hoped it would be all my fault, no acts same AFTER the first time phone was slept with power button.

TEUV and T144 both felt ok after boot, until screen went off, going to see if i can collect something useful.
[Nexus S Android Development] intheb0x:
im currently running the TEUV version and wow it is sloww,

but i see why, i wonder if it can be tweaked some way, because the battery savings from this could be huge.

using your kernel for the first time today TEUV-NS-05102011 (0.88GHz with 220MHz bus/gpu,ExtraUnderVolted) i got a couple extra hours out of battery, it was great. im hoping once it :sets in: it will be even better, but ill continue to play.

if you need any more observations from me for this deep idle kernel, let me know, i may be switching back

my phone seems to be running hotter with this mod.
[Nexus S Android Development] morfic:
i switched sim from g2x to NS, there is no data, correct.

wifi comes on normal and i can get online

airplane mode hangs, so no radio kickstart possible

logs tomorrow, i'm falling asleep over here
[Nexus S Android Development] intheb0x:
so far everything is working normal here, wifi, and 3g..

will post more as i go along.

nexus s 4g with sprint here.
[Nexus S Android Development] Ezekeel:
I am having no trouble with the mobile data connection. Also I have not experienced any change in the responsiveness of the UI. I use BFS, maybe that is the difference.
[Nexus S Android Development] FloHimself:
@Ezekeel: very nice work!

@KalimochoAz: any chance to get a CM nightly with this build in?
[Nexus S Android Development] KalimochoAz:
I have tested this some time ago, and it was inestable. I hope Ezekeel implementation is stable so I can add it, as I have added some other of his codes.

Talking about who started this, I have no idea. I took some time ago from Samsung galaxy, but I really now this is not coded by them. I think is an internal implementation from Samsung, but I'm not at all sure.

What I have found in the past is that it has some problems on wake up, for example on some cases that you receive a call, it start to fail all the threads, but that was my code, that can be buggy. So lets Ezekeel work on this and meanwhile I will try to test his code and see if I can also help on it, if is needed

Kalim
[Nexus S Android Development] FloHimself:
I'd like to test the current implementation. Can you point me to the current kernel source of the CM nightlys (CM github isn't the latest?) and provide a current kernel config?
[Nexus S Android Development] KalimochoAz:
No, I had a lot to do before release, so I have deprecated the code for the future. I have seen that at wake up, not with power turn on but with alarms, calls... sometimes system hangs. Since I nedded more loggin in kernel to check what happends.

Now I will habe more time to check it again, so I will try to keep you informed of what I see. I agree this trick saves a lot of battery.
[Nexus S Android Development] KalimochoAz:
No, is not updated. I'm finishing some cleaning at the code and I will merge all during this week. On the other hand if you want to test it

http://bit.ly/DeepIdleV2_4 ( CM Kernel with Ezekeel modif. )

http://bit.ly/Release71 ( CM kernel from Release 7.1 )

but this is just for test, is not official at all. ( in my phone this implementation and my own implementation of this trick is BUGGY )

All you test it, feel free to post here logs in order to help on:

adb shell logcat

adb shell klogtail

Kalim
[Nexus S Android Development] FloHimself:
Sure it would be nice to compile this from source, but for testing the binary blob is really enough. Thank you!
[Nexus S Android Development] qubz:
Thanks KalimochoAz, just flash the .zip?
[Nexus S Android Development] KalimochoAz:
yes, go to recovery an flash it.
[Nexus S Android Development] from1989:
how to use this mod in miui?zip?where?
[Nexus S Android Development] steve.garon:
Interesting.. so you still have the cpuidle backport patch and you get idle_stats?
[Nexus S Android Development] waterface:
Hey franco. According to my idle_stats, deep idle on my Nexus S i9023 with NSCollab and 2 Nov. kernel is not used. From the CPU load data, no app seems to be interfering. Could you tell me real quick how I can check and see what is preventing the phone from entering deep idle?
[Nexus S Android Development] yaachi:
is usb cable disconnected?
[Nexus S Android Development] belvedere:
open/close camera app. had the same thing and that's what fixed it for me.
[Nexus S Android Development] FloHimself:
Notice to myself: If I use the correct toolchain and the correct config options, I can build a kernel that's not freezing when entering deep idle state.
[Nexus S Android Development] MultiCulti:
here are my settings with the newest franco kernel ....everything running very smooth and no reboots or something ...

as you can see, also deepidle is working how its supposed ;)
[Nexus S Android Development] Ezekeel:
Great. Good to see that it also works on the i9023 without modifications.
[Nexus S Android Development] waterface:
Thank you, member with an Italian nickname!!! Deep idle seems to be in use now.
[Nexus S Android Development] franciscofranco:
Ezekeel any idea about that camera on/off trick to make deep idle to kick in like some users reported?
[Nexus S Android Development] waterface:
Thank you for your releases franco and ezekeel. And sorry about too many direct questions, I know you are no customer service people. Let me know if I can help with anything, like running tests or something. I accept assignments!

I have a NS i9023 as already mentioned.

Thanks again.
[Nexus S Android Development] morfic:
Thanks for the fix Ezekeel, working a treat now.
[Nexus S Android Development] Ezekeel:
No idea what causes this except that it is probably something with the ROM or an app. I do not have the problem, so I cannot look into it.

Great, glad to hear that.

So what are the average times you guys get for DEEP IDLE while playing mp3? It seems to sit around 7ms for me no matter the music player I use. On the other hand FLAC playback is around 17ms with stock, Mort and WinAmp music player, while PowerAmp has more wakeups with average times around 7ms. I would be interesting to see if one can reduce the number of wakeups by playing with the kernel config options and maybe different schedulers.

Also as I mentioned, I am searching for a new reference kernel. It should be as stable as possible, as close to stock as possible, updated regularly (especially to ICS once that arrives) so that I can simply apply the same updates to my fork and it should be efficient enough so I can use it as my daily driver. The best solution seems to be to fork directly from the official stock kernel, but that is a lot of work I guess. Any suggestions or comments?
[Nexus S Android Development] morfic:
why not grab the latest tarball, add in your patches, grab franco's or my .config and with your live oc, all you lack is the hard core fighting of debugging that is really the difference between say a cm kernel and what makes franco's or mine not suck balls.

you could dedicate a few hours at work and have a nice, clean reference kernel, of which you know all the ins and outs of.

no random patch interaction, easy to keep up to date, lean mean fun.
[Nexus S Android Development] caleb1783:
could it be device related?

i am using i9023 as well.

deep idle did not start until i opened/closed camera app.

checked deep idle status via

su

cat /sys/class/misc/deepidle/idle_stats
[Nexus S Android Development] morfic:
DEEP IDLE (TOP=OFF) 126159ms (7ms)

playing flac in poweramp
[Nexus S Android Development] from1989:
idle state total (average)

===================================================

IDLE 3006241ms (3ms)

DEEP IDLE (TOP=ON) 0ms (0ms)

DEEP IDLE (TOP=OFF) 6662479ms (7ms)
[Nexus S Android Development] polobunny:
Hey Ezeekeel, somewhat new to deep idle (I was waiting for a more mature state :P) and I'm wondering what the outputs of idle_stats mean. I can see there's the numbers of ms the phone stays in each state, but what is TOP=ON/OFF and what are the ms in parenthesis?

Thanks for the great mods so far. :)

Edit: Caleb, no need to su for cat. Saves you 3 keystrokes!
[Nexus S Android Development] Ezekeel:
Seems the stock kernel will be migrated to android.googlesource.com but is not yet available. I will wait until I can fork from them.
[Nexus S Android Development] polobunny:
mp3 with Winamp

idle state total (average)

===================================================

IDLE 1549455ms (10ms)

DEEP IDLE (TOP=ON) 0ms (0ms)

DEEP IDLE (TOP=OFF) 9179ms (7ms)

Just as you said.
[Nexus S Android Development] got2best:
I am wondering if it is working for me as well.. I don't get anything from ON.. and I am not ssure what they mean.

sent from my Nexus S i9023 from XDA premium
[Nexus S Android Development] polobunny:
Working. I believe TOP=ON is when screen is on, and deep idle isn't supposed when screen is on. Still awaiting confirmation from Ezeekeel though, I am wondering myself about the exact meaning of these. :)
[Nexus S Android Development] from1989:
look at this it works good for me??

idle state total (average)

===================================================

IDLE 99283ms (3ms)

DEEP IDLE (TOP=ON) 0ms (0ms)

DEEP IDLE (TOP=OFF) 216344ms (119ms)
[Nexus S Android Development] belvedere:
from my understanding, TOP=ON is when GPS is running or Bluetooth/USB are being used.

TOP=OFF I guess is any other instance.

so if you aren't using one of those 3 things, it'll be 0 and time will be allotted only under TOP=OFF.

I haven't used GPS, Bluetooth or USB.... http://dl.dropbox.com/u/4686846/screenshot-1320285210025.png
[Nexus S Android Development] polobunny:
I believe you are right my friend. :)

Using maps for a split second
[Nexus S Android Development] Ezekeel:
I get 17ms for FLACs with stock player, MortPlayer and WinAmp. Maybe worth considering a change.

With TOP=ON parts of the chip are not powered down and this state is used when BT or GPS is activated. When the screen is on or when connected to USB only the normal IDLE state is used.
[Nexus S Android Development] Maximilian Mary:
I think you should put this in the feature list in your OP. :p
[Nexus S Android Development] MultiCulti:
hmmm ... is ~50mA normal for Deepidle? ... from 1 am to 6 am it dropped 11% ... i didn't touch the phone
[Nexus S Android Development] from1989:
about the vibration dont works normally in deepidle right?

edit :my rom is miui .and my screen setted not turn on when messages comes~
[Nexus S Android Development] MultiCulti:
did´nt recognize ... so, it´s working normal here
[Nexus S Android Development] FloHimself:
It seems to be rom related. I've seen this behavior on stock GRK39F rom, but not on CM 7.0.3 or CM 7.1.0, with the same apps installed.
[Nexus S Android Development] waterface:
7ms after almost 10 minutes (559077ms) of mp3 playback with the Music app v4.0.1.501, comes with the NSCollab ROM. Battery stats say phone was using 99mA for the first 5 minutes, then 150mA. I'm still confused with these apparently high battery drains (I never go lower than 35-40, even on airplane mode).
[Nexus S Android Development] caleb1783:
hmmm. i m using cm based rom.. stable version as well...

deep idle works but i get average -50ma as well

Sent from Divinus Nexus S...
[Nexus S Android Development] MultiCulti:
is this now good or bad?