[Kernel][GPL] msm_hsic_host wakelock fix (Now with WiFi notification fix!)

Search This thread

chrone

Senior Member
May 5, 2012
1,050
369
Surabaya
quick impression on one day mild usage of n4 4.2.2 battery life from 100% to 1% (6.6%/hr) on stock kernel:
  • battery life 14.9 hours
  • screen time 2.5 hours
  • 3G most of the time, sometimes WiFi and 2G
  • autosync on
  • msm_hsic_host 1256 wakelocks, 10% ~ 2 hours wakelock

update:
uploaded bbs log and some screenshots.
 

Attachments

  • BetterBatteryStats-2013-02-15_200735298-mako422.txt
    17.7 KB · Views: 5
  • bbs-kernelwakelock-mako422.jpg
    bbs-kernelwakelock-mako422.jpg
    36.1 KB · Views: 1,365
  • bbs-other-mako422.jpg
    bbs-other-mako422.jpg
    32.1 KB · Views: 1,360
  • bbs-cpustates-mako422.jpg
    bbs-cpustates-mako422.jpg
    29.9 KB · Views: 1,355
Last edited:

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Thracemerin, does your experimental build from the 14th contain color adjustment, like your other kernels? :eek:

Not at the moment, it's just Google sources in v1, I will be looking at adding other stuff, I just wanted to make sure the new sources were solid before installing anything into them that may cause unforseen issues.

Just a quick question, boss. Isn't the stock kernel simply AOSP + proprietary drivers? So, what would be the difference? Or, is it simply a matter of who compiled the source, whether it be Google (stock OTA) or by the tools floating about in dev community land?

Yeah, the stock AOSP stock kernel and the OTA kernel should be the same other than who compiled it, since I'm using the Google toolchain as well there should be no difference. Digging around in the new sources I noticed that Google didn't push all the changes I made in my previous 4.2.1 versions, so I wanted to see if there was some other change that they made to fix the wake locks before I went ahead and added in the patches again.
 

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Ok, New version:

Back in Post 2

I re-added some of the HSIC patches from the 4.2.1 version and this may or may not have re-introduced the 3G data drop/lock up issue, I want to see if it did or not before I continue.

I would like people to run the version from the 14th first (for a full day and post the logs I asked for before) to get a baseline on the wake lock before trying the 15th version.

If you get a data drop, lock up or any other unusual behavior on the 15th version, please let me know. Logcats, last_kmsg, etc would be helpful as well if you can.
 
Last edited:
  • Like
Reactions: chrone

sotong

Senior Member
Sep 9, 2008
104
18
Hi,

I have not been able to test V1 on wakelocks as my usage pattern the past day was for heavy gaming. However, i do notice that the wi-fi data dropouts i used to have (delayed notifications) have gone. I still noticed it using the stock 4.2.2 kernel, so i find this very odd. I will try re-flashing the stock kernel and giving it another go. I noticed this delayed notification also with other custom kernels based on 4.2.2.
 
  • Like
Reactions: chrone

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Hi,

I have not been able to test V1 on wakelocks as my usage pattern the past day was for heavy gaming. However, i do notice that the wi-fi data dropouts i used to have (delayed notifications) have gone. I still noticed it using the stock 4.2.2 kernel, so i find this very odd. I will try re-flashing the stock kernel and giving it another go. I noticed this delayed notification also with other custom kernels based on 4.2.2.

So the delayed notification is gone? That's a good sign. I only ever had it intermittently on the 4.2.1 kernel, so it may just be random good luck that you don't have it anymore and it may pop up again, I don't see anywhere that Google fixed this, but it could have been hidden in something else.
 
  • Like
Reactions: chrone

sotong

Senior Member
Sep 9, 2008
104
18
So the delayed notification is gone? That's a good sign. I only ever had it intermittently on the 4.2.1 kernel, so it may just be random good luck that you don't have it anymore and it may pop up again, I don't see anywhere that Google fixed this, but it could have been hidden in something else.

