fiji-flo / x1carbon2018s3

S3 suspend for the X1 Carbon 2018
The Unlicense
165 stars 16 forks source link

Misunderstanding when using with Ubuntu 18 / Grub 2 #22

Closed komali2 closed 6 years ago

komali2 commented 6 years ago

Hey, great work on this, I appreciate all the work everyone is putting in here.

This isn't my world so I'm doing my best to keep up here: I'm using the latest hottest thing Ubuntu has slung our way, which ships with Grub2.

I disabled secureboot. I Made sure ACPI table ovverride is restricted didn't appear. I ensured I installed iasl and cpio. I downloaded, chmod'd and ran the generate_and_apply_patch script.

Now, I am stuck at the "Loading the override on boot" step.

From what I understand, "Edit your boot loader configuration" in grub 2 means do cd /etc/default then sudo gedit grub

There, you'll see something like

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

There, the internet tells me that GRUB_CMDLINE_LINUX_DEFAULT is most likely what this repo is referring to when it mentions "kernel parameters" in the line "add mem_sleep_default=deep to your kernel paramters.

So, I do that, and then my etc/default/grub looks like

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash /acpi_override mem_sleep_default=deep"
GRUB_CMDLINE_LINUX=""

But what I don't understand is what is meant by "add /acpi_override to the initrd line.

I don't see anything about initrd here. I am hunting through all the files in /etc/grub.d, which is apparently where other GRUB2 config files are located, but I am not seeing anything like the example given, or anything referring to initrd. There are many files.

Just to experiment, I did try just throwing it in the GRUB_CMDLINE_LINUX_DEFAULT like so:

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash /acpi_override mem_sleep_default=deep"
GRUB_CMDLINE_LINUX=""

Then I sudo update-grub, which succeeds, and reboots. However, dmesg | grep -i "acpi: (supports" is missing s3, so clearly whatever I am doing is not working.

So, where do I "add /acpi_override in Ubuntu 18 with GRUB2?

komali2 commented 6 years ago

According to the blog linked, this is probably what I need to do. I will try this:

We yet have to tell GRUB to load our new DSDT table on boot in its configuration file, usually located in /boot/grub/grub.cfg or something similar. Look out for the GRUB menu entry you're usually booting, and simply add our new image to the initrd line. It should look somewhat like that (if your initrd line contains other elements, leave them as they are and simply add the new ACPI override):

initrd /acpi_override /initramfs-linux.img Note: You will need to do this again when your distribution updates the kernel and re-writes the GRUB configuration. I'm looking for a more automated approach, but was too lazy to do it so far.

https://delta-xi.net/#056

komali2 commented 6 years ago

The blog recommends editing /boot/grub/grub.cfg directly, but the file itself has a warning at the top about doing so. I'd like to heed this warning if possible, because I am not a clever man.

komali2 commented 6 years ago

There is no line like /initramfs-linux.img.

There are other .img type type things, like

initrd /boot/initrd.img-4.15.0-29-generic

Here is what the "Ubuntu" menuentry looks like in grub.cfg

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-98288c11-f198-435b-af7b-eb4fc5a1da41' {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    insmod part_gpt
    insmod ext2
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root  98288c11-f198-435b-af7b-eb4fc5a1da41
    else
      search --no-floppy --fs-uuid --set=root 98288c11-f198-435b-af7b-eb4fc5a1da41
    fi
        linux   /boot/vmlinuz-4.15.0-29-generic root=UUID=98288c11-f198-435b-af7b-eb4fc5a1da41 ro  quiet splash mem_sleep_default=deep $vt_handoff
    initrd  /boot/initrd.img-4.15.0-29-generic
}
komali2 commented 6 years ago

I tried editing that file and completely nuked my system to the point that recovery was possible only by reinstalling Ubuntu. Do not edit grub.cfg directly.

PCK1992 commented 6 years ago

Have you figured out how to do it? I am stuck in the same place.

komali2 commented 6 years ago

No, I was unable to get it to work. However, I did a small fix that makes s2idle really not so bad.

See my comment on the lenovo forums: https://forums.lenovo.com/t5/Linux-Discussion/X1-Carbon-Gen-6-cannot-enter-deep-sleep-S3-state-aka-Suspend-to/m-p/4156860/highlight/true#M11455

Also, the people on the forums are saying that a BIOS patch has been released. There's information on the last page on how to do that , though I haven't tried it yet.

PCK1992 commented 6 years ago

BIOS update didn't change any of the sleep issues.

komali2 commented 6 years ago

Good to know

After the BIOS update, when you do dmesg | grep -i "acpi: (supports", what do you see?

PCK1992 commented 6 years ago

[ 0.121298] ACPI: (supports S0 S4 S5)

komali2 commented 6 years ago

Try switching to s5 mode see what happens. Or try them all

Pinqvin commented 6 years ago

On my Ubuntu installation, I edited the /etc/grub.d/10_linux script to add the /acpi_override to all the initrd lines when the configurations are generated. On line 314 of the script, you should find a line like this:

initrd="$i"

Change that line to the following:

initrd="acpi_override /$i"

Save your changes (you'll need to edit the file as root due to permissions) and re-generate the GRUB config by running sudo update-grub. This should add the acpi_override to every boot entry. Try rebooting to see if it works.

NOTE: If you typo something here or if your script is different for some reason (I did these changes on Ubuntu 18.04), these changes might lead you to be unable to boot. GRUB should still offer you a chance to edit the boot configuration if it's faulty. Try and erase the acpi_override part to boot back in to the OS, then revert the changes and run sudo update-grub again to re-create the GRUB configuration.

I'm not sure if this is the best way to get the acpi_override defined, but at least it has worked for me. Also worth noting that any changes to BIOS settings or upgrading the Lenovo firmware might require re-applying the DDST patch. To do that, you first need to boot into an environment without the acpi_override, otherwise you'll end up getting the already patched DDST

fiji-flo commented 6 years ago

Closing this, since Lenovo added S3 support.