Plasma breaks on Wayland with NVIDIA proprietary drivers eGPU

Hi guys, I need your help.

I have a laptop with an Intel integrated card + NVIDIA discrete card eGPU running KDE neon user edition. I have an external monitor connected to the NVIDIA card. Here is my lspci result:

$ lspci | grep 'VGA'
0000:00:02.0 VGA compatible controller: Intel Corporation Alder Lake-P Integrated Graphics Controller (rev 0c)
0000:04:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3080] (rev a1)

I’m trying to migrate my setup from X11 to Wayland since NVIDIA should have decent support for it now. I followed this KDE guide. It works out of the box when using Nouveau drivers. When using the NVIDIA proprietary drivers, I have the following situation:

  • SDDM works (X11 backend still). However, after login, Plasma fails to start. It results in a black screen with a mouse cursor on it. I can still ctrl + alt + T to access the terminal and manually open another software, like Firefox. Window management seems ok, so it looks like KWin is working.
  • If I log in to SDDM with the eGPU disconnected, wait till the Plasma loads, and only then connect the eGPU, it works perfectly well. (Hot-plug was not a thing on X11, so good to know it works out of the box on Wayland)

So, as far as I can tell, it seems like the overall setup is working, but the Plasma refuses to start when the NVIDIA card is connected with the proprietary drivers in use. I tried with both nvidia-driver-535 and nvidia-driver-545-open, same result. The nvidia-driver-535-open seems buggy and did not work at all.

Not sure how to debug this problem. Here is what I did so far:

  • Manually execute plasmashell
$ plasmashell --replace
Checking screens: available: (QScreen(0x560db2ef0a30, name="HDMI-A-2")) redundant: QHash() fake: QSet() all: (QScreen(0x560db2ef0a30, name="HDMI-A-2"))
kf.plasma.quick: Applet preload policy set to 1
file:///usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kirigami.2/templates/InlineMessage.qml:265:13: QML SelectableLabel: Binding loop detected for property "implicitWidth"
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
org.kde.plasma.containmentlayoutmanager: Error: cannot change the containment to AppletsLayout
QObject::connect: No such slot DesktopProtocol::_k_slotRedirection(KIO::Job *, QUrl)
QObject::connect: No such slot DesktopProtocol::_k_slotRedirection(KIO::Job *, QUrl)
[destroyed object]: error 7: importing the supplied dmabufs failed
The Wayland connection experienced a fatal error: Protocol error

  • Check journalctl
$ journalctl --follow --user-unit plasma-plasmashell
dez 14 14:34:20 fael-linux kioslave5[9784]: QObject::connect: No such slot DesktopProtocol::_k_slotRedirection(KIO::Job *, QUrl)
dez 14 14:34:20 fael-linux plasmashell[9767]: [destroyed object]: error 7: importing the supplied dmabufs failed
dez 14 14:34:20 fael-linux plasmashell[9767]: The Wayland connection experienced a fatal error: Protocol error
dez 14 14:34:20 fael-linux systemd[9209]: plasma-plasmashell.service: Main process exited, code=exited, status=1/FAILURE
dez 14 14:34:20 fael-linux systemd[9209]: plasma-plasmashell.service: Failed with result 'exit-code'.
dez 14 14:34:20 fael-linux systemd[9209]: plasma-plasmashell.service: Scheduled restart job, restart counter is at 3.
dez 14 14:34:20 fael-linux systemd[9209]: Stopped KDE Plasma Workspace.
dez 14 14:34:20 fael-linux systemd[9209]: plasma-plasmashell.service: Start request repeated too quickly.
dez 14 14:34:20 fael-linux systemd[9209]: plasma-plasmashell.service: Failed with result 'exit-code'.
dez 14 14:34:20 fael-linux systemd[9209]: Failed to start KDE Plasma Workspace.

Any ideas?

KWin tries to ensure it doesn’t use external GPUs as the primary one by default, but it sounds like that doesn’t work for your setup, and the NVidia GPU gets chosen if it’s connected at login time.

The driver is supposed to make sure that can’t happen, so that should be a bug in the driver. That it only happens with plasmashell is quite odd though

So, should I open a bug report to NVIDIA? I have no idea where to start. Would you mind point me out the way?

Regardless, is there any workaround I can use until NVIDIA fix it?

So, should I open a bug report to NVIDIA?

Depends on which driver gets used by KWin and which gets used by plasmashell.

You can check in the KWin log, it should print info about the GPU used for compositing:

journalctl --user-unit plasma-kwin_wayland --boot 0

I don’t know how to check for plasmashell tbh, but it’s probably the one that KWin isn’t using.

Regardless, is there any workaround I can use

You can tell KWin to always use the integrated GPU as primary with the KWIN_DRM_DEVICES environment variable: Environment Variables · Wiki · Plasma / KWin · GitLab. Usually /dev/dri/card0 is the integrated one and /dev/dri/card1 the dedicated one, but you should check with drm_info to be sure (on my laptop it’s reversed for some reason, even if I hotplug the eGPU after booting).

You can check in the KWin log

It it using intel. Log here.

You can tell KWin to always use the integrated GPU

Yeah, for me, card0 is integrated, and card1 is dedicated. Setting it to Intel totally disables my external monitor attached to the NVIDIA card. I know the dedicated card is being used because vkcube says so, but I can use only the laptop display, still no plasmashell.

Setting it to NVIDIA actually works! Well, kind of. Plasma starts as it should, and my external monitor works as well. However, I can no longer use my internal laptop display. It does not show up in system settings. It is not a big deal for me. I wouldn’t use it anyway. The problem here is that the laptop display keeps with the last SDDM frame and does not turn off. Since it is an OLED screen, having the same frame being displayed forever is a really bad idea.

Ah, so KWin uses Intel but plasmashell tries to use the NVidia GPU. The question is only why, it shouldn’t do that. But the NVidia driver failing to provide buffers usable on the Intel GPU is definitely a NVidia driver bug… I think you can report that on their forum.

Setting it to NVIDIA actually works! Well, kind of. Plasma starts as it should, and my external monitor works as well. However, I can no longer use my internal laptop display

You don’t have to make KWin only use one GPU, you can just list them, separate with colons, like this:

KWIN_DRM_DEVICES="/dev/dri/card0:/dev/dri/card1`

The first one will be used for compositing, the ones after that are just used for controlling the displays attached to them

You don’t have to make KWin only use one GPU, you can just list them, separate with colons

Thank you! When I set it to card0 (Intel) first, it produces the same behavior as before, with plasmashell not starting. However, when I set it to card1 first, everything works perfectly well, just like X11 did before. I’ll mark this as solved for now.

The question is only why, it shouldn’t do that.

You seem to be a KDE developer. Are you interested in investigating this further? If so, I could upload some logs if you point me out how to get them.

Edit: If someone else is facing the NVIDIA bug, I opened a topic about this problem on their forum. Check it out here.