Laptops hibernates with screen on (like sleeping with the eyes open)

Hi

When I hibernate the system with sudo systemctl hibernate the screen and keyboard light stay on. The laptop looks like it froze but I can force shut off by holding the power button and when I turn it on again everything comes back as I expect it (it works).

I’m running with the NVIDIA discrete GPU disabled (I don’t need it) by doing:

hardware.nvidiaOptimus.disable = true;

Nothing else:

boot.initrd.availableKernelModules = [ “xhci_pci” “thunderbolt” “vmd” “nvme” “usb_storage” “rtsx_pci_sdmmc” ];
boot.initrd.kernelModules = [ “dm-snapshot” ];
boot.kernelModules = [ “kvm-intel” ];
boot.extraModulePackages = [ ];

And the latest kernel available on NixOS 22.11 (6.0.9):

boot.kernelPackages = pkgs.linuxPackages_latest;

I found these on the journal:

Dec 02 19:31:37 hostname systemd[1]: Starting Pre-Sleep Actions…
Dec 02 19:31:37 hostname systemd[1]: pre-sleep.service: Deactivated successfully.
Dec 02 19:31:37 hostname systemd[1]: Finished Pre-Sleep Actions.
Dec 02 19:31:37 hostname systemd[1]: Reached target Sleep.
Dec 02 19:31:37 hostname systemd[1]: Starting Hibernate…
Dec 02 19:31:37 hostname systemd-sleep[602148]: Entering sleep state ‘hibernate’…
Dec 02 19:31:37 hostname kernel: PM: hibernation: hibernation entry
Dec 02 19:31:37 hostname kernel: bbswitch: enabling discrete graphics
Dec 02 19:31:37 hostname kernel: pci 0000:01:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dec 02 19:31:37 hostname kernel: pci 0000:01:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dec 02 22:09:03 hostname kernel: Filesystems sync: 0.010 seconds
Dec 02 22:09:03 hostname kernel: Freezing user space processes … (elapsed 0.001 seconds) done.
Dec 02 22:09:03 hostname kernel: OOM killer disabled.

Why is bbswictch trying to turn the GPU on after it turned it off during the boot process ?

[fmaste@hostname:~]$ sudo systemctl status bbswitch.service
● bbswitch.service - Disable NVIDIA Card
Loaded: loaded (/etc/systemd/system/bbswitch.service; enabled; preset: enabled)
Active: active (exited) since Fri 2022-12-02 15:11:03 UTC; 10h ago
Process: 2855 ExecStart=/nix/store/y8fws7bq1v3f6pidnayjkvs13innnjw4-bbswitch-unstable-20>
Main PID: 2855 (code=exited, status=0/SUCCESS)
IP: 0B in, 0B out
CPU: 29ms

Dec 02 15:11:03 hostname systemd[1]: Starting Disable NVIDIA Card…
Dec 02 15:11:03 hostname systemd[1]: Finished Disable NVIDIA Card.

I haven’t enabled any other config option related to GPU/Optimus/Prime/video/etc, just:

services.xserver.displayManager.startx.enable = true;
services.xserver.windowManager.xmonad = {…};

Output of lspci shows:

0000:00:02.0 VGA compatible controller: Intel Corporation TigerLake-H GT1 [UHD Graphics] (rev 01)
0000:01:00.0 3D controller: NVIDIA Corporation GA107GLM [RTX A2000 Mobile] (rev a1)

Thanks!!!

Try blacklisting the kernel modules, in case this is nouveau having some fun? nixos-hardware has a module to disable nvidia that does this: nixos-hardware/disable.nix at 7883883d135ce5b7eae5dce4bfa12262b85c1c46 · NixOS/nixos-hardware · GitHub

1 Like

Thanks!

The hardware.nvidiaOptimus.disable option is already doing that:

$ cat /etc/modprobe.d/nixos.conf
blacklist firewire_ohci
blacklist firewire_core
blacklist firewire_sbp2
blacklist nouveau
blacklist nvidia
blacklist nvidiafb
blacklist nvidia-drm

But maybe you are right, because it also adds a bbswitch service to disable the Nvidia GPU that can be causing the problem.

I also found this on the ArchWiki and I have to try it. Changing /etc/systemd/sleep.conf.d/hibernatemode.conf should be a NixOS option?

Fun, I suppose that means the nvidia hardware blacklist is superfluous, and this is a bug. I don’t have an iGPU, so I sadly couldn’t test those modules when I touched them. You can probably make the bbswitch module stop attempting to turn on the GPU on hibernate using something like:

systemd.services.bbswitch.serviceConfig.ExecStop = null;

If that works it’s nixpkgs PR time.

You can set that with systemd.sleep.extraConfig.

1 Like

Thanks!

With systemd.sleep.extraConfig = "HibernateMode=shutdown"; now the laptop hibernates after a screen blink, were the display turns on again to finally to shut everything down completely.

The question is: Is this a bug or a feature? Why would anyone want to hibernate without shutting down?

pd. For a new topic/post, now it resumes with a frozen mouse, no touchpad!