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

Suspend doesn't work after the laptop's lid is closed #1273

Closed
morfikov opened this issue Sep 15, 2015 · 15 comments
Closed

Suspend doesn't work after the laptop's lid is closed #1273

morfikov opened this issue Sep 15, 2015 · 15 comments

Comments

@morfikov
Copy link

I recently noticed that my laptop can't be suspended via closing its lid.

I have the following settings set in the /etc/systemd/logind.conf file:

# egrep -v ^# /etc/systemd/logind.conf

[Login]
KillUserProcesses=yes
KillOnlyUsers=morfik
KillExcludeUsers=root
HandlePowerKey=hibernate
HandleSuspendKey=suspend
HandleHibernateKey=hibernate
HandleLidSwitch=hybrid-sleep

I tried to change HandleLidSwitch to something else: poweroff, suspend, hibernate -- none of them work.

When I restarted systemd-logind, I got the following log:

Sep 15 13:34:13 morfikownia polkitd(authority=local)[1731]: Registered Authentication Agent for unix-process:11709:156806 (system bus name :1.38 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
Sep 15 13:34:13 morfikownia systemd[1]: lvm2.service: Cannot add dependency job, ignoring: Unit lvm2.service is masked.
Sep 15 13:34:13 morfikownia systemd[1]: Stopping Login Service...
Sep 15 13:34:13 morfikownia systemd[1]: Stopped Login Service.
Sep 15 13:34:13 morfikownia systemd[1]: Starting Login Service...
Sep 15 13:34:13 morfikownia systemd-logind[11715]: New seat seat0.
Sep 15 13:34:13 morfikownia systemd[1]: Started Login Service.
Sep 15 13:34:13 morfikownia polkitd(authority=local)[1731]: Unregistered Authentication Agent for unix-process:11709:156806 (system bus name :1.38, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Sep 15 13:34:13 morfikownia systemd-logind[11715]: Watching system buttons on /dev/input/event3 (Power Button)
Sep 15 13:34:13 morfikownia systemd-logind[11715]: Watching system buttons on /dev/input/event4 (Video Bus)
Sep 15 13:34:13 morfikownia systemd-logind[11715]: Watching system buttons on /dev/input/event2 (Power Button)
Sep 15 13:34:13 morfikownia systemd-logind[11715]: Watching system buttons on /dev/input/event1 (Lid Switch)
Sep 15 13:34:13 morfikownia systemd-logind[11715]: Watching system buttons on /dev/input/event8 (HP WMI hotkeys)
Sep 15 13:34:13 morfikownia systemd-logind[11715]: New session c1 of user lightdm.
Sep 15 13:34:13 morfikownia systemd-logind[11715]: New session 1 of user morfik.

But when I close/open the lid, I get only the two messages:

Sep 15 13:35:22 morfikownia systemd-logind[11715]: Lid closed.
Sep 15 13:35:31 morfikownia systemd-logind[11715]: Lid opened.

All the commands:

$ systemctl suspend
$ systemctl hibernate
$ systemctl hybrid-sleep

work just fine when they're typed into the terminal.

I've changed the behavior of the power button so it could hibernate my machine -- it works and reacts to the assigned action.

# systemctl --version
systemd 226
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID -ELFUTILS +KMOD -IDN
@grawity
Copy link
Contributor

grawity commented Sep 17, 2015

Please run systemd-inhibit --list --mode=block to check whether another program has taken over the lid-switch handling (e.g. Powerdevil). It will appear as a "handle-lid-switch" inhibitor in the list.

@poettering
Copy link
Member

Yeah, most likely something is just blocking the inhibiting, please use @grawity's suggested command line to check what tht might be.

@poettering poettering added login needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer labels Sep 18, 2015
@morfikov
Copy link
Author

It says:

# systemd-inhibit --list --mode=block
0 inhibitors listed

@LeifW
Copy link

LeifW commented Sep 23, 2015

Same symptoms here. Started when I upgraded to systemd 226. Downgrading back to 225 fixes it for me. Any other info I could provide?

@zonque
Copy link
Member

zonque commented Sep 23, 2015

Hmm, there's no obvious commit in logind between v225 and v226 that would explain that. Could you boot your system with debug on the kernel command line, and then provide logs for both cases?

@morfikov
Copy link
Author

I've also tested v225 and suspend works here just fine. After updating only the following packages: udev systemd libpam-systemd libnss-myhostname systemd-sysv, it stops. (it's debian distro)

What logs exactly do you need? Just the messages between Lid closed and Lid opened or full logs from start to end?

Anyways, in the case of v225, there's something like this:

Sep 23 10:45:59 morfikownia systemd-logind[1480]: Lid closed.
Sep 23 10:45:59 morfikownia systemd-logind[1480]: device-enumerator: scan all dirs
Sep 23 10:45:59 morfikownia systemd-logind[1480]:   device-enumerator: scanning /sys/bus
Sep 23 10:45:59 morfikownia systemd-logind[1480]:   device-enumerator: scanning /sys/classt pref]
Sep 23 10:45:59 morfikownia systemd-logind[1480]: Failed to open configuration file '/etc/systemd/sleep.conf': No such file or directory
Sep 23 10:45:59 morfikownia systemd-logind[1480]: Hibernation is possible, Active(anon)=293824 kB, size=524284 kB, used=16 kB, threshold=98%
Sep 23 10:45:59 morfikownia systemd-logind[1480]: Hibernating and suspending...

