Solved Optimus nVidia/Intel (MSI GL65) : unable to get dual screen to work

Hello ! I've been trying to get my dual screen setup to work on X (using XFCE) but no luck.
First, my setup : it's an MSI laptop Leopard GL65, with Intel Graphics (UHD630) and a nVidia GeForce RTX 2070 SUPER, running 14.0 RELEASE.

$ pciconf -lv|grep -B4 VGA
Code:
vgapci1@pci0:0:2:0:    class=0x030000 rev=0x05 hdr=0x00 vendor=0x8086 device=0x9bc4 subvendor=0x1462 subdevice=0x12b8
    vendor     = 'Intel Corporation'
    device     = 'CometLake-H GT2 [UHD Graphics]'
    class      = display
    subclass   = VGA
--
vgapci0@pci0:1:0:0:    class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x1f14 subvendor=0x1462 subdevice=0x12b8
    vendor     = 'NVIDIA Corporation'
    device     = 'TU106M [GeForce RTX 2070 Mobile / Max-Q Refresh]'
    class      = display
    subclass   = VGA

The BIOS does not allow to disable the discrete CPU or the Intel Graphics.
On the hardware part, I have the laptop screen, a IIYAMA screen on HDMI port, and an empty DP. It looks like (stated in Windows 11 this way and it does look like this on FreeBSD) that the laptop screen is managed by the Intel UHD, but the HDMI and DP ports belong to the NVIDIA card.

Drivers used are i915kms (modeset) and the official NVIDIA driver, and it does work fine. There's nothing special in the logs, only these errors/warnings :
Code:
(WW) Hotplugging is on, devices using drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.
(!!) More than one possible primary device found
(WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
(WW) NVIDIA: No DRM device: Direct render devices found but none could be used.
(II) GLX: Another vendor is already registered for screen 0

Now, here is what happens : I can get both screens to work fine, but never on the same time. I do this by switching the Screen0 section from "nvidia" to "intel".
In my current setup (laptop on left, IIYAMA screen on right), I have the IIYAMA screen displaying my main screen ; the laptop screen is black, but activated (backlit) and I can smoothly put/move the pointer on it from the external screen to the internal one and vice-versa - the mouse does like if the Xinerama setup was working fine.
If I switch to a console (ie Crtl+Alt+F1), the IIYAMA screens shutdown (no signal detected), and the laptop screen gets the console display. Turning back to XFCE using CTRL+ALT+F9 works as the opposite - laptop screen turns black, and my IIYAMA turns back to XFCE.

At boot, the whole Vinit goes on the laptop screen, and it switches to the IIYAMA when SDDM is ready. Same thing when I shutdown from XFCE.

I did turn off Xinerama option for now, as it "looks to" work but it's unusable : the desktop looks to be streched correctly (no more desktop icons, my open windows are here but on the left, the mouse can be moved to the laptop screen BUT it's not appearing) but the laptop screen is still black so I can't see what I'm doing.


Using ARandR, with nVidia setup I have the following outputs : HDMI-0 (the screen I use), DP-0 and DP-1 (internal displayport), both disconnected. Booting with Intel driver (so I have the laptop screen but not the HDMI output), I only have eDP-1 output.
xrandr only list one provider, the NVIDIA or the Intel one.

Here are my relevant xorg.conf files :
(screen.conf)

Code:
Section "Screen"
    Identifier     "Screen0"
    Device         "nvidia" #Put intel to boot to the laptop screen (eDP-1)
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "intel"
    Monitor        "Monitor0" #Same result:Monitor1
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

(monitor.conf)
Code:
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
    #Option        "LeftOf" "Monitor0"
EndSection

(intel.conf)
Code:
Section "Device"
        Identifier      "intel"
        Driver          "modesetting"
        BusID           "PCI:0:2:0"
        #Option         "PrimaryGPU" "yes" #Ignored
EndSection

(nvidia.conf)
Code:
Section "Device"
    Identifier     "nvidia" #Device0
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
EndSection

(layout.conf - file based on a generated one by nvidia-xconfig)
Code:
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    Screen      1  "Screen1" LeftOf "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0" #1=External screen stretched to the laptop screen correctly, but unusable as the laptop screen is black
EndSection

It also doesn't work in NomadBSD, BUT the setup works out of the box if I run a Live Debian (also running XFCE). I've been testing NVIDIA secondary graphics, lots of this but nothing did the trick.