That is correct. I just did further testing again:

1. Flash back to stock 4.2.2 kernel. Wait 5 mins. Sent gmail to my phone. Notification did not come in until i turn the screen on.
2. Flash to your V1 kernel. Wait 5 mins. Sent gmail again, and i got the notification almost immediately.

I am also puzzled as to why this is happening. But i am not complaining! Will test your V2 now. Thanks for your efforts
 
  • Like
Reactions: chrone

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
That is correct. I just did further testing again:

1. Flash back to stock 4.2.2 kernel. Wait 5 mins. Sent gmail to my phone. Notification did not come in until i turn the screen on.
2. Flash to your V1 kernel. Wait 5 mins. Sent gmail again, and i got the notification almost immediately.

I am also puzzled as to why this is happening. But i am not complaining! Will test your V2 now. Thanks for your efforts

Interesting...as far as I know V1 should be exactly identical to stock, so I can't explain why that would be, but I guess it's a happy side effect.
 
  • Like
Reactions: chrone

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Hi, just a quick update again. V2 seems to also have delayed notifications. Went back to V1, same test, and no delay.

I can't explain that, V1 and Stock are identical, V2 has nothing related to WiFi changed. So unless it's random coincidence that you aren't having problems with V1, I'm not sure what else it could be, I'll look into it further.

Edit: I tried hard to reproduce this on my local version with is essentially V2 and I can't, so either it's something I added in V2 and changed back in the local version (not likely) or it's something to do with your setup.
 
Last edited:

sotong

Senior Member
Sep 9, 2008
104
18
I can't explain that, V1 and Stock are identical, V2 has nothing related to WiFi changed. So unless it's random coincidence that you aren't having problems with V1, I'm not sure what else it could be, I'll look into it further.

Edit: I tried hard to reproduce this on my local version with is essentially V2 and I can't, so either it's something I added in V2 and changed back in the local version (not likely) or it's something to do with your setup.

I agree with you, it must be my set up because it does not make sense also. Could be a random coincidence. Is there a quicker way to test this (i read about pinging etc) instead of waiting several minutes when the phone is in standby?

