Suspend/resume cycling on system resume

After upgrading to nixpkgs ~18324978d632ffc55ef1d928e81630c620f4f447 (when I first noticed the issue), my system is unable to effectively resume from sleep. When I resume the system, it will forcibly re-suspend itself… until it doesn’t. It usually takes between 3-10 attempts for system to stay awake, with anywhere from 5-30 seconds between resumes and re-suspends.

In the journalctl logs below, you’ll see:

Aug 29 10:47:59 nixos systemd-sleep[137498]: System returned from sleep state.
...
Aug 29 10:48:23 nixos systemd-logind[1156]: The system will suspend now!

Not sure where to start with debugging, since the journal doesn’t (to me) show any obvious kernel/login errors.


Relevant details from neofetch:

OS: NixOS 23.11.20230827.a999c1c (Tapir) x86_64
Kernel: 6.1.47
DE: GNOME 44.3
WM: Mutter
CPU: AMD Ryzen 7 2700X (16) @ 3.700GHz
GPU: NVIDIA GeForce RTX 3060 Ti


Here’s the bits of my configuration.nix relating to graphics & DE config:

{
  boot.kernelModules = [
    "nvidia"
  ];

  hardware.nvidia = {
    modesetting.enable = true;
    powerManagement.enable = true;
  };

  hardware.opengl = {
    enable = true;

    driSupport = true;
    driSupport32Bit = true;

    extraPackages = with pkgs; [
      nvidia-vaapi-driver
    ];
  };

  services.xserver = {
    enable = true;

    videoDrivers = [ "nvidia" ];

    desktopManager.gnome.enable = true;
    displayManager.gdm.enable = true;
  };
}

Here’s my full journalctl, starting from the suspend last night, resume this morning, and subsequent 8-ish suspend/resume cycles: https://fars.ee/fH2w

1 Like

Did you ever find a solution to this problem? I think I have the same issue… I also have a NVIDIA GPU, and I could be wrong, but I don’t remember having this problem prior to adding NVIDIA into my configuration. I had a look in my journalctl, but I couldn’t see any information to track down the root cause.

OS: NixOS 23.11.20231201.5de0b32 (Tapir) x86_64 
Host: ASRock Z370M-ITX/ac 
Kernel: 6.1.64 
Uptime: 4 hours, 13 mins 
Packages: 952 (nix-system), 405 (nix-user) 
Shell: fish 3.6.1 
Resolution: 2560x1440, 2560x1440 
DE: GNOME 45.1 (Wayland) 
WM: Mutter 
WM Theme: Adwaita 
Theme: Adwaita [GTK2/3] 
Icons: Adwaita [GTK2/3] 
Terminal: kgx 
CPU: Intel i5-8600K (6) @ 4.300GHz 
GPU: NVIDIA GeForce GTX 1060 6GB 
Memory: 3465MiB / 15937MiB

I have slowly narrowed the issue down, and have lodged an issue with the GNOME team. Please see the linked issue for additional information and to help narrow down whether we have the same problem. For me, it looks to be an issue with the power plugin of the gnome-settings-daemon.

