TamtamHero / fw-fanctrl

A simple systemd service to better control Framework Laptop's fan(s)
BSD 3-Clause "New" or "Revised" License
178 stars 33 forks source link

Issues with suspend-then-hibernate due to script in /usr/lib/systemd/system-sleep/ #13

Closed galfwender closed 2 months ago

galfwender commented 1 year ago

If I use suspend-then-hibernate, e.g. "systemctl suspend-then-hibernate" I observe that it takes up to 90 seconds to successfully suspend, and 90 seconds again to wake up.

If I use suspend e.g. "systemctl suspend" or hybrid-sleep e.g. "systemctl hybrid-sleep", the laptop suspends and wakes in just a couple of seconds.

If I remove /usr/lib/systemd/system-sleep/fw-fanctrl-suspend, the issue goes away. I have no idea why, as running the command "runuser -l myuser -c "fw-fanctrl sleep" returns instantly.

galfwender commented 1 year ago

I have no such issue if I modify the script to use "sudo -u username -i cmd" instead.

TamtamHero commented 1 year ago

I tried both and it works the same on my machine (Ubuntu 22.04) Not sure how to investigate that :/

leopoldhub commented 3 months ago

Hi @galfwender , We recently did a consequent refactoring of our codebase, is this issue still present in the latest version?

KaranveerB commented 3 months ago

Installed via AUR so take this with a grain of salt.

Having this issue as well including on the newest version. Journalctl shows a pam_systemd(login:session): Failed to create session: Connection timed out error near where it happens. The logs around it are a bit inconsistent in what they show, but I've seen the following which seem relevant to debugging the issue

May 21 18:43:45 HOSTNAME systemd-logind[1080]: Power key pressed short.
May 21 18:43:45 HOSTNAME kernel: mei_pxp 0000:00:16.0-fbf6fcf1-96cf-4e2e-a6a6-1bab8cbe36b1: bound 0000:00:02.0 (ops i915_pxp_tee_component_ops [i915])
May 21 18:43:45 HOSTNAME kernel: cros_ec_lpcs cros_ec_lpcs.0: bad packet checksum 3b
May 21 18:43:45 HOSTNAME python3[15060]: EC returned error result code 7
May 21 18:43:45 HOSTNAME python3[15060]: EC returned error result code 12
May 21 18:43:45 HOSTNAME python3[15060]: EC response has invalid checksum
May 21 18:43:45 HOSTNAME python3[15060]: EC returned error result code 7
May 21 18:43:45 HOSTNAME python3[15060]: EC returned error result code 7
May 21 18:43:45 HOSTNAME systemd-sleep[14637]: System returned from sleep operation 'suspend-then-hibernate'.
May 21 18:43:45 HOSTNAME kernel: PM: suspend exit
May 21 18:43:45 HOSTNAME systemd-sleep[15089]: logname: no login name
May 21 18:43:45 HOSTNAME runuser[15096]: pam_unix(runuser-l:session): session opened for user root(uid=0) by root(uid=0)
May 21 18:44:15 HOSTNAME runuser[14654]: pam_systemd(runuser-l:session): Failed to create session: Connection timed out
May 21 18:44:15 HOSTNAME systemd-sleep[15397]: Success
May 21 18:44:15 HOSTNAME runuser[14654]: pam_unix(runuser-l:session): session closed for user root
May 21 18:45:15 HOSTNAME systemd[1]: systemd-suspend-then-hibernate.service: Deactivated successfully.
May 21 18:45:15 HOSTNAME systemd[1]: Finished System Suspend then Hibernate.
May 21 18:45:15 HOSTNAME systemd[1]: systemd-suspend-then-hibernate.service: Consumed 1.301s CPU time.
May 21 18:45:15 HOSTNAME systemd[1]: Stopped target Sleep.
May 21 18:45:15 HOSTNAME systemd[1]: Reached target Suspend; Hibernate if not used for a period of time.
May 21 18:45:15 HOSTNAME systemd-logind[1080]: Operation 'suspend-then-hibernate' finished.

I've also seen things like this though this was with an older version

May 21 17:56:02 HOSTNAME runuser[2861]: pam_systemd(runuser-l:session): Failed to create session: Connection timed out
May 21 17:56:02 HOSTNAME systemd-sleep[3296]: Traceback (most recent call last):
May 21 17:56:02 HOSTNAME systemd-sleep[3296]:   File "/usr/bin/fw-fanctrl", line 321, in <module>
May 21 17:56:02 HOSTNAME systemd-sleep[3296]:     main()
May 21 17:56:02 HOSTNAME systemd-sleep[3296]:   File "/usr/bin/fw-fanctrl", line 302, in main
May 21 17:56:02 HOSTNAME systemd-sleep[3296]:     client_socket.connect(COMMANDS_SOCKET_FILE_PATH)
May 21 17:56:02 HOSTNAME systemd-sleep[3296]: FileNotFoundError: [Errno 2] No such file or directory
May 21 17:56:02 HOSTNAME runuser[2861]: pam_unix(runuser-l:session): session closed for user root
May 21 17:57:02 HOSTNAME systemd[1]: systemd-suspend-then-hibernate.service: Deactivated successfully.
May 21 17:57:02 HOSTNAME systemd[1]: Finished System Suspend then Hibernate.
May 21 17:57:02 HOSTNAME systemd[1]: systemd-suspend-then-hibernate.service: Consumed 4.417s CPU time.
May 21 17:57:02 HOSTNAME systemd[1]: Stopped target Sleep.
May 21 17:57:02 HOSTNAME systemd[1]: Reached target Suspend; Hibernate if not used for a period of time.
May 21 17:57:02 HOSTNAME systemd[1]: Stopped target Suspend; Hibernate if not used for a period of time.

Don't want to do too more much investigation because the long login times are quite annoying to test, but I'm happy to give more information or to test fixes.

System is Framework 12th gen Intel, Arch Linux kernel 6.9.1-arch1-1, systemd version 255 (255.6-1-arch). Issue is fairly consistent for me, but isn't 100% occurence. I've only seen the issue occur with suspend-then-hibernate both when resuming from suspend and from hibernate.

leopoldhub commented 3 months ago

Hi, There seems to be a problem with the runuser -l command. It is no longer used in the latest commit and is most likely still here due to the AUR package. We are currently working on a PR (#37 ) with the AUR package maintainer (@icedream ) to create a long term solution for packaging. Your issue will most likely be resolved in the next AUR version, to test if it will be the case, you can try installing the program via the install script and check if you still have the issue. I will let you know when the pr is merged. Have a nice day.

KaranveerB commented 3 months ago

You're right. Installed via the install script and it works properly now. Sorry for not trying that first before saying I had the issue as well.