Wayland/modesetting on Nvidia

With the latest Nvidia drivers it seems that modesetting and Wayland work fine for Gnome and GDM.

Console text is still a normal console, but upon boot you get the native screen resolution in Plymouth and then you can login under both X.org and Wayland sessions.

Screenshot-from-2020-07-11-08-06-56

How to test? Make sure that you have the following line enabled for the nvidia-drm module:

# cat /usr/lib/modprobe.d/nvidia.conf | grep drm
options nvidia-drm modeset=1

And then make sure to comment out the following line in the udev rules supplied by GDM:

# cat /usr/lib/udev/rules.d/61-gdm.rules | grep -i nvidia
# disable Wayland when using the proprietary nvidia driver
#DRIVER=="nvidia", RUN+="/usr/libexec/gdm-disable-wayland"

Then reboot, and you will login with a Wayland session by default:

# cat /sys/module/nvidia_drm/parameters/modeset 
Y
# cat /sys/module/nvidia_drm/version 
450.57
$ lsmod | grep nvidia
nvidia_drm             57344  4
nvidia_modeset       1187840  3 nvidia_drm
nvidia_uvm           1130496  0
nvidia              19726336  208 nvidia_uvm,nvidia_modeset
drm_kms_helper        249856  1 nvidia_drm
drm                   618496  7 drm_kms_helper,nvidia_drm
$ env | grep XDG_SESSION_TYPE
XDG_SESSION_TYPE=wayland
$ lspci | grep -i vga
01:00.0 VGA compatible controller: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] (rev a1)