Edit: You are correct. Just sent a gmail to my phone (on V1) and nothing came in :( There goes my short-lived joy! Or gmail is having issues also.
 
Last edited:

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
I agree with you, it must be my set up because it does not make sense also. Could be a random coincidence. Is there a quicker way to test this (i read about pinging etc) instead of waiting several minutes when the phone is in standby?

Edit: You are correct. Just sent a gmail to my phone (on V1) and nothing came in :( There goes my short-lived joy! Or gmail is having issues also.

I guess that they more or less confirmed in this thread: http://xdaforums.com/showthread.php?t=2072930 that Google did not fix the WiFi notification issue, so I don't think it's you, blame Google.
 

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
New build in post 2 (see there for changelog)

I added a couple more CAF patches and used the data fix that Faux123 used in his enhanced stock kernel instead of the one I used previously, I want to see what happens with this as it relates to the wakelock and data use to see how it goes, if it doesn't work I'll install my previous solution.

Happy Flashing.
 
  • Like
Reactions: io53 and chrone

chrone

Senior Member
May 5, 2012
1,050
369
Surabaya
New build in post 2 (see there for changelog)

I added a couple more CAF patches and used the data fix that Faux123 used in his enhanced stock kernel instead of the one I used previously, I want to see what happens with this as it relates to the wakelock and data use to see how it goes, if it doesn't work I'll install my previous solution.

Happy Flashing.

i'm testing your v3 right now, will post the log tomorrow now after full day use.
no need to test v1 since it's the same as stock and i've posted the bbs log above, right?
 

floepie

Senior Member
Feb 28, 2006
1,990
455
Amsterdam
That is correct. I just did further testing again:

1. Flash back to stock 4.2.2 kernel. Wait 5 mins. Sent gmail to my phone. Notification did not come in until i turn the screen on.
2. Flash to your V1 kernel. Wait 5 mins. Sent gmail again, and i got the notification almost immediately.

I am also puzzled as to why this is happening. But i am not complaining! Will test your V2 now. Thanks for your efforts

Sending yourself a gmail turns out to be a very poor test. Invariably, if I send myself an email, notification delays are very random, and this has been confirmed by others on this board. However, getting emails from 3rd parties is much more reliable for delay testing. It may have something to do with "loopback" settings on the router. In any case, if you have a router which flushes its ARP cache every couple minutes, you will get delays (up to 15 minutes) because Google hasn't updated the wifi driver to offload ARP broadcast requests. They decided battery life was more important, so they chose to drop requests entirely when the screen is off.

Fortunately, if you have a dd-wrt router, you can set a static IP address from the router to get around this issue.
 
Last edited:
  • Like
Reactions: chrone

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Sending yourself a gmail turns out to be a very poor test. Invariably, if I send myself an email, notification delays are very random, and this has been confirmed by others on this board. However, getting emails from 3rd parties is much more reliable for delay testing. It may have something to do with "loopback" settings on the router.

True, but the WiFi issue is definitely not fixed, I tested it using the ping method. If I used a PC that hadn't previously connected to the phone while the screen was off, the pings timed out, as soon as I turned the screen on they'd work until the ARP timed out, then it would go back to time out.
 
Last edited:
  • Like
Reactions: chrone

jakejm79

Senior Member
Jan 29, 2010
1,053
152
Theracemerin, having upgraded to 4.2.2 (CM10.1 2/16) and using you v3 fix, my wakelock performance isn't as good (about 30 mins over 10 hours of sleep with wifi on) when compared to the older v2 (for 4.2.1 built 2/4) version I was using before. Hopefully you can add the rest of your fixes you had for the 4.2.1 kernel to the 4.2.2 kernel.
 
  • Like
Reactions: chrone

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Theracemerin, having upgraded to 4.2.2 (CM10.1 2/16) and using you v3 fix, my wakelock performance isn't as good (about 30 mins over 10 hours of sleep with wifi on) when compared to the older v2 (for 4.2.1 built 2/4) version I was using before. Hopefully you can add the rest of your fixes you had for the 4.2.1 kernel to the 4.2.2 kernel.

You're absolutely right, it's not. Faux123s solution to the data problem was to decrease the USB bus suspend time by 20% from the original, my solution from 4.2.1 was to use the CAF patch that set it to 0 as soon as the data stopped, this caused a problem if the data stream stopped momentarily it would get permanently stuck. I added a few additional patches to make sure that this wouldn't happen if it were just a momentary stop in the stream, so Faux123s solution reduces the wakelock time, but not to the same degree as mine, his patch is safer from a data drop standpoint though.

Edit: The new HEAD in my git has all my old patches from 4.2.1, I'm running a few tests on it to make sure we're good to go before pushing a test release.
 
Last edited:

jakejm79

Senior Member
Jan 29, 2010
1,053
152
OK, that makes sense, I never really suffered from the data drop issue, maybe we could get a little more aggressive than just 20% (assuming you are saying it was reduced by 20% i.e. from 10 to 8 and not reduced to 20% i.e. from 10 to 2)

EDIT: OK sounds good, I will sit patiently.
 
  • Like
Reactions: chrone

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
OK, that makes sense, I never really suffered from the data drop issue, maybe we could get a little more aggressive than just 20% (assuming you are saying it was reduced by 20% i.e. from 10 to 8 and not reduced to 20% i.e. from 10 to 2)

Yeah, 20% from original (ie 200->160).

See here: https://github.com/thracemerin/Mako/commit/e5b918aa41059e05ee3851fd117d20dd761e8526

I know it looks like I raised it from 0 to 160, but there was a previous patch that set it to 0 from 200 here: https://github.com/thracemerin/Mako/commit/56d96a8b55adc6ed005f35f06ef705ea8c812c3c
 
Last edited:
  • Like
Reactions: chrone

Top Liked Posts

  • There are no posts matching your filters.
  • 66
    Hi Folks

    I have been trying to solve the msm_hsic_host wake lock problem without introducing the data drop/lockup issues that have been introduced into other kernels by adding the patches from code aurora.

    Disclaimer: The usual statements apply, I'm not responsible for your device being bricked, ebola outbreaks, nuclear war, etc... resulting from the use of this kernel, flashing this kernel should be done at your own risk, that being said I have been running various variations of this for the last few days without my phone having any issues.

    All Versions now in post 2 below.

    What's in this release?
    4.2.1 versions: Simply the CM stock kernel pulled from their github here: https://github.com/CyanogenMod/lge-kernel-mako with patches from CAF that I cherry-picked in an attempt to fix the msm_hsic_host wake locks without causing 3G data problems.
    4.2.2 versions: Stock AOSP pulled from the android-msm-mako-3.4-jb-mr1.1 repo at https://android.googlesource.com/kernel/msm/ with patches from CAF that I cherry-picked in an attempt to fix the msm_hsic_host wake locks without causing 3G data drops.

    What do I do if I get a data drop?
    Post here, be as detailed as possible, logs would be extremely helpful so I can see what's going on with your device, because these data drops seem to be somewhat random and don't affect everyone it's very difficult to actually reproduce them on another device on another network, as a result the more information you can give me the better.

    My WiFi drops while the screen off resulting in delayed notifications!
    To be clear, this is not the same issue, the issue with WiFi disconnecting while the screen off seems to be an Android 4.2.1 issue and exists on all kernels and even different devices running Android 4.2.1, this kernel doesn't do anything to address this issue, whether it fixes it or doesn't is entirely independent of the kernel. A potential fix for this is available from this thread: http://xdaforums.com/showthread.php?t=2072930 Note: It would appear that this hasn't been fixed in 4.2.2 despite Google claiming that it has been, the fixes outlined in that thread still work however. Possible Fix in Post 2

    The wakelock is reduced but my battery life is the same or not significantly improved
    Well, without these patches the wakelock keeps the phone awake, but if the screen is off and nothing else is going on the kernel is just waiting for the USB bus to suspend so the CPUs are either offline or at their lowest clock speed so they aren't likely using that much power. That being said there should be some improvement in battery life over a 100-0 drain cycle, how much will depend on factors that are mainly not kernel related (time on WiFi, 3G signal strength, apps syncing in the background, etc...).

    Wasn't this fixed in 4.2.2? My msm_hsic_host wakelock is way down.
    Yes and no, Google took 2 patches that were included in the set I was using on 4.2.1, these two fixes significantly reduced the msm_hsic_host wakelock while on WiFi but not really while on 3G. So, if you use WiFi primarily your msm_hsic_host wakelock will be reduced but if you use your phone primarily on 3G it will continue to be high, though probably lower than it was on the stock 4.2.1 kernel.

    Thanks to:
    LG - for making such an awesome device
    Google - for providing us with the AOSP sources
    CyanogenMod - I used their kernel as a base
    Code Aurora Forums - for solving the issue
    Harsh - for pointing me in the right direction on which CAF patches I was missing
    franciscofranco - additional CAF patches that might help
    molesarecoming - for the color calibration halfbreed v4 settings.
    Koush - the original anykernel format
    _motley - the zip file for the anykernel version for N4
    jakejm79 - for testing various builds with various patches for me and giving me good feedback
    veyka - for testing this build and confirming that he doesn't have data issues with it
    socali - for his testing and research on the WiFi delayed notification issue.
    24
    4.2.2 Version

    Experimental WiFi Fix
    Confused about all the fixes floating around? Maybe this will help: http://xdaforums.com/showpost.php?p=40432746&postcount=578
    Date: April 15, 2013
    Download: hsic_fix_nexus4_wlan_v6.zip
    MD5: 8ba0f874efc894c8aaa2e115c5fe2438
    See here: http://xdaforums.com/showpost.php?p=40340768&postcount=522

    Revert Zip: wlan_revert.zip
    MD5: 381013687035626bcb1cbaf609ea431
    Note: Flash this if you have flashed any of the WiFi fix versions prior to switching to a different kernel.

    Stable Version: (anykernel)
    Date: March 04, 2013
    Download (any kernel): hsic_fix_nexus4_4.2.2v1.zip
    MD5: 17127c1ce03ce0489c49ed7377204a6c
    Source: https://github.com/thracemerin/Mako (branch: jb-hsic-rel tag: release-v1)

    4.2.1 Version (anykernel)
    Date: Feb 04, 2013
    Download (any kernel): https://hotfile.com/dl/192620778/4b1c43e/hsic_fix_nexus4_v2.zip.html
    MD5: 22be4821f3c16087a04a8084cc0d5703
    Source: https://github.com/thracemerin/lge-kernel-mako
    13
    So can I understand something properly regarding the msm_hsic wakelock? The issue is taht we're seeing high kernel wakelocks but this is not being reflected in partial wakelocks correct?

    So for example over 1 hour of screen off, I'll have 10 minutes of awake time. Usually, checking WLD or BBS, I'll see partial wakelocks of 1-2 minutes total from Gmail, Whatsapp, etc. But it seems most of the 10 minutes comes from msm_hsic. Is this the problem we're all talking about?

    I haven't really been observing the deep sleep time on my phone until recently, but then what constitutes an actual fix? If the awake time finally equates to the total partial wakelock time? And that the kernel wakelock time isnt' excessive for msm_hsic?

    The Nexus 4 has a hardware flaw in that the SoC used is actually a tablet SoC and not a phone SoC, as a result the cellular modem is attached to a USB bus. The msm_hsic host wakelock is held when this bus is active which happens anytime the phone needs to use the cellular modem, on some of the original firmware (4.1.x & 4.2.x specifically) there was an issue where when the phone went into suspend the msm_hsic host controller wouldn't suspend resulting in an extremely long wakelock for no reason, this has been corrected for the most part in 4.3. Keep in mind that the cellular modem has to be active a lot even on WiFi to ensure that you get proper tower information from your provider so that when you receive a phone call your phone actually rings, the wakelock will be increased while on 3G since all the data transactions also have to happen over cellular radio, it will also be increased if you are travelling while on 3G since it has to handle tower handoffs, etc... these things are handled better by SoCs that have internal modems, but the current state of the N4 as it relates to this issue is about as good as you can expect given the hardware limitations, any attempt to make it better would likely result in data drops or connectivity issues.

    Sent from my Nexus 7 (flo) using Tapatalk 4
    11
    New Build :victory:

    Prima v3.2.3.92a because v3.2.3.93 wouldn't build because of changes they made for 802.11ac which isn't supported by our device, I'll have to squash the build errors for that later.

    Anyway, this one is anykernel again, so you don't have to figure out which version to flash, all the previous comments about highly experimental, make a backup, etc... still apply. If you used my previous stock versions and your ROM supported init.d you probably noticed it was disabled, reflash your ROM first to fix this, it shouldn't happen again now that we're back to anykernel.

    Date: April 1, 2013
    Download: hsic_fix_nexus4_wlan_v3.zip
    MD5: 8cfe92dc2ddb1e8e506d5017c4fe0a2b

    Note: If you were on v1, you probably didn't notice if you didn't go to my github, but it wasn't actually v3.2.2.2 so I removed the links earlier, I would strongly recommend either v2 or v3 if you are still on v1, sorry for the confusion about that.

    A super special thanks to all the folks over at Code Aurora Forums for all the superb work they do, without them there would be no fix available.

    Happy flashing!
    11
    Testing a new wifi fixed version with the very latest prima drivers (v3.2.3.90), assuming I can't find anything wrong I will post this version later today for comparison with the older version of the wifi fix.