Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the state of suspend/hibernate? #431

Open
versipellis opened this Issue Mar 16, 2019 · 35 comments

Comments

Projects
None yet
@versipellis
Copy link

versipellis commented Mar 16, 2019

As the title states - what's the state of this? I don't seem to be alone in not having either working (SB2, even with a properly configured swapfile).

I recall jake saying we should be using suspend over hibernate now, but I can't seem to find which issue that was in. On top of that, issues like #266 are getting closed without a note or resolution.

@nkkollaw

This comment has been minimized.

Copy link

nkkollaw commented Mar 16, 2019

On top of that, issues like #266 are getting closed without a note or resolution.

Yes, see my comment in that issue, "I mean, it's fine as @jakeday does whatever with his repo, but I see the majority of issues get closed without even a note, even though they're not resolved".

It's a little confusing, and probably annoying for people that invest time in reporting issues only to see them get closed for seemingly no reason (or with no official reason stated).

Unfortunately I'm not familiar with kernel development and can just complain rather than help, but... I would GLADLY contribute $5/mo. if there was an Open Collective account to donate to. I know that contributors to this project have their own dayjob or projects for actual paying clients, but MAYBE if people donated it would help making some extra time for working on this instead.

@kitakar5525

This comment has been minimized.

Copy link

kitakar5525 commented Mar 16, 2019

state of suspend