I’ve also experienced this periodically. I’ve just discovered Suspend in multiseat not working correctly: One seat causes the entire installation to go into suspend mode (#611) · Issues · GNOME / gnome-settings-daemon · GitLab and wonder if this could be the cause. I have multiple systems and the bug does not manifest on all of them, but I’ve noticed it manifests on a system with multiple users logged in, so I’m wondering if that could be a missing piece of the puzzle. Do you have multiple users logged in also, perhaps?

I have the same issue, but for me powerManagement.enable = true; seems to be the culprit. When I set it to false I no longer have suspend/resume cycles.

1 Like

Confirming hardware.nvidia.powerManagement.enable = false; fixes the suspend/resume cycles — but I forgot I’d turned that on in the first place to fix app crashes on resume :frowning:

https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks#Preserve_video_memory_after_suspend

Having to restart an app or two is better than rendering the entire computer unusable, I suppose?

I wonder if it is a NixOS specific thing or a NVIDIA thing.

It was also discontinued on amd graphics as well. And, even if I reboot, it stops.

Almost all people affected who commented in the GNOME issues are using NixOS, so I believe that it is a NixOS specific thing. That being said, it is strange, because I couldn’t find any related patches in nixpkgs. I reported the issue on nixpkgs: Suspend/resume loop on GNOME with `hardware.nvidia.powerManagement` enabled · Issue #336723 · NixOS/nixpkgs · GitHub

Just ran into the same problem. Running Gnome and AMD GPU (one machine has dGPU and another iGPU, both have encountered this problem). KDE doesn’t have this issue. The last working revision for me is 76612b17c0ce71689921ca12d9ffdc9c23ce40b2.

Well, it got worse for me. With 24.11 and the 560 drivers I run into unrecoverable situations after resuming (blank screen, crashing applications) without power management. So now I have to enable power management which confronts me in with the suspend/resume cycle bug :slightly_frowning_face:

I might have found something. Based on this post [Solved] Suspend is failing with nvidia and wayland. / Newbie Corner / Arch Linux Forums

I added this to my configuration.nix:

  systemd = {
     services."gnome-suspend" = {
      description = "suspend gnome shell";
      before = [
        "systemd-suspend.service" 
        "systemd-hibernate.service"
        "nvidia-suspend.service"
        "nvidia-hibernate.service"
      ];
      wantedBy = [
        "systemd-suspend.service"
        "systemd-hibernate.service"
      ];
      serviceConfig = {
        Type = "oneshot";
        ExecStart = ''${pkgs.procps}/bin/pkill -f -STOP ${pkgs.gnome-shell}/bin/gnome-shell'';
      };
    };
    services."gnome-resume" = {
      description = "resume gnome shell";
      after = [
        "systemd-suspend.service" 
        "systemd-hibernate.service"
        "nvidia-resume.service"
      ];
      wantedBy = [
        "systemd-suspend.service"
        "systemd-hibernate.service"
      ];
      serviceConfig = {
        Type = "oneshot";
        ExecStart = ''${pkgs.procps}/bin/pkill -f -CONT ${pkgs.gnome-shell}/bin/gnome-shell'';
      };
    };
  };

I have tested it a couple of times, no more suspend/resume cycles for me with power management enabled, well at least for now, I hope it stays this way.

Also I think for this to work you need to add killall to your installed packages if you haven’t. Don’t know why it isn’t there by default but whatever. EDIT: it seems pkill is the tool of choice these days. I changed the script to use that and also specified the exact name of the gnome-shell process.

Can someone check if this works?

3 Likes

It works for me, on 24.11, a 13th gen intel CPU and an rtx 4060 mobile. Seems promising.

Yep, this works for me, for the most part — no more suspend/resume cycles or app crashes on resume.

  • The system is a bit lethargic on resume; it takes ~30-45 seconds to present the GDM greeter, and some apps are unresponsive for ~15 seconds after that. Everything is normal after that all settles
  • My display is blanking after ~30 seconds of no input. I have my screen blank set to 10 minutes, and I’ve tried toggling the setting, but no luck. (EDIT: I also tried turning off screen blank entirely, but it still blanks after 30 seconds…) There is nothing in journalctl/dmesg besides a warning from gdm-x-session regarding dropped events from my mouse.

Also, I’m using X, not Wayland, so this does seem to be a cross-protocol issue.

Relevant looking gnome-settings-daemon bug; the screen blanking is cause by some interaction in gnome-settings daemon. I don’t yet understand why I see this on one machine but not on a different machine (The nvidia machine experiences, the amdgpu machine does not, but this may be circumstantial/unrealted to the GPU, and something odd about the configuration).

With the hanging on resume, there are open issues in the nvidia driver ecosystem:

I haven’t yet found a working configuration on wayland. Currently tested 6.6.66 and 6.12 with 565.77 open drivers on a GTX 3060.

Thanks! I was having the problem for couple weeks and your solutions works on a Thinkpad P15v gen3 with Ryzen 6000H processor with nvidia T600 gpu.