swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.53k stars 1.11k forks source link

Unexpected shutdown of the laptop when the screen is turned off #6110

Closed ghost closed 3 months ago

ghost commented 3 years ago

Laptop: 20Q0000MRT ThinkPad X390 OS: Arch Linux Linux kernel: 5.11.6-arch1-1

$ pacman -Q | grep sway sway 1:1.5.1-1 swaybg 1.0-4 swayidle 1.6-1 swaylock 1.5-1

swaymsg -t get_version sway version 1.5.1

My sway config

I have a very strange behavior of the screen off mode.

When I run swayidle with the following script:

#!/bin/bash
swayidle -w \
  timeout  5 'swaylock -f -i ~/.bin/lock.png' \
  timeout  10 'swaymsg "output * dpms off"' \
      resume  'swaymsg "output * dpms on"' \
  before-sleep 'swaylock -f -i ~/.bin/lock.png'

my laptop (after turning off the screen) shuts down unexpectedly in the interval (5-15 minutes).

There are no shutdown events in the journald log.

This behavior started with kernel 5.10 and continues to this day. There was no such behavior on linux-lts kernel 5.4.

emersion commented 3 years ago

Maybe related to logind automagically doing stuff behind our back. Or could also be a kernel bug, I suppose.

kennylevinsen commented 3 years ago

Yeah, I'd also suspect logind actions, possibly combined with a failed suspend/hibernate attempt. Start out by setting all actions in /etc/systemd/logind.conf to Ignore, including those that might not seem relevant, and see if that makes a difference.

ghost commented 3 years ago

I also thought about logind at first. But I have default settings:

cat /etc/systemd/logind.conf
#  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.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the system.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See logind.conf(5) for details.

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#HandleRebootKey=reboot
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#RebootKeyIgnoreInhibited=no
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RuntimeDirectoryInodes=400k
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192

And when I use this script (without turning off the screen, just lock) - everything is ok. No shutdown

swayidle -w \
  timeout  5 'swaylock -f -i ~/.bin/lock.png' \
  before-sleep 'swaylock -f -i ~/.bin/lock.png'
kennylevinsen commented 3 years ago

I also thought about logind at first. But I have default settings

The defaults tend to cause problems.

ghost commented 3 years ago

@kennylevinsen which of the default values of the /etc/systemd/logind.conf (in your opinion) can have such an effect?

I remind you that if the screen does not turn off (dpms), then everything is fine.

In addition, if the shutdown had been caused by logind, it would have been displayed in the journald log.

kennylevinsen commented 3 years ago

@kennylevinsen which of the default values of the /etc/systemd/logind.conf (in your opinion) can have such an effect?

Any that isn't "ignore". Things like external monitor detection tend to break when displays go to sleep for example, leading to unexpected rule execution. There isn't really a point in having logind do any of this anyway.

Point is - it's known to be fragile, so ruling it out would be useful.

ghost commented 3 years ago

I don't connect any external monitors

I tried to specify this value: IdleAction=ignore

But the problem continues.

But, when I set "CPU power management" to "disable" in the BIOS, the problem was solved.

I don't understand where the problem is yet :(

kennylevinsen commented 3 years ago

Are you undervolting perhaps? I imagine you're either crashing in a lower power state, or failing a suspend attempt. Remember that the journal is useless if you're crashing, as you can't rely on writes being flushed.

I tried to specify this value

All the Handle and Action fields please. :)

ghost commented 3 years ago

@kennylevinsen

I set the following parameters:

HandlePowerKey=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
HandleRebootKey=ignore
IdleAction=ignore

And that didn't solve the problem. The laptop continues to shut down unexpectedly when the screen is turned off :(

neurlang commented 3 years ago

@dgpat

I had a similar unexpected shutdown problem, but on desktop pc.

It happened only on Linux, Windows ran fine.

The cause turned out to be not 100% attached cpu heat sink.

Edit: try running a cpu intensive task to see if it shutdowns unexpectedly

Edit 2: if some process does a shutdown there will be a line added to a kernel log, in case the problem is hardware specific, there won't be any such line, the computer will just shutdown. Hope this info will help you. Another piece of information is that some Linux distros tends to have a lots of ir remote control drivers, if such a driver is buggy it may be pressing the power down key randomly, the computer will shutdown unexpectedly (while logging the shutdown message to the log).

ghost commented 3 years ago

@neurlang thanks for reply! But I already wrote that the computer shutdown in IDLE mode. And shutdown happens when the screen turns off (DPMS). When the screen remains on, the laptop DOES NOT UNEXPECTED SHUTDOWN.

languitar commented 3 years ago

One think I noticed: I have my laptop under my desk with its lid closed, only using external monitors. If swayidle turns of the external screens, the lid detection kicks in and starts to suspend the laptop.

sachinchaudhary1808 commented 3 months ago

same issue lol

kennylevinsen commented 3 months ago

I'll close this as it is unrelated to sway and swayidle.

sachinchaudhary1808 commented 3 months ago

I'll close this as it is unrelated to sway and swayidle.

well for now i have installed hyprlock and if i encounter that issues again i will report you

kennylevinsen commented 3 months ago

Even if it happens with hyprlock it is still unrelated to sway and swayidle. The most likely cause is logind configuration, other system configuration, or a kernel panic.

The only way sway or swayidle would ever shut down your computer is if you explicitly tell them to run "poweroff" or similar command.

sachinchaudhary1808 commented 3 months ago

Even if it happens with hyprlock it is still unrelated to sway and swayidle. The most likely cause is logind configuration, other system configuration, or a kernel panic.

The only way sway or swayidle would ever shut down your computer is if you explicitly tell them to run "poweroff" or similar command.

ok u are right i found the cuz it was dpms miss configuration sorry