And in the case of v226:

Sep 23 10:52:56 morfikownia systemd-logind[1446]: Lid closed.
Sep 23 10:52:56 morfikownia systemd-logind[1446]: System is docked.
Sep 23 10:52:56 morfikownia systemd-logind[1446]: Refusing operation, as it is turned off.
Sep 23 10:52:56 morfikownia systemd-logind[1446]: System is docked.
Sep 23 10:52:56 morfikownia systemd-logind[1446]: Refusing operation, as it is turned off.

@zonque
Copy link
Member

zonque commented Sep 23, 2015

And the system is docked in both cases? I wonder why v225 doesn't detect this. Are you sure the configuration files, most importantly /etc/systemd/logind.conf are the same after installing either package? Does Debian ship any HandleLidSwitchDocked config directive?

Again, the changes in logind between v225 and v226 are minimal, and none of them would explain the effect you see.

@poettering
Copy link
Member

@morfikov logind, seems to think your system is docked when you close the lid. Is it docked? systemd considers systems docked where this is either reported via an SW_DOCK input switch (which some laptop drivers expose), or if there's more than one screen attached and up. Is that the case for you? What does "grep . /sys/class/drm/*/status" say when this happens?

@morfikov
Copy link
Author

I didn't change anything. I just upgraded/downgraded the packages. So the state of the machine was/is always the same, and in one case suspend works, and in the other doesn't. Config files are the same I think, and I included the content of the logind.conf at the beginning.

Is it docked? Does it mean the power cable is connected? If yes, it's always connected. But it doesn't matter whether it's connected or not -- it doesn't work either way.

There's only one screen:

# grep . /sys/class/drm/*/status
/sys/class/drm/card0-DP-1/status:disconnected
/sys/class/drm/card0-HDMI-A-1/status:disconnected
/sys/class/drm/card0-LVDS-1/status:connected
/sys/class/drm/card0-VGA-1/status:disconnected

@zstewar1
Copy link

Same problem here:

