PRIME render offloading not working on my arch linux on a lenovo laptop with xfce+xorg

Running glx-info with prime-run (wraps all the needed environment variables) yields:

# prime-run glxinfo
name of display: :0.0
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  39
  Current serial number in output stream:  40

I have looked into https://devtalk.nvidia.com/default/topic/1068229/linux/problem-with-offloading-with-prime/ and i have tried:

  • removing /usr/share/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf
  • Adding the Files section to 10-nvidia-drm-outputclass.conf (I don't have a /etc/X11/xorg.conf)
  • Adding nvidia-drm.modesetting=1 to the kernel cmdline via grub

— info dump —

Versions of things:
nvidia-dkms 440.44-5
linux-zen 5.4.6.zen1-1
xorg-server 1.20.6-2

lsmod | grep nv:

nvidia_drm             53248  1
nvidia_modeset       1118208  1 nvidia_drm
nvidia              20451328  1 nvidia_modeset
drm_kms_helper        229376  2 nvidia_drm,i915
drm                   573440  7 drm_kms_helper,nvidia_drm,i915
ipmi_msghandler        73728  2 ipmi_devintf,nvidia

I have not tested running on the stock linux kernel, but I doubt it will make a difference since zen simply changes the io scheduler, and my nvidia is installed with DKMS.

I tried adding nvidia-drm.modesetting=1 to the kernel cmdline which added Provider 1 in the output of xrandr --listproviders below, but it’s still not working.

Providers: number : 2
Provider 0: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 4 associated providers: 0 name:modesetting
Provider 1: id: 0x22e cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:modesetting

I see no way to attach files in this form so i’ll upload them to Drive:
Output of glxinfo:

Output of __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo:

Output of nvidia-bug-report.sh:

If you want any more info, I’m here. Thanks in advance :)
nvidia-bug-report.log.gz (582 KB)
glxinfo_notworks.txt (330 Bytes)
glxinfo_works.txt (43 KB)

Please create /etc/X11/xorg.conf with contents

Section "ServerLayout"
  Identifier "layout"
  Screen 0 "iGPU"
  Option "AllowNVIDIAGPUScreens"
EndSection

Section "Device"
  Identifier "iGPU"
  Driver "modesetting"
  BusID "PCI:0:2:0"
EndSection

Section "Screen"
  Identifier "iGPU"
  Device "iGPU"
EndSection

Section "Device"
  Identifier "nvidia"
  Driver "nvidia"
  BusID "PCI:59:0:0"
EndSection

No dice, attaching updated nvidia-bug-report.log.gz.
nvidia-bug-report-new.log.gz (574 KB)

Please embed the nvidia modules in the initrd so thhey’re available at an earlier time on boot.

It worked! Thank you very much. Here’s my final config.

/usr/share/X11/xorg.conf.d/10-quirks.conf: (Probably arch linux specific)

# Collection of quirks and blacklist/whitelists for specific devices.

# Accelerometer device, posts data through ABS_X/ABS_Y, making X unusable
# http://bugs.freedesktop.org/show_bug.cgi?id=22442 
Section "InputClass"
        Identifier "ThinkPad HDAPS accelerometer blacklist"
        MatchProduct "ThinkPad HDAPS accelerometer data"
        Option "Ignore" "on"
EndSection

# https://bugzilla.redhat.com/show_bug.cgi?id=523914
# Mouse does not move in PV Xen guest
# Explicitly tell evdev to not ignore the absolute axes.
Section "InputClass"
        Identifier "Xen Virtual Pointer axis blacklist"
        MatchProduct "Xen Virtual Pointer"
        Option "IgnoreAbsoluteAxes" "off"
        Option "IgnoreRelativeAxes" "off"
EndSection

# https://bugs.freedesktop.org/show_bug.cgi?id=55867
# Bug 55867 - Doesn't know how to tag XI_TRACKBALL
Section "InputClass"
        Identifier "Tag trackballs as XI_TRACKBALL"
        MatchProduct "trackball"
        MatchDriver "evdev"
        Option "TypeName" "TRACKBALL"
EndSection

# https://bugs.freedesktop.org/show_bug.cgi?id=62831
# Bug 62831 - Mionix Naos 5000 mouse detected incorrectly
Section "InputClass"
        Identifier "Tag Mionix Naos 5000 mouse XI_MOUSE"
        MatchProduct "La-VIEW Technology Naos 5000 Mouse"
        MatchDriver "evdev"
        Option "TypeName" "MOUSE"
EndSection

/usr/share/X11/xorg.conf.d/40-libinput.conf: (Probably arch linux specific)

# Match on all types of devices but joysticks
#
# If you want to configure your devices, do not copy this file.
# Instead, use a config snippet that contains something like this:
#
# Section "InputClass"
#   Identifier "something or other"
#   MatchDriver "libinput"
#
#   MatchIsTouchpad "on"
#   ... other Match directives ...
#   Option "someoption" "value"
# EndSection
#
# This applies the option any libinput device also matched by the other
# directives. See the xorg.conf(5) man page for more info on
# matching devices.

Section "InputClass"
        Identifier "libinput pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

/etc/X11/xorg.conf:

Section "Files"
  ModulePath "/usr/lib/xorg/modules"
  ModulePath "/usr/lib/nvidia/xorg"
EndSection

Section "ServerLayout"
  Identifier "layout"
  Screen 0 "iGPU"
  Option "AllowNVIDIAGPUScreens"
EndSection

Section "Device"
  Identifier "iGPU"
  Driver "modesetting"
  BusID "PCI:0:2:0"
EndSection

Section "Screen"
  Identifier "iGPU"
  Device "iGPU"
EndSection

Section "Device"
  Identifier "nvidia"
  Driver "nvidia"
  BusID "PCI:59:0:0"
EndSection

/etc/mkinitcpio.conf: (Probably arch linux specific)

...
MODULES=(nvidia nvidia_modeset nvidia_drm drm_kms_helper drm ipmi_msghandler)
...

Remember to run mkinitcpio -p linux (mkinitcpio -p linux-zen in my case)

There are no other (xorg config) files in either /usr/share/X11/xorg.conf.d/ or /etc/X11/xorg.conf.d/ except noted here.
Relevant packages that I have installed: mesa-demos nvidia-prime nvidia-settings dkms nvidia-dkms linux-zen-headers

Huge thanks to generix :)