I think most of the Surface devices can suspend correctly even on a non-patched kernel.
(One of the exceptions is Surface Book with Performance Base which uses TOSHIBA NVMe SSD [1179:010f]. Not Surface Book, which uses Samsung NVMe SSD. See my resolved issue if you are interested in: #123)

Correctly means we can use suspend (s2idle) and our Surface can wakeup from suspend. However, currently at least my Surface Book with Performance Base cannot achieve s0ix yet, thus high power consumption during suspend. Like about 2~3 %/h battery drain. (whereas Surface 3, which uses Atom SoC, can achieve s0ix on Linux 4.20 or later)

I think

Connected Standby is not supported yet

only means we cannot achieve s0ix yet.

There is a documentation from Intel of s2idle and s0ix states on Linux:

Some other devices are also struggling to achieve s0ix:

debugging suspend

If you replaced suspend with hibernate in setup.sh, systemctl suspend also hibernate your system. Try like this to suspend in such a situation:

sudo /usr/lib/systemd/system-sleep/sleep pre; sudo su -c "echo freeze > /sys/power/state"; sudo /usr/lib/systemd/system-sleep/sleep post

If you have suspend issue, you can debug suspend like this before going into suspend:

sudo su -c "echo 1 > /sys/power/pm_debug_messages"
sudo su -c "echo 0 > /sys/module/printk/parameters/console_suspend"
sudo su -c "echo 1 > /sys/module/printk/parameters/ignore_loglevel"
dmesg -xHTw

If your Surface will not turn on, force restart and you can see kernel logs of previous boot:

journalctl -xk -b -1
@nkkollaw

This comment has been minimized.

Copy link

nkkollaw commented Mar 16, 2019

I have set my laptop's screen to go blank when I close the lid (so, no suspend). Yet, when I open it again many times drivers get unloaded: touchpad, touchscreen, sometimes screen will not turn on again.

Is there any way I can debug this behavior? Does it have anything to do with suspend?

@kitakar5525

This comment has been minimized.

Copy link

kitakar5525 commented Mar 16, 2019

I have no idea why touchpad, touch input and screen crashes even on going into screen blank.
I also frequently use only screen lock (no suspend) but with no problems.

Please see the log output flow before and after going into screen blank:

sudo su -c "echo 1 > /sys/module/printk/parameters/ignore_loglevel"
dmesg -xHTw

You can lock screen and output the mark of screen lock to dmesg like I did before (#388):

sudo su -c "echo 'screen lock on GNOME' > /dev/kmsg"
dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock

If your system is no longer responsive, force reboot and see previous boot kernel logs:

journalctl -xk -b -1

EDIT

I'm experiencing now a crash when lid closed and going into blank screen on recently released GNOME 3.32 Wayland session on Arch Linux (no problems with Xorg session). This is absolutely not related to kernel, but just for your information.

Some logs from journalctl -b -0...

Mar 17 00:38:33 localhost systemd-logind[529]: Lid closed.
Mar 17 00:38:33 localhost systemd-logind[529]: Locking sessions...
[...]
Mar 17 00:38:34 localhost gnome-shell[1586]: Failed to flip onscreen: Tried to flip inactive CRTC
[...]
Mar 17 00:38:50 localhost systemd-logind[529]: Lid opened.
Mar 17 00:38:50 localhost gnome-shell[1586]: Failed to flip onscreen: Tried to flip inactive CRTC
Mar 17 00:39:00 localhost tracker-miner-f[1965]: g_str_has_suffix: assertion 'str != NULL' failed
[...]
Mar 17 00:39:07 localhost systemd-coredump[2774]: Process 1586 (gnome-shell) of user 1000 dumped core.
@jakeday

This comment has been minimized.

Copy link
Owner

jakeday commented Mar 17, 2019

@versipellis Suspend is functioning better than hibernate at this point, and several issues have been with hibernate not being setup properly. It seems several assume just having a big enough swap and enabling hibernate is good enough, but it's not. I would personally rather use suspend at this point and would recommend that. It's more stable and easier to setup.

@nkkollaw As I mentioned in the issue you pointed out for your comment, I usually try to comment on issues before closing them. If they are getting closed, I've either checked that they are fixed or they are tracked in another issue and it's just a duplicate. Sometimes I make mistakes, and I apologize for that!

@nkkollaw

This comment has been minimized.

Copy link

nkkollaw commented Mar 17, 2019

@jakeday: of course! Your work is a miracle since I can actually use Linux on this awesome laptop.

I just wrote that because it was confusing.

In addition, some issues that get closed are not solved on my end even after upgrading and restarting, which adds to my confusion. I guess however that on your system and/or with a clean install they are absolutely solved, and my system has some specific configuration that stops certain things from working.

What do you think about my Open Collective comment? I know you don't do this for money, and have no idea if enough people use this projects to raise enough for it to make sense, but if there was let's say $500-1000/mo. it would be appreciated, I guess? I would be happy to contribute with $5/mo. as long as I use the Surface Book as a laptop (which I plan to do for many years).

@hjr265

This comment has been minimized.

Copy link

hjr265 commented Mar 17, 2019

I really wanted to contribute as well, but unfortunately PayPal isn't an option.

Also, someone in Reddit mentioned this, and I totally agree with them, we really need a wiki where it is easier to document these quirks and fixes.

@jakeday

This comment has been minimized.

Copy link
Owner

jakeday commented Mar 17, 2019

@nkkollaw I'll do a better job at explaining when issues are closed as well as getting others to verify. I want to prevent any cofusion! I like that idea of an Open Collective, but going that route we would need to ensure any and all contributors can participate. What are your thoughts on that?

@hjr265 I opened up the Wiki on this GitHub repo and put some placeholder info there. Anyone should be able to edit it. Would that be a good start?

@nkkollaw

This comment has been minimized.

Copy link

nkkollaw commented Mar 17, 2019

@jakeday : I've used Open Collective only once, and don't know if multiple people can share contributions.

MAYBE the best way would be to use Open Collective for the project, and then you use some or all of the money could go towards Bounty Source, ex. a bug or feature is assigned an amount according to difficulty, and at that point whoever fixes that bug gets the money--giving money to contributors directly. I think that would be fair for anyone. elementary OS uses this approach and it works for them.

I also don't know if one can setup donations on Bounty Source directly without going through Open Collective.

Since I can't do any kernel development or patching I can help by looking into those options, if you think you'd entertain any of those or a mix of the two.

@sokolowistan96

This comment has been minimized.

Copy link

sokolowistan96 commented Mar 18, 2019

Suspend is functioning better than hibernate at this point, and several issues have been with hibernate not being setup properly. It seems several assume just having a big enough swap and enabling hibernate is good enough, but it's not. I would personally rather use suspend at this point and would recommend that. It's more stable and easier to setup.

@jakeday

What way is there to restore suspend-function without installing the whole kernel anew? (because from what I've understood, the script replaced suspend with hibernate, barring choosing "no")

I'm asking because I'm not even sure if installing it anew and choosing "no" would retrieve that function, as the script only does something when choosing "yes"

@tmarkov

This comment has been minimized.

Copy link
Contributor

tmarkov commented Mar 18, 2019

There is a way to get suspend back. The script replaces the files /etc/systemd/system/suspend.target and /etc/systemd/system/systemd-suspend.service with symlinks to the appropriate hibernate files, but it does back up the originals. So you simply need to restore them.

@HastyMarly

This comment has been minimized.

Copy link

HastyMarly commented Mar 19, 2019

I'm able to suspend on my SL2 using linux-surface-petercxy 5.0.1-1 on Archlinux using systemctl suspend (with the service scripts pointing to suspend not hibernate). I have to hit the power button to turn it back on and everything seems to work. However, if I suspend a second time without rebooting, the screen will come back but my wifi, keyboard and touchpad don't work. Is this the expected behavior as things currently stand or should I try to dig into it some more?

@sokolowistan96

This comment has been minimized.

Copy link

sokolowistan96 commented Mar 19, 2019

There is a way to get suspend back. The script replaces the files /etc/systemd/system/suspend.target and /etc/systemd/system/systemd-suspend.service with symlinks to the appropriate hibernate files, but it does back up the originals. So you simply need to restore them.

@tmarkov could you tell me where to find those backups?

@tmarkov

This comment has been minimized.

Copy link
Contributor

tmarkov commented Mar 19, 2019

@sokolowistan96 In the same directory.

@sokolowistan96

This comment has been minimized.

Copy link

sokolowistan96 commented Mar 19, 2019

@sokolowistan96 In the same directory.
@tmarkov
I may be a feckless noob, but I can't find anything that looks remotely like a backup haha
here's a screenshot of the directory:
Screenshot from 2019-03-19 22-07-20

@tmarkov

This comment has been minimized.

Copy link
Contributor

tmarkov commented Mar 19, 2019

@sokolowistan96 You don't have one. When did you replace suspend? Older version of the script didn't do backups. In that case look here: https://askubuntu.com/questions/66533/how-can-i-restore-configuration-files

@sokolowistan96

This comment has been minimized.

Copy link

sokolowistan96 commented Mar 19, 2019

@tmarkov
thats weird, because I did it only a couple of days ago. BTW the file itself looks like that, so it's definitely replaced:
Screenshot from 2019-03-19 22-22-43
I tried to replace every hibernate with suspend in hope it would work but that (sadly but obviously) didn't change anything haha

I will take a look into the link, but I'd be glad if @jakeday could answer, as he must know how to do it

@tmarkov

This comment has been minimized.

Copy link
Contributor

tmarkov commented Mar 19, 2019

@sokolowistan96

Here's what I have in my files. Note that there are two and you need to fix both.

suspend.target

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Suspend
Documentation=man:systemd.special(7)
DefaultDependencies=no
Requires=systemd-suspend.service
After=systemd-suspend.service
StopWhenUnneeded=yes

systemd-suspend.service:

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Suspend
Documentation=man:systemd-suspend.service(8)
DefaultDependencies=no
Requires=sleep.target
After=sleep.target

[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-sleep suspend
@sokolowistan96

This comment has been minimized.

Copy link

sokolowistan96 commented Mar 19, 2019

@tmarkov it seems to be working now but you won't believe how & I don't think it's a healthy state haha.
I looked up the properties of suspend.target and saw that it points/links to a file called hibernate.target in the same directory (which doesn't even exist in my file browser?).

so I thought well, maybe I should just relink it to suspend.target
googled how to do it, did it and know the file is being shown as broken
however, when I now use suspend it is working perfectly fine

But here is the big issue... my surface book 2 started doing a weird droning noise while on ubuntu and while I can't believe that this is somehow connected to breaking a stupid link-file, it occurred for the first time ever after just now.
Edit: The noise persisted even after a restart to windows, however not when i shut down completely and then restarted... very weird indeed, almost certainly not related to deleting that link but probably related to linux itself.. I may open up a seperate issue for that, if it persists as it's kind of off topic.

I'd still like to get those link-files back into some normal healthy-looking state though
thats how it looks now

new
new2

@tmarkov

This comment has been minimized.

Copy link
Contributor

tmarkov commented Mar 19, 2019

@sokolowistan96 Originally, you have four files. suspend.target, hibernate.target, systemd-suspend.service, and systemd-hibernate.service. Clearly two handle suspend (and contain what I posted above), and two handle hibernate and you have them. The switch is done by deleting the suspend files (it's actually supposed to back them up by adding ~ to the end of the file name, don't know why you don't have backup) and replacing them with link to the hibernate files, so when the system tries to susuend, it processes the hibernate files instead.

So, to properly undo the switch you simply need to delete the link and restore the original files. If it works with broken links that point to themselves you can leave it as is, I guess. I would expect something to be broken because of that (maybe it's something you don't use).

@nkkollaw

This comment has been minimized.

Copy link

nkkollaw commented Mar 19, 2019

@sokolowistan96 : sorry to hack the thread, was is your icon theme? Looks awesome!

@sokolowistan96

This comment has been minimized.

Copy link

sokolowistan96 commented Mar 19, 2019

@sokolowistan96 : sorry to hack the thread, was is your icon theme? Looks awesome!

Haha yeah I love it.
It is Numix-circle (should come with the "unity/gnome tweak tool")

@sokolowistan96

This comment has been minimized.

Copy link

sokolowistan96 commented Mar 19, 2019

@tmarkov
it stopped working now, so clearly it wasn't a good solution haha, idk why it worked in the first place
I'll try to do that tomorrow, as it's late now (at least here in Vienna)
would you mind uploading the original files ? I'm not sure how to create them from scratch

@tmarkov

This comment has been minimized.

Copy link
Contributor

tmarkov commented Mar 20, 2019

@sokolowistan96 Right click - new - text file? Maybe it's called empty document instead. But they're just normal regular text files. Also, not to spam here, can you ask any further question on gitter https://gitter.im/linux-surface/support?source=orgpage?

@sikandar566

This comment has been minimized.

Copy link

sikandar566 commented Mar 23, 2019

There is a way to get suspend back. The script replaces the files /etc/systemd/system/suspend.target and /etc/systemd/system/systemd-suspend.service with symlinks to the appropriate hibernate files, but it does back up the originals. So you simply need to restore them.

You can do so by breaking symlinks given that you still have suspend.target and systemd-suspend.service in same directory
sudo unlink /lib/systemd/system/hibernate.target
sudo unlink /lib/systemd/system/systemd-hibernate.service

Additionally you can run setup.sh if you want updated kernel version

@ezyang

This comment has been minimized.

Copy link

ezyang commented Mar 24, 2019

@sikandar566 Err, isn't your quoted command deleting the hibernate target?

@michaelperel

This comment has been minimized.

Copy link

michaelperel commented Mar 27, 2019

In my experience (surface pro 4) with kernel 5.0.1, the symbolic links /etc/systemd/system/suspend.target, /etc/systemd/system/suspend.target~, /etc/systemd/system/systemd-suspend.service, and /etc/systemd/system/systemd-suspend.service~ all existed after choosing yes to replace suspend with hibernate while doing setup.sh. As hibernate caused issues, I wanted to revert back to suspend. I have removed those four symbolic links (sudo rm <filename here>). Suspend seems to be working fine by just removing those symbolic links, and I think the reason is because the files for suspend already exist in /lib/system/system.d. You can see those files with ls /lib/systemd/system | grep suspend. They contain the contents of the files that @tmarkov posted above (you can see this with cat /lib/systemd/system/suspend.target and cat /lib/systemd/system/systemd-suspend.service). I have only tested this for about ~30 mins, and if I have trouble with suspend, I will post an update

@versipellis

This comment has been minimized.

Copy link
Author

versipellis commented Apr 3, 2019

So, systemctl suspend seems to work, after reverting the setup.sh changes, mostly.. Except I get the hissing sound after resuming from suspend. Is anyone else getting this?

@versipellis

This comment has been minimized.

Copy link
Author

versipellis commented Apr 5, 2019

Also, suspending my SB2 seems to still cause it to generate pretty significant amounts of heat over time. Anyone else facing this?

@NitroBAY

This comment has been minimized.

Copy link

NitroBAY commented Apr 5, 2019

No I don't get any hissing sound on my SB. I get perfect thermals while sleeping (edit: while my computer sleeps I meant).
EDIT : I mean SB1, I don't have SB2.
EDIT : is your bug related to the one described here https://wiki.archlinux.org/index.php/Microsoft_Surface_Book_2#audio

@kitakar5525

This comment has been minimized.

Copy link

kitakar5525 commented Apr 6, 2019

@versipellis

generate pretty significant amounts of heat over time

It reminds me of NVMe SSD heat. (Bug #1801875 “Power consumption during s2idle is higher than lon...” : Bugs : linux package : Ubuntu)

What is the SSD temperature before and after long (like 1 hour) suspend?

sudo smartctl -a /dev/nvme0 | grep -e "Temperature" -e "Model Number"

EDIT

If smartctl not exist, install smartmontools:

sudo apt install smartmontools
@Larx

This comment has been minimized.

Copy link

Larx commented Apr 6, 2019

So what is the recommended configuration now? I never thought about it, as I for years simply disabled suspend in favour of hibernate on my surface, and then I stumbled over this bug report. So nowadays suspend is possible?
Does that mean that only the two systemd-units for suspend don't need to be symlinked to hibernate, or are the changes to logind.conf and sleep.conf no longer necessary?
Thanks!

@Larx

This comment has been minimized.

Copy link

Larx commented Apr 16, 2019

To add my experiences: For my Surface Pro 3, suspend is really unreliable, most of the time it simply suspends itself again after waking up for a few seconds. Only hard poweroff helps. Hibernate works better!

@chenchen2015

This comment has been minimized.

Copy link

chenchen2015 commented Apr 17, 2019

On Surface Book 1, suspend works very unreliably as well. I have roughly the same experience as @Larx after getting suspend to work as described by @tmarkov Most of the times, I cannot even wake up my machine after suspend. For the record, I have the version with 8GB memory and configured a 10GB swap space.

@NitroBAY

This comment has been minimized.

Copy link

NitroBAY commented Apr 18, 2019

Suspend works constistantly on my SB1 @Arch also 8GB ram 10gb swap.
What does not tho is hibernating. Sometimes hibernate work sometimes it does save and therefore go back to the state before turning off but actually do not turn off like the screen is turned off but the PC is still on and I can still change the keyboard backlighting (I need to force turn off through power button on the top).
Very annoying as I'm using suspend-then-hibernate .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.