37 thoughts to “Wayland/modesetting on Nvidia”

  1. So the 470 driver does it when fully enabled. There’s a requirements section in the driver readme since at this time the majority of people no do have all the required bits. But reaching those requirements, Wayland is working well.

    But games now work in Wayland. The nvidia-settings is noted to not work at this time and various other issues are present.

  2. It has improved a bit with the latest driver. The display may now show up on Wayland with pre-game setup windows and games may even start to some extent but fail to work properly. I’m hoping the future 470 driver will do the rest.

  3. Any idea about Nvidia Optimus(Intel UHD + Nvidia Proprietary) + Fedora Gnome Wayland?
    Intel as primary GPU ofcourse!

  4. Side note.

    There’s some possible corruption with X11 resume as well after enabling the nvidia stuff found here. So don’t do the suspend resume stuff unless you don’t care. It is annoying if you leave stuff open.

  5. Mmmh… yes, that’s weird. It seems something is missing on my installation, even though both (mine and yours) come from the same source (negativo17.org). Intriguing… My installed Nvidia packages are:

    rpm -qa | grep -i nvidia | sort
    akmod-nvidia-450.57-1.fc32.x86_64
    kmod-nvidia-5.7.12-200.fc32.x86_64-450.57-1.fc32.x86_64
    kmod-nvidia-5.7.14-200.fc32.x86_64-450.57-1.fc32.x86_64
    kmod-nvidia-5.7.15-200.fc32.x86_64-450.57-1.fc32.x86_64
    nvidia-driver-450.57-1.fc32.x86_64
    nvidia-driver-libs-450.57-1.fc32.x86_64
    nvidia-kmod-common-450.57-1.fc32.noarch
    nvidia-libXNVCtrl-450.57-1.fc32.x86_64
    nvidia-settings-450.57-1.fc32.x86_64

    Would you mind comparing this with output with the same command on your system? Maybe that will give us a clue on what’s different.

    1. No, actually I use Nvidia’s .run file directly 🙂

      Running “rpm -qa | grep -i nvidia | sort” is just blank for me. I can’t help you with that though I could rework to that and see what happens. Would rather not.

      Did you get the script right? What’s happening?

      1. Ah, I see, I thought you were using Simone’s rpms. No need to rework your installation — don’t mess with what’s working 😉

        Unfortunately, in my case, things went from bad to worse. Wayland loads up just fine, and everything seems to be in place — systemd, kernel module parameters etc. Suspend does seem to work, but it never resumes. The computer acts as if it is resuming, keyboard leds are responsive, but monitors remain in power save mode. After a while, keyboard stops responding. I can’t even run nvidia-bug-report.sh.

        That was disappointing, I was really thinking now this would work. I am reporting this on the Nvidia forum, hopefully devs will try to help me diagnose what’s happening.

        Anyway, thank you very much for your commitment to making this work 😉

        1. No prob

          I would have to assume that if you have everything correct then it would be from using Negativo17. But, I kind of expect that to generally work the same.

          Suppose it could be related to the gpu generation.

          The nvidia script I posted just calls the other one so I guess if it changed then the script is either working or not correctly done… I tested the paste and even though the quotes should be re-done directly on the system, it still worked so that shouldn’t be the problem.

          Hope you figure it out.

          1. I think I also see that black screen on resume randomly as well. Forgot that it happened once and just did it again.

  6. Yes, I am confused as well =} There is no /usr/share/doc/NVIDIA_GLX-1.0 on my system. Could you please provide the output for

    rpm -qf /usr/share/doc/NVIDIA_GLX-1.0

    ?

    1. $ rpm -qf /usr/share/doc/NVIDIA_GLX-1.0
      file /usr/share/doc/NVIDIA_GLX-1.0 is not owned by any package

      I don’t think that helps much. Tried a few other ways but nothing.

      Maybe this is a good explanation here? https://nvidia.custhelp.com/app/answers/detail/a_id/137/~/linux—editing-your-x-config-file

      “there is a sample config file included with the NVIDIA driver package (it gets installed in /usr/share/doc/NVIDIA_GLX-1.0/).”

      So you could try a quick reinstall of the drivers you use. If its still not there then maybe its not getting installed from those for some reason? Its kind of weird if it doesn’t but maybe something no one noticed.

    2. I will just post the script as well lol. Don’t know why I didn’t think about that.

      #!/bin/sh

      case “$1” in
      post)
      /usr/bin/nvidia-sleep.sh “resume”
      ;;
      esac

      Yes, that’s all it is. That gets it to you 😉

      Filename: “nvidia”

      1. Hahahaha… yes, why didn’t we think of it in the first place?! =) Thanks a lot! Now I will be able to try it out.

  7. It is working here, but display gets totally corrupted when resuming from suspend (F32, latest driver, running on my good old GTX 750 Ti). Anyone else experiencing this?

      1. Thanks for confirming that. Do you know if this is a general driver issue, or is it specific to Wayland / modesetting?

          1. Yes, I can confirm that, no issues with X11. I posted this on NVidia’s Linux forum [https://forums.developer.nvidia.com/t/resuming-from-suspend-issue-driver-450-57-fedora-32-modesetting-enabled-gtx-750-ti/146265], and Aaron Plattner just replied with some additional info. AFAICS there are some configurations missing that would be needed for suspend/resume to work properly (a missing script, missing module parameters, and required systemd services are disabled by default), hopefully Simone will be able to take a look at it.

    1. Hey, got it working. There’s still some corruption but it resumes. I’m waiting on an email for Nvidia account so will post this here. I’m using the proprietary driver though not Negativo17 or anything but I believe it will be the same. Also mixing in stuff from your Nvidia post.

      1) Install the service files and related and then enable the services [x]

      2) Get “$ cat /proc/driver/nvidia/params” to show “PreserveVideoMemoryAllocations=1” [x]
      This was a pain. I had to set “nvidia.PreserveVideoMemoryAllocations=1” with the kernel command line to get it to
      1. Nothing else was working for me and it is where I’m at now and it resumes much better with that.
      You can do this by rebooting and pressing e at grub for temporary or edit /etc/default/grub and remake the grub
      config for what you use either efi or boot eg “sudo grub2-mkconfig -o /boot/efi/grub.cfg”.

      misc:

      I believe the Nvidia doc is saying that s2idle should be showing [deep], not that it shouldn’t show s2idle. I don’t think this is a problem for me as it shows [deep].

      I don’t use “options nvidia NVreg_DynamicPowerManagement=0x02” but I guess that’s something you do or need. I put the “options nvidia-drm modeset=1” in there though but can also be done from the kernel command line.

      Maybe the corruption I have is what the Nvidia dev is talking about when he says “a bug where some video memory is not preserved correctly in some cases” but not sure.

      Currently that’s where I’m at with it. Its cool that you got the Nvidia dev to help with that.

      1. I always miss something. You may need to make sure if editing grub file that the kernel command line has the “nouveau.modeset=0” thing so nouveau doesn’t run and other stuff. I’m actually missing some something as I didn’t think about that but it works without whatever it was haha.

        Want to make that clear.

      2. Yes, that should be it 😉 woo

        1 & 2 above.

        The corruption can be worked around by logging out and back it. It only happens with random UI stuff that appears to not have been preserved.

      3. That’s awesome! I will try it here as well. One thing that I am currently missing is the /lib/systemd/system-sleep/nvidia script, where did you manage to find it?

        Thanks for the detailed info, specially with the PreserveVideoMemoryAllocations=1 kernel parameter. As for the NVreg_DynamicPowerManagement=0x02, I did not put it on /usr/lib/modprobe.d/nvidia.conf, it was already there AFAIK.

        And, yes, it is cool that Nvidia devs are actively working to improve Wayland support, and participate on the forums helping us =)

        1. “One thing that I am currently missing is the /lib/systemd/system-sleep/nvidia script, where did you manage to find it?”

          Maybe the driver install you do just doesn’t have it? I’m also confused with why you don’t have it.

          Should be right there in “/usr/share/doc/NVIDIA_GLX-1.0/samples/systemd/” and then do the “sudo install /usr/share/doc/NVIDIA_GLX-1.0/samples/systemd/nvidia /lib/systemd/system-sleep” to put it into “/lib/systemd/system-sleep/”. That’s all I did following the Nvidia doc.

          I guess the driver also put “NVreg_DynamicPowerManagement=0x02” in the conf file for you. Might as well keep it if its there 🙂

          1. Argh… I don’t know why, but my reply went to the top of the thread. I’ll repeat it here to make it easier to follow the conversation:

            Yes, I am confused as well =} There is no /usr/share/doc/NVIDIA_GLX-1.0 on my system. Could you please provide the output for

            rpm -qf /usr/share/doc/NVIDIA_GLX-1.0

            ?

      4. Whoops, just looked at is am I’m getting X11 corruption on resume when Chrome is left open since enabling this stuff.

        Anyway it is actually “nvidia.NVreg_PreserveVideoMemoryAllocations=1”

  8. Interesting. We are slowly getting towards the point that Wayland becomes usable also with Nvidia driver. I’ve tried this in the past and it has also previously occasionally worked. Currently Wayland is no good for me due to firefox (firefox-wayland) only showing a black screen and nvidia-settings doesn’t work at all, either.

    1. Fixed the Firefox black screen by doing a reset of Firefox. Now I need to figure out if there is a way to run wine/proton games without getting a grey screen. Still need a way to toggle refresh rate also for the buggy monitor of mine (when nvidia-settings isn’t working).

      1. Switched back to X11 for now, can’t find any fix for the old game + proton/wine + grey screen issue.

        1. I noticed in a native game that offers a pre-configuration that the display selection was missing my display. The game starts to black screen and is unplayable. Another native game has a Vulkan error and won’t start. This would of course also hit Proton and Wine. Probably other issues as well.

          So there’s definitely stuff still going on with Nvidia and Wayland before its usable for everything. Really great that its working as well as it does. I did start one older game that uses Wine and it worked fine so it doesn’t seem like its that far away.

          1. So it seems that the issue is sdl related and has been a problem for everyone who uses Wayland. There might be other issues as well but example “LD_PRELOAD=”/usr/lib64/libSDL2.so:/usr/lib/libSDL2.so:$LD_PRELOAD” SDL_VIDEODRIVER=x11 %command%” people tend to use that to play Steam games. It didn’t fix anything for me.

            Looks like a real mess there.

        2. So nvidia-settings is also not opening because of not finding the display. Same as the Vulkan issue I mentioned in the other reply. So that might just be the main issue with everything.

          Have to find out how the display is chosen when running Wayland aka something like xorg.conf. So far I can find nothing with others running into that problem previously but only just started looking.

          1. “nvidia-settings does not work with Wayland.”

            https://fedoraproject.org/wiki/How_to_debug_Wayland_problems

            Yeah, this has confused me a bit as I get this:

            “If you see loads of output (when compared to a standard run), the app is using Wayland natively.”

            In fact, basically most things on Wayland that fail to run seem to get hung up on a problem related to the display and it seems to be originating from either the application’s Wayland code or compatibility code that can display non-native applications in Wayland.

            Couldn’t quite figure out which. But the $ DISPLAY= environment variable can change the nvidia-settings Wayland debug output so it should be ok with Wayland to an extent.

            Really needs more digging into, but yes, it could be that nvidia-settings needs to implement Wayland code. Believe I couldn’t find any source code for that so no idea really if a fix there is required or if it can be “fixed” outside of the application code.

          2. Think I found the source code for nvidia-settings and you’re right it doesn’t look to support Wayland.

            Its interesting how much code shows when debugging its start on Wayland lol. Fedora doc is a bit misleading.

Leave a Reply to André CostaCancel reply