Do you think I'll be able to make this to work ? Thanks for any clue !!
 
Using ARandR, with nVidia setup I have the following outputs : HDMI-0 (the screen I use), DP-0 and DP-1 (internal displayport), both disconnected. Booting with Intel driver (so I have the laptop screen but not the HDMI output), I only have eDP-1 output.
Without AI-enhanced drivers, don't you think that you should let the drivers know which outputs should be assigned to which monitors?

See the xorg.conf specification:
With RandR 1.2-enabled drivers, monitor sections may be tied to specific outputs of the video card. Using the name of the output defined by the video driver plus the identifier of a monitor section, one associates a monitor section with an output by adding an option to the Device section in the following format:

Option "Monitor-outputname" "monitorsection"

(for example, Option "Monitor-VGA" "VGA monitor" for a VGA output)
 
Without AI-enhanced drivers, don't you think that you should let the drivers know which outputs should be assigned to which monitors?

See the xorg.conf specification:
Hi ! i had no time to reply to you, so I added on my intel.conf (Section "Device") the following option :
Code:
Option "Monitor-eDP-1"  "Monitor1"
I go slowly on it to avoid any error (that's why I haven't done the same yet for the nVidia card) and of course it had no effect.
But I do have lines on Xorg.0.log stating that the eDP-1 output is connected and probed (I only put here the relevant lines) :
Code:
(II) modeset(1): Output eDP-1 using monitor section Monitor1
(II) modeset(1): Output eDP-1 connected
(II) modeset(1): Using exact sizes for initial modes
(II) modeset(1): Output eDP-1 using initial mode 1920x1080 +0+0

xrandr still points only one provider.
I tested with Debian, and it states (as I said) 2 providers (provider 0 is id 0x44 with 3 outputs, provider 1 is id 0xfc, 4 outputs, name for both is modesetting), and the following outputs :
* eDP-1 (connected primary screen0)
* DP-2 (disconnected - never saw it on FreeBSD)
* HDMI-2 (disconnected, never saw it either)
* DP-1-1 (no state ?)
* HDMI-1-1 (connected, that's my external monitor).

I just notice that something generated a 20-nvidia-drm-outputclass.conf into the config dir (usr/local/share/X11/xorg.conf.d). I'll rename it to see what happens...
 
Are you sure that drm-kmod works in this configuration the way you want it to work (two different drivers, two different screens)?
I'm fairly certain that with i915kms, you're replacing the framebuffer driver in the kernel and that would ultimately stop you from using any Nvidia device in parallel.

Ah, strike that - I just realized you're using modesetting on i915kms; so that would stop you from loading the framebuffer code. Actually, it would stop i915kms from doing anything, because the driver bails out quite early if that is set, if I remember correctly
 
A
Ah, strike that - I just realized you're using modesetting on i915kms; so that would stop you from loading the framebuffer code. Actually, it would stop i915kms from doing anything, because the driver bails out quite early if that is set, if I remember correctly
Oh, that would be awesome!

If I understand you correctly, this would stop i915kms from usurping the video hardware, so that it no longer blocks other video hardware from coexisting.
In other words, cutting down the drm-kmod's bad behaviour, so using other manufacturers video hardware together in parallel with the onboard graphics is no longer blocked.

This might explain well why ditching the KMS crap is a gooood thing, because it makes possible to use nvidia together with xf86-video-intel :)
 