Sep 26 19:47:01 R6-C9 systemd-logind[17954]: Lid closed.
Sep 26 19:47:01 R6-C9 systemd-logind[17954]: System is docked.
Sep 26 19:47:01 R6-C9 systemd-logind[17954]: Refusing operation, as it is turned off.
Sep 26 19:47:01 R6-C9 systemd-logind[17954]: System is docked.
Sep 26 19:47:01 R6-C9 systemd-logind[17954]: Refusing operation, as it is turned off.
$ grep . /sys/class/drm/*/status
/sys/class/drm/card0-DP-1/status:disconnected
/sys/class/drm/card0-HDMI-A-1/status:disconnected
/sys/class/drm/card0-LVDS-1/status:connected
/sys/class/drm/card0-VGA-1/status:disconnected
$ systemd-inhibit --list --mode=block
0 inhibitors listed.

@morfikov
Copy link
Author

@poettering I've managed to figure out what's wrong. First of all, I was missing the following option:

HandleLidSwitchDocked=hybrid-sleep

After adding it, strange things started to happen. Hibernation/hybrid-sleep sometimes was working, and sometimes wasn't. That was because of ZRAM devices. I have two of them: one for the /tmp/ directory, and the other for SWAP. The setup looks like this:

# lsblk
NAME                       SIZE FSTYPE      TYPE  LABEL MOUNTPOINT   UUID
sda                      232.9G             disk
├─sda1                      40G ntfs        part                     02282C55282C49CD
├─sda2                       1G ext4        part  boot  /boot        4c67dff5-3d8e-4b3f-9cf1-49b88d5f67a9
├─sda3                      20G crypto_LUKS part                     9e03ae84-2f10-4f88-bf1c-d7507ad30f78
│ └─debian_laptop           20G LVM2_member crypt                    1f7G9n-hwJ4-hD20-N9GP-3l77-8tCi-uM7LZG
│   ├─debian_laptop-root    12G ext4        lvm   root  /            dfdc8fb7-d9d4-4cd4-869c-0f1910a3a17e
│   ├─debian_laptop-home     4G ext4        lvm   home  /home        27632431-fa15-49ba-8354-9c193e321aa6
│   ├─debian_laptop-tmp      2G ext4        lvm   tmp                be5e9b14-4f41-462a-b3c6-8502e88cc0c7
│   └─debian_laptop-swap     2G swap        lvm         [SWAP]       c4f58930-bfda-4f4e-bad0-2be8d1b5bc9e
├─sda4                       1K             part
├─sda5                      30G crypto_LUKS part                     d314ed20-ffaf-4a18-98a7-91538e79d981
│ └─grafi                   30G ext4        crypt grafi /media/Grafi 990d110a-1310-4ab2-8a03-c952a408be11
└─sda6                   141.9G crypto_LUKS part                     f3c10054-0583-4e10-937b-dcdc9a05a25c
  └─kabi                 141.9G ext4        crypt kabi  /media/Kabi  b47e6dcd-924e-40fa-a8b1-7593419f86d7
sr0                       1024M             rom
zram0                      512M             disk        [SWAP]
zram1                        3G             disk        /tmp

# swapon -s
Filename                                Type            Size    Used    Priority
/dev/zram0                              partition       524284  0       16383
/dev/dm-4                               partition       2093052 0       -1

# cat /etc/initramfs-tools/conf.d/resume
RESUME=/dev/mapper/debian_laptop-swap

When the /dev/zram0 device is empty, the hybrid-sleep/hibernation works, but when it stats to collect data, then the three possible things can happen:

  1. hybrid-sleep/hibernation doesn't work as described in this topic

  2. when I try to hibernate from a terminal, I can get this message:

    Failed to hibernate system via logind: Sleep verb not supported

  3. The system can hang itself while trying to hibernate.

What will actually happen depends on the amount of data collected by the ZRAM device.

There's also another thing worth mentioning. When I get the above message, and I issue again: systemctl hibernate from the terminal, it always try to hibernate and hangs my laptop, but the message doesn't appear again. When I empty the ZRAM device, and try to hibernate, it works as expected.

It looks like the problem only affects hibernation/hybrid-sleep. Suspending works even when the ZRAM device is nearly full.

Is it a bug, or hibernation shouldn't be used when ZRAM is used?

@poettering
Copy link
Member

I have no idea, sounds unrelated to systemd though, please talk to zram and hibernation kernel folks. Closing.

@poettering poettering added not-our-bug and removed login needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer labels Oct 19, 2015
@LeifW
Copy link

LeifW commented Oct 20, 2015

Seems the systemd issue is versions > 225 changing to think the system is docked.
When I boot with the default config in 226 or 227 with "debug" on the kernel line, I get that same "System is docked" message in the logs when I close the lid, and no suspend. most defintely am not docket, and that's a change in behavior from 225.
I can add the "HandleLidSwitchDocked=suspend" line to fix that, now that I know what it is (the default for that event is ignore). Seems that could be an issue for people wishing to distinguish between the lid switch events while docked vs undocked, though.

@LeifW
Copy link

LeifW commented Oct 20, 2015

FWIW, my laptop is only showing the internal display connected:
grep . /sys/class/drm/*/status

/sys/class/drm/card0-DP-1/status:disconnected
/sys/class/drm/card0-HDMI-A-1/status:disconnected
/sys/class/drm/card0-LVDS-1/status:connected
/sys/class/drm/card0-VGA-1/status:disconnected

@NoSuck
Copy link

NoSuck commented Nov 26, 2015

I have been experiencing a similar issue. Running systemctl hibernate invariably results in Failed to hibernate system via logind: Sleep verb not supported. I have no zram devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants