Laptop screen goes black after disconnecting an external monitor

I’m having problems with the external monitor connected to my laptop via DisplayPort: it works as expected, but when I disconnect the monitor, the laptop screen also goes black. Plugging the monitor back sometimes restores the image on both screens. Sometimes, don’t. Attempts to switch to a different tty also work only occasionally.
Previously, it had been working fine (I could disconnect it without any issues), but I’m unable to track down the particular change/update causing issues.
The hardware configuration is NVIDIA 2070 Max-Q with the 535.129.03 driver, prime-select runs in nvidia mode.
I attached the inxi -Gx output and the journalctl log, where I disconnected the external monitor at 14:34.
Any tips and bits of advice are appreciated.

inxi -Gx output
Graphics:
  Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] driver: i915 v: kernel
    arch: Gen-9.5 bus-ID: 00:02.0
  Device-2: NVIDIA TU106M [GeForce RTX 2070 Mobile] vendor: Intel
    driver: nvidia v: 535.129.03 arch: Turing bus-ID: 01:00.0
  Device-3: Chicony HD Webcam driver: uvcvideo type: USB bus-ID: 1-13:5
  Display: x11 server: X.Org v: 21.1.9 with: Xwayland v: 23.2.2 driver: X:
    loaded: modesetting,nvidia dri: iris gpu: i915,nvidia,nvidia-nvswitch
    resolution: 1: 3440x1440 2: 1920x1080~144Hz
  API: OpenGL v: 4.6.0 NVIDIA 535.129.03 renderer: NVIDIA GeForce RTX 2070
    with Max-Q Design/PCIe/SSE2 direct-render: Yes

journalctl log

Here are a couple more facts:

  1. The Cinnamon DE handle monitor disconnects without any issues.
  2. I switched prime-select to offload mode, and… GNOME had no more problems disconnecting the monitor.

I’m confused about what is actually causing problems here: is it GNOME, NVIDIA driver, or something completely different.

@Dremlin likely the connection from either intel or nvidia to the port. You need to run xrandr --listproviders and xrandr --listmonitors to see what is using the output at that time and connected to your monitor.

xrandr --listproviders output
Providers: number : 2
Provider 0: id: 0x1b7; cap: 0x1 (Source Output); crtcs: 4; outputs: 5; associated providers: 1; name: NVIDIA-0
    output DP-0
    output DP-1
    output DP-2
    output DP-3
    output HDMI-0
Provider 1: id: 0x201; cap: 0xf (Source Output, Sink Output, Source Offload, Sink Offload); crtcs: 3; outputs: 1; associated providers: 1; name: modesetting
    output eDP-1-1
xrandr --listmonitors output
Monitors: 2
 0: +*DP-0 3440/800x1440/330+0+0  DP-0
 1: +eDP-1-1 1920/344x1080/193+3440+0  eDP-1-1

@malcolmlewis do you see any potential problem causes here? Thank you!

@Dremlin Hi, So what mode was this output, offload? If not, can you run the above in offload mode. The intel gpu should be running both eDP-1-1 (Laptop screen ) and DP-n…

@malcolmlewis Hi, this was the nvidia mode. Please see the outputs for the offload mode below.

xrandr --listproviders output

Providers: number : 2
Provider 0: id: 0x42; cap: 0xf (Source Output, Sink Output, Source Offload, Sink Offload); crtcs: 3; outputs: 1; associated providers: 1; name: modesetting
output eDP-1
Provider 1: id: 0x26c; cap: 0x2 (Sink Output); crtcs: 4; outputs: 5; associated providers: 1; name: NVIDIA-G0
output DP-1-0
output DP-1-1
output DP-1-2
output DP-1-3
output HDMI-1-0

xrandr --listmonitors output

0: +*DP-1-0 3440/797x1440/334+0+0 DP-1-0
1: +eDP-1 1920/344x1080/193+3440+0 eDP-1

@Dremlin so the providers changed, and both monitors run and if you unplug the DP one all is good?

So in this mode if you run;

glxinfo | grep "OpenGL renderer"

then

__NV_PRIME_RENDER_OFFLOAD=1 __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only  glxinfo | grep "OpenGL renderer"

The cards switch?

@malcolmlewis Yes, in the offload mode I can unplug the DP monitor without any issues.
Yes, the provider changes from Mesa Intel(R) UHD Graphics 630 (CFL GT2) to NVIDIA GeForce RTX 2070 with Max-Q Design/PCIe/SSE2

@Dremlin so you could install switcheroo-control and use that with the dbus integration with GNOME to start applications (right click on the desktop icon)

switcherooctl list
Device: 0
  Name:        NVIDIA Corporation TU117GLM [Quadro T400 Mobile]
  Default:     yes
  Environment: __GLX_VENDOR_LIBRARY_NAME=nvidia __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only

Device: 1
  Name:        NVIDIA Corporation GP104GL [Tesla P4]
  Default:     no
  Environment: __GLX_VENDOR_LIBRARY_NAME=nvidia __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only

There also a number of applications that will just use the offload device automatically (compute/graphics)…

1 Like

@Dremlin there is probably no need for suse-prime either… I don’t use it here, I have a laptop with dual AMD GPU’s and it just uses switcherooctl (MicroOS Aeon)…

@malcolmlewis Thank you for your suggestion! The main reason I’m mainly using the nvidia mode is that the integrated GPU is not capable of rendering the image for my external display smoothly. I saw there is a Reverse PRIME walkaround. Does switcherooctl have any?

@Dremlin That’s unusual, intel are generally pretty up to speed with that, can you post the output from inxi -Gaz.

When you do say rendering an image, can you describe a little more in detail?

@malcolmlewis Visual effects (mouse movement, scrolling, windows dragging, and resizing) aren’t as smooth as they are expected to be. It feels like the refresh rate for them is slightly lower than the display refresh rate. And it doesn’t matter if I’m running my external display at 144 Hz or 60 Hz. It’s usable but not pleasant.

inxi -Gaz output
Graphics:
  Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] driver: i915 v: kernel
    arch: Gen-9.5 process: Intel 14nm built: 2016-20 ports: active: eDP-1
    empty: none bus-ID: 00:02.0 chip-ID: 8086:3e9b class-ID: 0300
  Device-2: NVIDIA TU106M [GeForce RTX 2070 Mobile] vendor: Intel
    driver: nvidia v: 535.129.03 alternate: nouveau,nvidia_drm non-free: 530.xx+
    status: current (as of 2023-05) arch: Turing code: TUxxx
    process: TSMC 12nm FF built: 2018-22 pcie: gen: 1 speed: 2.5 GT/s
    lanes: 16 link-max: gen: 3 speed: 8 GT/s ports: active: none off: DP-1
    empty: DP-2,HDMI-A-1 bus-ID: 01:00.0 chip-ID: 10de:1f10 class-ID: 0300
  Device-3: Chicony HD Webcam driver: uvcvideo type: USB rev: 2.0
    speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-13:5 chip-ID: 04f2:b68b
    class-ID: 0e02 serial: <filter>
  Display: x11 server: X.Org v: 21.1.9 with: Xwayland v: 23.2.2
    compositor: gnome-shell v: 45.1 driver: X: loaded: modesetting,nvidia
    dri: iris gpu: i915,nvidia,nvidia-nvswitch display-ID: :1 screens: 1
  Screen-1: 0 s-res: 5360x1440 s-dpi: 96 s-size: 1418x381mm (55.83x15.00")
    s-diag: 1468mm (57.81")
  Monitor-1: DP-1 mapped: DP-1-0 note: disabled pos: primary,left
    model: Dell S3422DWG serial: <filter> built: 2022 res: 3440x1440 dpi: 109
    gamma: 1.2 size: 800x330mm (31.5x12.99") diag: 864mm (34") modes:
    max: 3440x1440 min: 640x480
  Monitor-2: eDP-1 pos: right model: BOE Display 0x084d built: 2018
    res: 1920x1080 hz: 144 dpi: 142 gamma: 1.2 size: 344x193mm (13.54x7.6")
    diag: 394mm (15.5") ratio: 16:9 modes: 1920x1080
  API: OpenGL v: 4.6 Mesa 23.2.1 renderer: Mesa Intel UHD Graphics 630 (CFL
    GT2) direct-render: Yes

@Dremlin maybe @mrmazda has some comments on the intel gpu and settings… different dpi setting etc…

Likewise I don’t see an issue using offload the other way using the intel gpu, try it and see how it goes…

@malcolmlewis Ok! Thanks for trying to help!

1 Like

I’m afraid the involvement of NVidia drivers, particularly in dual graphics environment, cuts my ability to contribute down to virtual nothingness. My newest NV GPU is 11 years old, and all I own have been good enough for me using pure FOSS (except for those old nForce abominations that were probably never good enough for anyone).

I think if you spend some time searching among the entire universe of Gnu/Linux distros you’ll find a lot of displeasure among laptop users of external displays, particularly with docking stations and/or dual graphics. I suppose an answer I gave to one such yesterday could conceivably be useful here. Don’t get your hopes up though.

@mrmazda more with thoughts on the intel gpu and it’s performance for this user and their displays in use (refresh rates, dpi etc)…

Model of the laptop?