It might looks so cmoerz, maybe the drivers are fighting each other :P
So, here are some news :
As said, I added the Option "Monitor-eDP-1" to the Intel Device section, and the Option "Monitor-DFP-0" to my NVIDIA Device Section (it is named this way in Xorg logs when running from Intel driver and the IIYAMA is probed).
It does the exact opposite of what I had : the laptop screen is working, and my IIYAMA screen is black, but I can fly the mouse on it from the laptop screen and vice-versa with no problem at all. Same result if I put "HDMI-0" instead of "DFP-0" (HDMI-0 is the working output name when I'm running from the nvidia driver).
When I enable Xinerama, still the same thing : the IIYAMA turns on, works as an extended part of the main (laptop) screen, which is black (and the mouse is NOT visible).

I disabled the composite because the log stated that both Composite and Xinerama were enabled, but on the next boot with Xinerama enabled, the windows were all crashing/wrong buggy display, so I had to run Xterm from a user session using SDDM (toggling to console with Ctrl+Alt+FX gave an empty screen... ouch).

In the current setup, I'm running FreeBSD from my laptop's screen, the IIYAMA is black but on with the mouse I can move on, I have sound on the IIYAMA, only one provider from xrandr (1 output), but the NVIDIA X Server Settings does have 2 screens and detects perfectly the IIyama (as X Screen 1 on HDMI-0).

I keep confident but this one is tricky !!
 
...using SDDM (toggling to console with Ctrl+Alt+FX gave an empty screen... ouch). ...
Maybe you could, at least for the experimenting/diagnosing period, disable such login managers?
Just to rule out their side effects, respective problems they cause.
I'd really advise to use startx/xinit from console...
 
Maybe you could, at least for the experimenting/diagnosing period, disable such login managers?
Just to rule out their side effects, respective problems they cause.
I'd really advise to use startx/xinit from console...
I'll test this indeed and report ?
 
Well, some news : nothing to say, it didn't work. Here some outputs, I removed the useless probes to keep it readable.

Code:
xrandr --query
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
HDMI-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 476mm x 268mm
   1920x1080     60.00*+  74.97    59.94    50.00 
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)

xrandr --listmonitors
Monitors: 1
 0: +*HDMI-0 1920/476x1080/268+0+0  HDMI-0

xrandr --screen 0
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
HDMI-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 476mm x 268mm
   1920x1080     60.00*+  74.97    59.94    50.00  
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)

xrandr --screen 1
Screen 1: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1920x1080    144.03*+  60.01    59.97    59.96    60.00    59.93
 
Hi, feedback months later !
Still no luck, I removed nvidia-drm-510-kmod as it was useless (I run nvidia-driver) and tested some new things, but no luck. I might try again starting from the Intel to "expand" to the discreete card (as opposite of what I do now). Double checked in Windows, it does state the internal monitor goes to Intel UHD, and the HDMI goes to Nvidia.
Weird thing is, I was playing with VLC to test my libdvdcss port, I mistakenly double clicked for fullscreen, and the fullscreen went... on the internal monitor. The video was empty, but the VLC controls did display and reacted fine to my mouse. I then noticed in the seetings that the internal monitor was the default one for fullscreen (and it allows me to use both the internal or external monitors if I want).
That's just crazy !!
 
Last edited:
Hi, thanks for your reply !
Indeed, the nvidia-driver was updated (nvidia-driver: 535.146.02 -> 550.54.14).
Not rebooted yet, but I'll follow your link for issue :)
 
I GOT IT TO WORK !! (only took me one year ; I have better experience, that helps a lot...)

Today, I tried new things as some package upgrade crashed my X unclean "dual screen" setup on XFCE (internal screen working, external black with the mouse moving on it) and I eventually make the dual screen to work on this model, testing progressively lots of my manually made Xorg conf files, which are now useless (target achieved). Here are my working setup, I hope it can help other MSI laptop users.
Works for me on 14.1-RELEASE-p3 on XFCE4.
The only caveat I noticed is that it overheats a bit. I'll check Xorg.0.log because I think some driver is not working correctly.
This setup makes the NVIDIA card the primary graphics provider.
  • I use nvidia-drm-kmod-550.54.14 (I noticed I only add nvidia-driver, not the DRM version), alongside the standard drm-515-kmod-5.15.160 for Intel.
  • /etc/rc.conf : kld_list="i915kms acpi_video nvidia-drm" (the list here shows only the relevant video parts). You can try nvidia-modeset, but SirDice stated in a thread to use this, so I tried and it looks fine. The nvidia-drm-kmod notes still says to use nvidia-modeset.
  • Don't forget to add, as stated in nvidia-drm-kmod notes hw.nvidiadrm.modeset=1 to /boot/loader.conf.
  • Disable (or delete) any X file manually made or generated by X or nvidia-settings (ie. you can rename/remove the whole /usr/local/etc/X11/xorg.conf.d directory).
  • In XFCE, with the external monitor turned on (all FreeBSD will run from the internal screen, then X will start on the external display), check you have two providers using xrandr --listproviders (if there's one... Problem !).
  • From here, you can enable the internal display (called for me eDP-1-1), use xrandr, arandr or the XFCE settings to arrange the two screens as you wish (make the internal display primary, it's supposed to be this way...).
I'd like to thank everyone for help, it took me some time but the learning curve is on its way ?
 
Back
Top