Finally, S0i3 is there! Thinkpad Tablet 10 sleeps deeply with Linux kernel 4.15rc

This is so good news, finally! I have been waiting for this for almost two years now. What happened? This happened:

root@bones:~/bin# ./pms 
before sleep:
AC online @ 0.00W | Cap-remain 26.88Wh | Voltage 4.183V | Remain 0h 0m
S0IR Residency: 0us
S0I1 Residency: 0us
S0I2 Residency: 0us
S0I3 Residency: 0us
S0 Residency: 198783424us
after sleep:
AC online @ 0.00W | Cap-remain 26.88Wh | Voltage 4.183V | Remain 0h 0m
S0IR Residency: 384us
S0I1 Residency: 3936us
S0I2 Residency: 96us
S0I3 Residency: 28158592us
S0 Residency: 201490592us

What you see here is the output of a small script I wrote which sends my Thinkpad Tablet 10 with Intel Baytrail Z3795 CPU to sleep. I am using a custom script because during the past months I experimented a lot to achieve as low as possible power mode and have it sleep and resume as reliable as possible too.

What you see above is the output of my battery tool plus the output of “cat /sys/kernel/debug/pmc_atom/sleep_state” before going to sleep and right after resume. For the past kernel version all S0I stats have been zero, meaning the CPU never entered these states when sleeping. This is pretty bad since these states are the states of minimum power consumption. Not reaching these states mean higher power drain during sleep – when the device is effectively doing nothing. This caused a pretty high power drain resulting in max. three days of standby, i.e. a fully charged battery would be flat within less than three days of standby. In average this translated to about 0.3W power consumption in standby.

Previously I had experiments where it reached S0i2 and this already reduced the power consumption to about ~0.1W meaning a little more than eight days of standby. Today I discovered that with kernel 4.15rc8 I can get it to go into S0i3 which will even further increase standby times! In S0i3, the deepest sleep state, the LPDDR RAM is finally sent into self refresh so that all CPU clocks can be stopped. This will greatly improve standby!

Update: With S0i3 power consumption goes down to about 0,086W. My battery still has almost 27Wh (from the original 33Wh), so my TPT10 will run flat after 313,95 hours or 13,08 days! This is an awesome improvement!

Here is a good overview and explanation of the Intel S0i<n> states:
https://www.anandtech.com/show/6355/intels-haswell-architecture/3

On the negative side of things with kernel 4.15rc8 some things need to be tweaked and do not work at all anymore:

  • All ACPI controlled GPIOs are now by default wakeup sources. I think this to be a bad idea since the TPT10 will now wakeup to lid switch, plugging or unplugging AC and some more. Especially the lid switch is problematic since at least with my ultrabook keyboard it is extremely unreliable and wakes up even when moving the folded deice.
  • The IIO sensor hub driver has an issue, namely a parse error at boot:
    hid-sensor-hub 0018:2047:0855.0002: item 0 1 0 8 parsing failed
    hid-sensor-hub 0018:2047:0855.0002: parse failed
    hid-sensor-hub: probe of 0018:2047:0855.0002 failed with error -22
    So all IIO sensors are gone for now – no ambient light, no accel, no magnetometer anymore. Weird.
  • The LID switch as a LID switch input event is gone. I have no idea why, it might be cause by another kernel thing, first the kernel says:
    input: Lid Switch as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0D:00/input/input0
    ACPI: Lid Switch [LID0]
    but some time later:
    ACPI: button: The lid device is not compliant to SW_LID.
  • There used to be a RFKILL switch for the built-in GPS which is gone too, I need to check the kernel config and source.
  • It still happens that I get interrupt storm from acpi_irq IRQ#9 after resume. It mostly happens when the ultrabook keyboard is removed while the device is running. After that the IRQ#9 gets disabled and the S0i<n> is not reached anymore. I need to find a fix for this IR#9 getting disabled thing. Strangely during normal runtime this IRQ seems not to be used at all and also not during suspend / resume so I wonder why it prevents proper sleep after it got disabled? My current theory is that an ACPI event does not get handled properly then and that this causes further ACPI sleep requests not being processed.

But deep sleep is more important to me than the above 🙂 Still not working is battery EC readings since the method the TPT10 uses seems to be very far away from what the kernel implements here.

For getting sound to work properly you need to apply another patch so that the quirk gets applied correctly. This patch is already in the ASOC repository and will get merged into mainline. Between 4.14 and 4.15 the Alsa device name has changed so you need to upgrade your Alsa config. Pierre Louis Bossart has a Github repo with matching Alsa UCM files with which finally also automatic headphone detection is working and the digital microphones work as audio input! This is pretty awesome. Grab the UCM files here:
https://github.com/plbossart/UCM

I have compiled and uploaded a kernel 4.15rc8 and rc9 Debian packages to my server:

