Can't enable nvidia DRM when using prime

I have been trying to enable nvidia DRM so that I can use autorandr. I’m pretty sure it used to be enabled by default, but now it isn’t anymore. I used mhwd to install the nvidia drivers and use nvidia PRIME (prime-run) to switch between my intel iGPU und my Nvidia-3060.

I have tried enabling it by editing my /etc/modprobe.d/mhwd-gpu.conf

##
## Generated by mhwd - Manjaro Hardware Detection
##
 
blacklist nouveau
blacklist ttm
#blacklist drm_kms_helper
#blacklist drm
options nvidia "NVreg_DynamicPowerManagement=0x02"


blacklist nvidiafb
blacklist rivafb
options nvidia_drm modeset=1

But that just leads the following cryptic X11 error:
screen 0 deleted because of no matching config section

I was at some point able to get it running using this:

Step 2: change /etc/X11/xorg.conf.d/90-mhwd.conf to:

 Section "Module"
    Load "modesetting"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1:0:0"
    Option "AllowEmptyInitialConfiguration"
EndSection

Step 3 change /etc/modprobe.d/mhwd-gpu.conf to

##
## Generated by mhwd - Manjaro Hardware Detection
##
 
blacklist nouveau
#blacklist ttm
#blacklist drm_kms_helper
#blacklist drm
options nvidia "NVreg_DynamicPowerManagement=0x02"


blacklist nvidiafb
blacklist rivafb
options nvidia_drm modeset=1

Step 4

create this file (/usr/local/bin/optimus.sh)

#!/bin/sh

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

make it executable

chmod a+rx /usr/local/bin/optimus.sh

Edit /etc/lightdm/lightdm.conf and set (if you are using another dm check the article)

display-setup-script=/usr/local/bin/optimus

But now the whole system runs entirely on the NVIDIA GPU and therefore burns through the battery in minutes.

Isn’t there a way to both preserve nvidia prime and enable nvidia drm?

Sorry, but it is weird. Nvidia KMS (kernel mode Setting) doesn’t work the same way as you would use an open source driver like i915 or nouveau. Nvidia has limited support in that regard.

If the NVIDIA card drains your battery, why would you consider KMS, which will run the NVIDIA all the time, unable to unload the module and shut it down?

I’m not using for that reason. But its the only way to make Direct Rendering Manager work

So, then tell us what your goal is? DRM can be accessed on a prime setup for example by prime-run some_command or with a reversed Prime Xorg config. Why would you need KMS (modeset=1)? I don’t get the whole idea and what you are trying to accomplish.

Looks to like a xy problem.

Im trying to get autorandr to work so manjaro automatically switches to my laptop screen when the dp cable gets unplugged.

Ots recommended on the autorandr github page snd eorks with the nvidia only config

Allright.

  1. DisplayPort is most likely hardwired to the Nvidia GPU.
  2. You run it in a reverse prime mode, which means it runs the Nvidia GPU and pass though a screen with modesetting to the laptop screen, which is hardwired to Intel GPU. In this direction it works.
  3. Now you try it the other way around. Pass through a screen from the Intel GPU to the DisplayPort, what doesn’t work, because the nvidia driver is limited:

The NVIDIA DRM KMS implementation does not yet register an overlay plane: only primary and cursor planes are currently provided.

Chapter 36. Direct Rendering Manager Kernel Modesetting (DRM KMS)

Here is how it works with MultiPlaneOverlay (MPO): Multiplane Overlay (MPO) — The Linux Kernel documentation

So because Nvidia is limited to one primary plane it will not work your way. It could only work with the open source nouveau driver, but on the other hand it would a performance degrade.

If I understand you correctly this is a dead end. I guess I need to find some other solution.

I think you forgot something. :wink:

MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

See:

I tried that already it didn’t work. Since it works on another laptop with an older Nvidia card, I assume Nvidia deprecated DRM on newer cards. I hope someday someone makes something like autorandr that doesn’t rely on DRM.

You should really start over and stop editing files like that.
Get your mhwd files back as they would have been applied from selecting the PRIME profile.

Once youve done that you can use drop-in files for your options:

/etc/X11/xorg.conf.d/99-nvidia.conf

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1:0:0"
    Option "AllowEmptyInitialConfiguration"
EndSection

/etc/modprobe.d/99-nvidia.conf

options nvidia "NVreg_DynamicPowerManagement=0x02"
options nvidia_drm modeset=1

this works, but now Prime is disabled again (everything runs on GPU and chews through battery.) I need both DRM and Prime

Found an autorandr solution called grobi that does the same thing without DRM. Its a bit more complicated to set up and the manjaro package is broken ( sudo ln -s /usr/lib/systemd/user/grobi.service /usr/lib/systemd/system/grobi.service to fix) but aside from that it works okay