Lenovo X1 Carbon 6 Gen [S3] Deep Sleep


Update (October 17th):

Per the latest comment, these steps are no longer needed in the latest bios updates from Lenovo:


Disclaimer: I’m not responsible for any damages or injury, including but not limited to special or consequential damages, that result from your use of this instructions.

As promised here, I am covering the steps to get S3 deep sleep working on a 6th generation Lenovo ThinkPad X1 Carbon specifically running Ubuntu 18.04. These steps were worked out based on the guidelines from this post and an updated patch referenced by this post.

  1. Reboot, enter your BIOS/UEFI. Go to Config — Thunderbolt (TM) 3 — set Thunerbolt BIOS Assist Mode to Enabled. It has also been reported that Security — Secure Bootmust be disabled.
  2. With universe repo added,
sudo apt install acpica-tools cpio

3. For convenience and not necessarily the best practice, I sudo su to root:

sudo su - root

4. Then I made a directory to store all my work for this hack:

mkdir -p /root/sleep
cd /root/sleep

5. Get a dump of the ACPI DSDT table:

cat /sys/firmware/acpi/tables/DSDT > dsdt.aml

6. Decompile the dump, which will generate a .dsl source based on the .aml ACPI machine language dump.

iasl -d dsdt.aml

7. If it worked properly, you will see output similar to below:

Intel ACPI Component Architecture
ASL+ Optimizing Compiler/Disassembler version 20180105
Copyright (c) 2000 - 2018 Intel Corporation
Input file dsdt.aml, Length 0x26183 (156035) bytes
ACPI: DSDT 0x0000000000000000 026183 (v02 LENOVO SKL 00000000 INTL 20160527)
Pass 1 parse of [DSDT]
Pass 2 parse of [DSDT]
Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)
Parsing completed
Disassembly completed
ASL Output: dsdt.dsl - 1077991 bytes

8. Download the updated patch for Ubuntu referenced here instead of the one suggested in Delta Xi:

wget https://gist.githubusercontent.com/PombeirP/67a3e2b479b6a8a71b26f4b6ad624e1c/raw/c4bc3cce254f18b911e408b8bbee3429c64caed1/X1C6_S3_DSDT.patch

9. Apply the downloaded patch against your dsdt.dsl

patch --verbose < X1C6_S3_DSDT.patch

10. If all goes well, it should look something like this:

Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- dsdt.dsl.orig 2018-05-29 19:08:56.321347717 +0200
|+++ dsdt.dsl 2018-05-29 19:10:53.737896784 +0200
--------------------------
patching file dsdt.dsl
Using Plan A...
Hunk #1 succeeded at 18.
Hunk #2 succeeded at 39.
Hunk #3 succeeded at 66.
Hunk #4 succeeded at 159.
Hunk #5 succeeded at 177.
Hunk #6 succeeded at 195.
Hunk #7 succeeded at 351.
Hunk #8 succeeded at 13763.
Hunk #9 succeeded at 27513.
Hunk #10 succeeded at 34763.
done

11. If not, note the following suggestion from Delta Xi:

Plan B: If this does not work (patch is rejected): It has been the case, that certain UEFI settings may lead to different DSDT images. This means that it may be possible that the above patch doesn't work at all with your decompiled DSL. If that is the case, don't worry: Go through the .patch file in your editor, and change your dsdt.dsl by hand. This means locating the lines which are removed in the patch and removing them in your dsl. The patch contains only one section at the end which adds a few lines - these are important and make the sleep magic happen.

12. Also, note the following:

Make sure that the hex number at the end of the first non-commented line is incremented by one (reading DefinitionBlock, should be around line 21). E.g., if it was 0x00000000 change it to 0x00000001. Otherwise, the kernel won't inject the new DSDT table.

13. Recompile your patched version of the .dsl source

iasl -ve -tc dsdt.dsl

14. If all goes well, you should see something like this:

Intel ACPI Component Architecture
ASL+ Optimizing Compiler/Disassembler version 20180105
Copyright (c) 2000 - 2018 Intel Corporation
ASL Input:     dsdt.dsl - 34767 lines, 1075418 bytes, 15321 keywords
AML Output: dsdt.aml - 144267 bytes, 2876 named objects, 12445 executable opcodes
Hex Dump: dsdt.hex - 1352883 bytes
Compilation complete. 0 Errors, 332 Warnings, 116 Remarks, 6298 Optimizations, 46 Constants Folded

15. Now we have to create a CPIO archive with the correct structure, which GRUB can load on boot (much like initrd is loaded). We name the final image acpi_override and copy it into /boot/

mkdir -p kernel/firmware/acpi
cp dsdt.aml kernel/firmware/acpi/
find kernel | cpio -H newc --create > acpi_override
cp acpi_override /boot/

16. Now that we have acpi_override in /boot/, let’s make Grub load it on boot by editing the following file:

vim /etc/grub.d/10_linux

17. Search for the “initrd” string that looks like this:

initrd ${rel_dirname}/${initrd}

18. Edit that line to look like this instead:

initrd /acpi_override ${rel_dirname}/${initrd}

19. Edit the /etc/default/grub:

sudo vim /etc/default/grub

20. Search for the following line that starts with:

GRUB_CMDLINE_LINUX_DEFAULT=

21. Edit that line to look like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=deep acpi.ec_no_wakeup=1"

22. Generate the grub settings with the following command:

update-grub

23. Reboot


Update:

As made apparent by some of the readers of this post, depending on your setup, step 18 might have to be this instead if you get an error upon a reboot saying something along the lines of “/acpi_override not found”:

initrd /boot/acpi_override ${rel_dirname}/${initrd}

24. Now let’s check if the settings are in effect:

j@x1c6:~$ dmesg |grep ACPI |grep supports
[ 0.177328] ACPI: (supports S0 S3 S4 S5)
j@x1c6:~$ cat /sys/power/mem_sleep
s2idle [deep]

The bold text from the above are what you should look for. If you see both, that means the hack worked and you now have S3 deep sleep working for your brand new X1 Carbon! The difference is roughly 2% of battery over 6–7 hours of sleep with a snappy wake-up versus 1% battery over 30–45 minutes of S2 sleep with a laggy wake-up. I’d say this is a huge improvement from a big FAIL out of the box for this laptop.

Thanks to the good work of Delta Xi and the hackers at the Arch Linux forum for making this possible so that people like myself can actually make this laptop a more usable workstation for the road!

Enjoy! :)