https://www.dpin.de/downloads/tpt10/

Have fun, happy hacking, feedback welcome!

20 thoughts on “Finally, S0i3 is there! Thinkpad Tablet 10 sleeps deeply with Linux kernel 4.15rc

  1. Slade Winstone

    Hi Nicole,

    Unfortunately I can’t see the mailing list archive for the TPT10 mailing list because the link is bad so I apologize if you’ve already answered these questions before…

    I’ve got the wifi working well with an NVRAM file but I wonder if you could provide a bit of help or assistance with sound on the TPT10?

    I’ve used your most recent 4.15.2_02 kernel image but I’m still having trouble with sound. I’ve copied your intel firmware file and asound.state and Pierre Bossarts UCM config files and restarted alsa.

    In dmesg I can see the original rt5645 error “Device with ID register 0x6271 is not rt 5645 or rt5650.”

    Following that I see several lines that refer to rt5670:
    “quirk dev_gpio”
    “quirk DMIC enabled”
    “quirk DMIC1 on IN2P pin”
    “quirk JD mode 1”

    These all seems quite hopeful! 🙂 but I can’t get manage to get any sound out of my TPT10 …

    I’ve read through your site and files and I’ve been spending a lot of time on google trying to find answers for enabling this rt5672(?) without any luck.

    Could you provide a bit more information about how you managed to get the rt5672 audio working?

    Many thanks,
    Slade.

    Reply
    1. wpadmin

      Hi,
      it seems the DMI quirk for your machine is not detected and setup correctly. Could you send the output of “dmidecode” to me please, by email, then I can check this and eventually add a new machine ID/type to the patch.

      Background is that the TPT10 BIOS falsely identifies the audio codec and thus the audio driver tries to probe it and finds a different identifier in the ID register of the chip and consequently bails out. There a bunch of machine IDs in a quirk table and probably your’s has to be added.

      Reply
  2. RussianNeuroMancer

    I wonder if you did anything special in your script to reach S0i3? I just tested Lenovo Miix 2 8 that running kernel by Hans and still get only S0 during suspend.

    Reply
    1. nicole Post author

      Which kernel version is Hans’ kernel? It started to work from 4.14.x onward IIRC.
      How do you tell that only S0 is reached and not one of the S0i* states?

      One important detail preventing entering S0i* modes is that the proper sound initialization has to be done and working. So as a brief test if you can _not_ play sound this might cause the issue (because then most likely the sound driver stack is only half loaded and initialized).

      Reply
      1. RussianNeuroMancer

        > Which kernel version is Hans’ kernel? It started to work from 4.14.x onward IIRC.
        4.13-4.15 from footrail trees.

        > How do you tell that only S0 is reached and not one of the S0i* states?
        I check /sys/kernel/debug/pmc_atom/sleep_state after wakeup.

        > One important detail preventing entering S0i* modes is that the proper sound initialization has to be done and working. So as a brief test if you can _not_ play sound this might cause the issue (because then most likely the sound driver stack is only half loaded and initialized).

        Sound is working, as Lenovo Miix2 8 is just regular tablet with rt5640 (probably very similar to yours Thinkpad Tablet 10, as I can see here: https://bugzilla.kernel.org/show_bug.cgi?id=196701 ). Required UCM files in place, necessary PulseAudio tweak is applied. Playback to both of headphones and speaker works.

        However, you give me idea why anything below S0 could fail on this particular tablet: https://bugzilla.kernel.org/show_bug.cgi?id=196701

        So I tried 4.15-footrail on another tablet – Dell 5855, but outcome is the same (sound is working too, btw: https://bugzilla.kernel.org/show_bug.cgi?id=195195 ). Take a look, maybe you will find something that require my attention: https://paste.kde.org/pz870tpp0/lijnzy

        Reply
    1. nicole Post author

      Awesome!
      Just did it (and enabled the driver in my config which I had not before) and indeed, the IRQ storms are gone!
      This is totally awesome!
      If you create a patch and want a “tested by” signature, you are welcome tp put me in there.

      And as an additional benefit, the device now wakes up when a key is pressed on the ultrabook keyboard.

      Thank you so much Hans for caring about it and letting us/me know!

      Reply
  3. Karl der Mittelgroße

    Hallo Nicole,

    habe ein Lenovo Miix 2 10″ Tablet mit Intel Atom Z3745 “inside” und das Sound-Problem unter Android-x86. Es wird keine Soundkarte erkannt…

    Könntest du mir bitte freundlicherweise gelegentlich wenigstens einen kleinen Tipp geben, wo ich anfangen sollte, um weiter zu kommen?

    Beste Grüße, Karl

    Reply
    1. nicole Post author

      Hi Karl,
      es würde helfen, mal in “dmesg” zu schauen und zu sehen, wo es am Soundtreiber klemmt. Das kann eine Menge Ursachen haben – und leider sind viele davon nicht leicht zu beheben. Ohne Debug Ausgaben kann ich dazu aber gar nichts sagen.

      Viele Grüße
      nicole

      Reply
  4. You Zhang

    Hi Nicole,

    I’m a ThinkPad 10 user from China and I have been searching for some info of installing Linux on the device. Google got me here and since it has been quite a while since you updated the ThinkPad 10 Linux topic I have some questions and I will be very grateful if you can take a look at them. Thank you for your time in advance.
    So I want to install Linux on my ThinkPad 10 1st Gen, which distro would you recommend? I plan to get the Ubuntu 18.04 or a PopOS, do you see much of a difference between distros?
    Also I wonder how well does the device work with the latest kernel. Do most of the hardware including the Ultrabook Keyboard work out of the box or do I need to tinkle a bit?
    I’m not very experienced with Linux so I expect some difficulties. Hopefully it’s not too much work.

    Best regards,
    Y.Zhang

    Reply
    1. nicole Post author

      Concerning hardware support this is mostly a matter of the Linux kernel, less of the distribution. It is not completely distribution agnostic though since some hardware requires firmware blobs which some distros carry some don’t and some others may require additional dances to get them.

      I would always recommend Debian or a Debian based distro. The package management with dependency handling and the incredible wealth of packages is IMHO unrivaled by any other distro.

      Reply
    1. nicole Post author

      Well, I am afraid basically yes, it started to work with some kernel update. But if you still experience issues due to S0ix though you have a kind of recent Linux kernel and distribution then there might be something else broken too, maybe in your distribution?
      But from the thread you are linking to I read that your issue is that your device does not go into S0i3 automatically, right? Well, I think this is the intention with S0i3, you have to enter it deliberately, it will not enter it on its own – at least as far as I have seen and experienced it. You can enter S0i3 from commandline, look at /sys/power/state, maybe aso see the Intel documentation here:
      https://01.org/blogs/qwang59/2018/how-achieve-s0ix-states-linux

      Reply
      1. Itay

        Thanks for you response!

        My problem is that my machine gets into S0i2 perfectly (when closing the lid / going to sleep) and it does save some battery. The thing is that it doesn’t get further, into S0i3, where I hope to save even more battery.

        Any documentation I’ve read anywhere on the internet never talks about S0i3 specifically (including the article you’ve shared), but about S0ix in general and how to achieve it. Well, I’ve achieved it, and I’m still trying to figure out how to enable S0i3 on my machine 🙂 (It seems that my machine currently doesn’t even try to get into S0i3 as /sys/kernel/debug/pmc_core/substate_residencies does not even print it with “0”…)

        Reply
      2. Itay

        And regarding entering S0i3 deliberately, I forgot to mention that both “echo freeze > /sys/power/state” and “echo mem > /sys/power/state” gets the system into S0i2.

        Reply
        1. nicole Post author

          I am afraid then I also do not know what is preventing it entering S0i3 then… “freeze” was what forced my ThinkPad Tablet 10 into S0i3.

          Reply
          1. Itay

            Interesting, thanks for sharing! I’ll hopefully come back here one day with an update when it’ll work.

      3. Itay

        Thanks for you response!

        My problem is that my machine gets into S0i2 perfectly (when closing the lid / going to sleep) and it does save some battery. The thing is that it doesn’t get further, into S0i3, where I hope to save even more battery.

        Any documentation I’ve read anywhere on the internet never talks about S0i3 specifically (including the article you’ve shared), but about S0ix in general and how to achieve it. Well, I’ve achieved it, and I’m still trying to figure out how to enable S0i3 on my machine 🙂 (It seems that my machine currently doesn’t even try to get into S0i3 as /sys/kernel/debug/pmc_core/substate_residencies does not even print it with “0”…)

        And regarding entering S0i3 deliberately, I forgot to mention that both “echo freeze > /sys/power/state” and “echo mem > /sys/power/state” gets the system into S0i2.

        Reply
      4. Itay

        Thanks for you response!

        My problem is that my machine gets into S0i2 perfectly (when closing the lid / going to sleep) and it does save some battery. The thing is that it doesn’t get further, into S0i3, where I hope to save even more battery.

        Any documentation I’ve read anywhere on the internet never talks about S0i3 specifically (including the article you’ve shared), but about S0ix in general and how to achieve it. Well, I’ve achieved it, and I’m still trying to figure out how to enable S0i3 on my machine 🙂 (It seems that my machine currently doesn’t even try to get into S0i3 as /sys/kernel/debug/pmc_core/substate_residencies does not even print it with “0”…)

        And regarding entering S0i3 deliberately, both “echo freeze > /sys/power/state” and “echo mem > /sys/power/state” gets the system into S0i2.

        Reply

Schreibe einen Kommentar zu Itay Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert