No Nvidia Screen Provider on Arch Nvidia REVERSE PRIME

So i’ve been configuring my Arch with Nvidia REVERSE PRIME on my Nvidia Optimus Laptop, it has Geforce MX150. I have been following the setup from here and i modified it a little bit, also added a display setup script for lightdm for nvidia output sink. I realized to utilize the Nvidia Prime-run while using REVERSE PRIME setup is actually to have a “virtual screen” running on Nvidia or having an Xorg running on Nvidia.

So here’s the problem, when the computer first boot there’s only one provider that’s available which is the modesetting and there is no Nvidia GPU Screen 0 or NVIDIA-G0 provider and i ran xrandr to check listproviders and there’s only one provider, but everytime i restart lightdm.service that provider or Nvidia GPU Screen 0/NVIDIA-G0 miraculously shows up. So how do i start the computer at the first boot with NVidia GPU Screen 0/NVIDIA-GO shows up on xrandr or there’s xorg running on Nvidia? Is there any extra steps that i need to take like loading a module or someting? Any Solution?

lspci

00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)
01:00.0 3D controller: NVIDIA Corporation GP108M [GeForce MX150] (rev a1)

First Boot

xrandr --listproviders

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

Nvidia-smi

Wed Dec  9 11:58:26 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.45.01    Driver Version: 455.45.01    CUDA Version: 11.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce MX150       Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   44C    P0    N/A /  N/A |      0MiB /  2002MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

Lightdm Restarted after the first boot

xrandr --listproviders

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: 0x241 cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:NVIDIA-G0

Nvidia-smi

Wed Dec  9 12:16:20 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.45.01    Driver Version: 455.45.01    CUDA Version: 11.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce MX150       Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   46C    P8    N/A /  N/A |      4MiB /  2002MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      5045      G   /usr/lib/Xorg                       4MiB |
+-----------------------------------------------------------------------------+

Here’s my config

xorg.conf

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "intel"
    Inactive "nvidia"
    Option "AllowNVIDIAGPUScreens"
EndSection

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

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration"
EndSection

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

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

10-nvidia-drm-outputclass.conf

Section "OutputClass"
    Identifier "intel"
    MatchDriver "i915"
    Driver "modesetting"
EndSection

Section "OutputClass"
    Identifier "nvidia"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "AllowEmptyInitialConfiguration"
    Option "PrimaryGPU" "yes"
    ModulePath "/usr/lib/nvidia/xorg"
EndSection

lightdm display setup script

#!/bin/sh
xrandr --setprovideroutputsource NVIDIA-G0 modesetting
xrandr --auto

Logs
nvidia-bug-report.log (669.9 KB)

It looks like nvidia driver does not load on first lightdm start. Could you try adding “modprobe nvidia” into lightdm pre-startup script? Also, Option “PrimaryGPU” “yes” seems weird, because nvidia in prime render offload would not be a primary gpu, I think.

Maybe the nvidia driver does load, just not in time for Xorg to pick it up on first lightdm appearance? You could also try something stupid, like a adding a systemd service with a startup script that has a command “sleep 5 && systemctl lighdm start”, after disabling the original lightdm service…

I guess you’ll just have to configure Arch to embed the nvidia driver into the initrd and recreate it. Then the driver will load early.

Yeah, that second config looks weird for this setup. I tested the one where i load the nvidia driver on lightdm display setup script and the result still the same.

So i deciced to add Nvidia as one of the modules to load early, everythings seems working and everytime i boot to the system there’s actually two screen provider and NVIDIA Reverse Prime working.

How to :
Edit /etc/mkinitcpio.conf and add nvidia to MODULES section, After that generate the new initramfs

For stability, you should also include the module nvidia-drm and nvidia-modeset.