Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Suspend / resume on NVIDIA w. OpenRC
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
sunox
Tux's lil' helper
Tux's lil' helper


Joined: 26 Jan 2022
Posts: 136

PostPosted: Sun Jan 21, 2024 4:45 pm    Post subject: Suspend / resume on NVIDIA w. OpenRC Reply with quote

I'm just wondering if suspend/resume with nvidia-drivers using OpenRC has been figured out yet.

I have been able to suspend and resume successfully for the past few weeks, but my windows would all be empty on resume, and to get the content to come back I would have to interact with the window e.g. scroll a bit.

This was my semi-working configuration:

I had the NVreg_PreserveVideoMemoryAllocations=0 commented out in /etc/modprobe.d/nvidia.conf, and I have NVreg_PreserveVideoMemoryAllocations=1 set as a kernel parameter. It seems this kernel parameter does not apply, because in /proc/driver/nvidia/params there is a line PreserveVideoMemoryAllocations: 0. (Very weirdly, when testing later I noticed a change what happens during suspend/resume if I had the "=0" line in nvidia.conf uncommented.)

I had stupidly copied over the nvidia.sleep.sh script from /usr/bin into /lib64/elogind/system-sleep and did no modifications to it. The script would just fail after running the first few lines as the argument "pre" doesn't match anything.

So in short, I think I did nothing besides commenting a line out in nvidia.conf and adding a kernel parameter line that I think (?) had no effect.

This morning I started to experiment with the nvidia-sleep.sh script which gets called when I do loginctl suspend. I got it to write "suspend" to /proc/driver/nvidia/suspend when suspending, and "resume" when resuming. Unfortunately I was never able to get it to work. The best I've been able to do was to resume to a frozen desktop showing my wallpaper. That was from following the script given in the last post here (https://forums.gentoo.org/viewtopic-t-1133268-highlight-.html), which was inspired by something in this bug report (https://bugs.gentoo.org/693384). One time somehow the graphical session was on a different tty than the one it was launched from, and I could go to the original tty and see the wayland compositor was complaining of broken pipes.

Another very weird thing is I can't seem to get it back to the semi-broken-but-still-ok-I-guess state it was in a few hours ago, even though I am fairly certain I have undone all changes. At this point I would be happy-ish just getting back to the old state.

Any advice on this complicated issue really appreciated.
Back to top
View user's profile Send private message
sunox
Tux's lil' helper
Tux's lil' helper


Joined: 26 Jan 2022
Posts: 136

PostPosted: Sun Jan 21, 2024 5:16 pm    Post subject: Reply with quote

If I just do "echo mem | sudo tee /sys/power/state" I get exactly the same suspend/resume behaviour I had before I started today: Empty windows that have to be interacted with before they repopulate. I used to get this behaviour with loginctl suspend. I guess this might be some sort of clue.

Edit: I got back to my old state by complete fluke. I had an elogind script in system-sleep that unbind-ed the drivers on a usb hub on my motherboard while suspending and then binds them again on resume. This was because a while ago my system would resume quickly after suspending and I traced it back to devices on this usb hub. Anyway somehow if I do not have this script in system-sleep loginctl suspend will just seemingly turn the screen off but not suspend.

I guess I can go back to experimenting with custom scripts etc. now that I think this was getting in the way earlier.

Again advice welcome during this troubling time of partially broken suspend/resume.


Last edited by sunox on Sun Jan 21, 2024 5:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21724

PostPosted: Sun Jan 21, 2024 5:22 pm    Post subject: Reply with quote

echo mem > /sys/power/state instructs the kernel to enter suspend-to-RAM. The kernel will notify all relevant drivers on the way down, and on the way back up. Your problem looks to me like the nVidia driver does not handle suspend well, and needed the application to explicitly redraw the window because the original contents had been lost. Does this work properly if you blacklist the nVidia driver and use Nouveau? What version of the nVidia drivers are you using, and on what kernel?
Back to top
View user's profile Send private message
sunox
Tux's lil' helper
Tux's lil' helper


Joined: 26 Jan 2022
Posts: 136

PostPosted: Sun Jan 21, 2024 5:26 pm    Post subject: Reply with quote

I'm on the stable 535 driver and I'm on the newest kernel 6.7.1.

I might try to call the custom nvidia suspend scripts again, and play around with differenet preservememoryallocation values.
Back to top
View user's profile Send private message
eeckwrk99
Apprentice
Apprentice


Joined: 14 Mar 2021
Posts: 165
Location: Gentoo forums

PostPosted: Sun Jan 21, 2024 5:46 pm    Post subject: Reply with quote

sunox wrote:
I'm on the stable 535 driver and I'm on the newest kernel 6.7.1.

I might try to call the custom nvidia suspend scripts again, and play around with differenet preservememoryallocation values.

What card do you have? Suspend/hibernate is broken for some GTX 970 and users (including me) with 6.6/6.7 kernel and/or 545 NVIDIA drivers. No issue with 6.1 kernel and 535.
As far as I'm concerned, I never got resuming from suspend/hibernate working with PreserveVideoMemoryAllocation=1, regardless of the NVIDIA driver version.
Back to top
View user's profile Send private message
sunox
Tux's lil' helper
Tux's lil' helper


Joined: 26 Jan 2022
Posts: 136

PostPosted: Sun Jan 21, 2024 5:49 pm    Post subject: Reply with quote

I was actually able to get it to work. The last thing I did was switch to the proprietary kernel modules and set the 'preserve memory' option as a kernel parameter. I am not sure which of these did the trick, but I suspect the former. Maybe it was both.

So in case anyone else stumbles on this here is my configuration. Of course some of these might be unnecessary (esp. #5).

1. Comment out the NVreg_PreserveVideoMemoryAllocations=0 " in /etc/modprobe.d/nvidia.conf
2. Put nvidia.NVreg_PreserveVideoMemoryAllocations=1 in kernel commandline.
3. Put this script in /lib64/elogind/system-sleep:
Code:

#!/bin/sh
case "${1-}" in
    'pre')
   /usr/bin/nvidia-sleep.sh suspend
        ;;

    'post')
   /usr/bin/nvidia-sleep.sh resume &
        ;;
    *)
        exit 1
        ;;
esac

4. Use proprietary kernel module
5. I have a script that, on suspend, unbinds the driver of a USB hub that was somehow preventing the system from suspending (screen would go black but other hardware showed no sign of change), and then rebinds it on resume.


For context I am using Hyprland wayland compositor.

If I hadn't added this script for some random other problem then I would have never figured out what was preventing suspend, and I likely never would have had working suspend on nvidia. How weird.


Last edited by sunox on Sun Jan 21, 2024 9:50 pm; edited 18 times in total
Back to top
View user's profile Send private message
sunox
Tux's lil' helper
Tux's lil' helper


Joined: 26 Jan 2022
Posts: 136

PostPosted: Sun Jan 21, 2024 5:51 pm    Post subject: Reply with quote

PreserveVideoMemoryAllocation=1 is requested by my Wayland compositor https://wiki.hyprland.org/Nvidia/#fixing-suspendwakeup-issues. Maybe this is a wayland thing, or something specific to that compositor.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum