(ignore this, I accidentlly posted it twice) PRIME render offload - "BadValue (integer parameter out of range for operation)" when trying to use nvidia GPU

Edit: duplicate of https://devtalk.nvidia.com/default/topic/1069168/linux/prime-render-offload-quot-badvalue-integer-parameter-out-of-range-for-operation-quot-when-trying-to-use-nvidia-gpu/

I’m on a Lenovo IdeaPad Z510 laptop, with an nvidia geforce GT 740M GPU, using linux gentoo. After years of using alternative solutions, I learned that official nvidia driver now has a working solution for render offload.

Based on the instructions here https://download.nvidia.com/XFree86/Linux-x86_64/440.44/README/primerenderoffload.html I attempted to install the nvidia driver and use render offload.

I installed nvidia drivers with libglvnd and kms support (
all enabled gentoo USE flags: X acpi compat driver kms libglvnd multilib tools), and disabled nouveau kernel module. I’m using xorg version 1.20.6 and kernel 5.4.6, with nvidia driver version 440.44-r1. I am using the modesetting intel GPU driver, as the instructions say. I also added the /etc/X11/xorg.conf.d/nvidia.conf that can be seen in nvidia-bug-report.log linked at the end. In /usr/share/X11/xorg.conf.d/50-nvidia-drm-outputclass.conf I also tried to change “nvidia-drm” to “nvidia_drm” there as this is the name of the kernel module I have, without any improvement.

When attempting to run __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo I get the following output:

name of display: :0.0
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (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

When running xrandr --listproviders I’m getting:

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

Which clearly does not look right.

I also attempted to specify PCI bus IDs as can be seen commented out in nvidia.conf.

and that leads to crashing X with the following error (Xorg.1.log in nvidia-bug-report.log, where Xorg.0.log is log of the currently running X instance I’m writing this post on):

free(): invalid pointer
(EE) Backtrace:
(EE) 0: /usr/bin/X (xorg_backtrace+0x4d) [0x56148099ec0d]
(EE) 1: /usr/bin/X (0x5614807fa000+0x1a88d5) [0x5614809a28d5]
(EE) 2: /lib64/libpthread.so.0 (0x7fb66d536000+0x15260) [0x7fb66d54b260]
(EE) 3: /lib64/libc.so.6 (gsignal+0x141) [0x7fb66d39fed1]
(EE) 4: /lib64/libc.so.6 (abort+0x127) [0x7fb66d38855b]
(EE) 5: /lib64/libc.so.6 (0x7fb66d366000+0x7fc16) [0x7fb66d3e5c16]
(EE) 6: /lib64/libc.so.6 (0x7fb66d366000+0x88fb8) [0x7fb66d3eefb8]
(EE) 7: /lib64/libc.so.6 (0x7fb66d366000+0x8abcc) [0x7fb66d3f0bcc]
(EE) 8: /usr/lib64/libnvidia-glcore.so.440.44 (0x7fb666345000+0xe57744) [0x7fb66719c744]
(EE) 9: /usr/lib64/xorg/modules/extensions/libglxserver_nvidia.so (0x7fb66830f000+0x8f88ef) [0x7fb668c078ef]

Based on this: https://devtalk.nvidia.com/default/topic/1068925/prime-render-offloading-not-working-on-my-arch-linux-on-a-lenovo-laptop-with-xfce-xorg/?offset=1 I also attempted to add nvidia driver to initramfs, without any change (dmesg output confirming that it is loaded from initramfs: https://pastebin.com/raw/qxAaetLZ).

Output of nvidia-bug-report.sh: https://gist.githubusercontent.com/Barteks2x/6afb2f7f964ea2dfa2a77273a8072a97/raw/043fb6ae2167bb3a1ea01f42e02787b5333bd0c3/nvidia-bug-report.log

Ignore this, accidentlaly posted twice instead of editing title.