Bug 455532

Summary: kwin_wayland_drm: Failed to find a working setup for new outputs!
Product: [Plasma] kwin Reporter: Marco Rebhan <me>
Component: platform-drmAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: asturm, hyunkang2019, nate, vincent, xaver.hugl, zawertun
Priority: VHI Keywords: regression
Version: 5.25.0   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In: 5.25.5
Sentry Crash Report:
Attachments: dmesg-drm-debug.log
kwin-drm-debug.log
dmesg DRM log, Plasma 5.25.3
kwin log, Plasma 5.25.3
GDB log of kwin crash

Description Marco Rebhan 2022-06-18 08:09:23 UTC
SUMMARY
Since Plasma 5.25, kwin_wayland no longer displays anything on the monitors in DRM mode. It seems to start up but the monitors are getting no signal, and hangs forever until killed. The same issue occurs with only one monitor connected. The log shows these lines:

kwin_wayland_drm: Failed to find a working setup for new outputs!
kwin_wayland_drm: Applying KScreen config failed!

STEPS TO REPRODUCE
1. Start kwin_wayland from display manager or TTY (e.g. 'kwin_wayland konsole')

OBSERVED RESULT
Screens get no video output

EXPECTED RESULT
Screens display graphical interface

SOFTWARE/OS VERSIONS
Operating System: Gentoo Linux 2.8
KDE Plasma Version: 5.25.0
KDE Frameworks Version: 5.95.0
Qt Version: 5.15.4
Kernel Version: 5.18.5-gentoo-dist (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor
Memory: 23.4 GiB of RAM
Graphics Processor: AMD Radeon RX Vega
Manufacturer: Micro-Star International Co., Ltd.
Product Name: MS-7C56
System Version: 2.0

ADDITIONAL INFORMATION
Log of 'kwin_wayland konsole':

No backend specified through command line argument, trying auto resolution
MESA-LOADER: failed to open simpledrm: /usr/lib64/dri/simpledrm_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib64/dri, suffix _dri)
failed to load driver: simpledrm
MESA-LOADER: failed to open zink: /usr/lib64/dri/zink_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib64/dri, suffix _dri)
failed to load driver: zink
kf.globalaccel.kglobalacceld: Failed to register service org.kde.kglobalaccel
OpenGL vendor string:                   AMD
OpenGL renderer string:                 AMD Radeon RX Vega (vega10, LLVM 14.0.5, DRM 3.46, 5.18.5-gentoo-dist)
OpenGL version string:                  4.6 (Core Profile) Mesa 22.1.2
OpenGL shading language version string: 4.60
Driver:                                 Unknown
GPU class:                              Unknown
OpenGL version:                         4.6
GLSL version:                           4.60
Mesa version:                           22.1.2
Linux kernel version:                   5.18.5
Requires strict binding:                no
GLSL shaders:                           yes
Texture NPOT support:                   yes
Virtual Machine:                        no
kwin_wayland_drm: Failed to find a working setup for new outputs!
kwin_wayland_drm: Applying KScreen config failed!
Couldn't start kglobalaccel from org.kde.kglobalaccel.service: QDBusError("org.freedesktop.DBus.Error.Disconnected", "Not connected to D-Bus server")
kwin_xkbcommon: XKB: inet:323:58: unrecognized keysym "XF86EmojiPicker"
kwin_xkbcommon: XKB: inet:324:58: unrecognized keysym "XF86Dictate"
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimal, offscreen, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb
Comment 1 Marco Rebhan 2022-06-18 11:40:24 UTC
A git bisect shows c65c8223 "backends/drm: refactor buffer management" to be the first bad commit.

https://invent.kde.org/plasma/kwin/-/commit/c65c82239269c2db03e1e27c1b1262665cbdff66
Comment 2 Zamundaaa 2022-06-22 08:59:17 UTC
Can you run the script at https://invent.kde.org/plasma/kwin/-/wikis/Debugging-DRM-issues in a tty and upload the two log files it generates?
Comment 3 Marco Rebhan 2022-06-22 09:47:09 UTC
Created attachment 150042 [details]
dmesg-drm-debug.log
Comment 4 Marco Rebhan 2022-06-22 09:47:37 UTC
Created attachment 150043 [details]
kwin-drm-debug.log
Comment 5 Zamundaaa 2022-06-22 11:08:32 UTC
Ok, this is almost certainly a duplicate of bug 454086. Please test again with 5.25.1
Comment 6 Marco Rebhan 2022-06-22 16:02:34 UTC
With 5.25.1, I get a black background and the mouse cursor but nothing else. The log contains these lines:

kwin_wayland_drm: Could not create drm framebuffer! Invalid argument
kwin_wayland_drm: Could not create drm framebuffer! Invalid argument
kwin_wayland_drm: Failed to create gamma blob! Invalid argument
kwin_wayland_drm: Failed to create a gbm surface!
The Wayland connection broke. Did the Wayland compositor die?

I should probably create a new bug for that, right?
Comment 7 Hyuk 2022-06-30 09:02:13 UTC
(In reply to Marco Rebhan from comment #6)
> With 5.25.1, I get a black background and the mouse cursor but nothing else.
> The log contains these lines:
> 
> kwin_wayland_drm: Could not create drm framebuffer! Invalid argument
> kwin_wayland_drm: Could not create drm framebuffer! Invalid argument
> kwin_wayland_drm: Failed to create gamma blob! Invalid argument
> kwin_wayland_drm: Failed to create a gbm surface!
> The Wayland connection broke. Did the Wayland compositor die?
> 
> I should probably create a new bug for that, right?

same here. :(
Comment 8 Bug Janitor Service 2022-07-15 04:36:57 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 9 Marco Rebhan 2022-07-15 10:58:28 UTC
Ah right, I guess I should change this back to Reported or what it was before?
Comment 10 Andreas Sturmlechner 2022-07-15 18:09:07 UTC
Did you test 5.25.3 already?
Comment 11 Marco Rebhan 2022-07-20 08:25:18 UTC
(In reply to Andreas Sturmlechner from comment #10)
> Did you test 5.25.3 already?

That one gives me a slightly different error yet again:

> kwin_wayland_drm: Failed to create framebuffer for multi-gpu: Invalid argument
> kwin_wayland_drm: Failed to create framebuffer for CPU import: Invalid argument
> kwin_wayland_drm: Failed to create gamma blob! Invalid argument

And as with 5.25.1, only a black screen with cursor. I'll upload the new log files.
Comment 12 Marco Rebhan 2022-07-20 08:26:10 UTC
Created attachment 150763 [details]
dmesg DRM log, Plasma 5.25.3
Comment 13 Marco Rebhan 2022-07-20 08:26:53 UTC
Created attachment 150764 [details]
kwin log, Plasma 5.25.3
Comment 14 Zamundaaa 2022-07-23 12:08:57 UTC
afaict, the warnings are about the kernel failing our request to create buffers for the cursor; KWin just falls back to a software cursor in that case.

When you have the black screen with a cursor, can you move it around? Also, can you still start apps with shortcuts?
Comment 15 Marco Rebhan 2022-07-25 10:51:11 UTC
Created attachment 150900 [details]
GDB log of kwin crash

Yes, I can move the cursor around. I can't start anything directly from kwin, since it doesn't run the argument you pass to it from the command line in this state and none of the shortcuts work (tried meta+e, alt+space, and meta+enter which I've bound to open konsole). What I could do is run a program from a SSH shell (kwin segfaults if I switch to another TTY) such as dolphin:

    WAYLAND_DISPLAY=wayland-0 QT_QPA_PLATFORM=wayland dolphin

It does show up and I can interact with it using the keyboard, but as soon as my mouse cursor gets within maybe 20 pixels of the window, kwin segfaults. According to GDB (see attached log), it has to do with the cursor.
Comment 16 Bug Janitor Service 2022-08-04 16:15:50 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2779
Comment 17 Zamundaaa 2022-08-04 16:16:47 UTC
that MR should fix the crash you're seeing. Is the segfault when you switch to a different tty the same, or does it crash somewhere else?
Comment 18 Nate Graham 2022-08-05 16:48:32 UTC
Marco, are you able to test that merge request? That would be very helpful.
Comment 19 Marco Rebhan 2022-08-05 19:09:12 UTC
I hope I can test it by tomorrow.
Comment 20 Andreas Sturmlechner 2022-08-06 09:18:06 UTC
(In reply to Marco Rebhan from comment #19)
> I hope I can test it by tomorrow.
You probably know anyway, but just in case: https://wiki.gentoo.org/wiki//etc/portage/patches
Comment 21 Marco Rebhan 2022-08-06 17:10:23 UTC
That patch does indeed fix it. Thanks!

(In reply to Andreas Sturmlechner from comment #20)
> (In reply to Marco Rebhan from comment #19)
> > I hope I can test it by tomorrow.
> You probably know anyway, but just in case:
> https://wiki.gentoo.org/wiki//etc/portage/patches

I knew about this, but thanks. The patch didn't apply on top of the latest kwin release though, so I had to use the live ebuild.
Comment 22 Zamundaaa 2022-08-09 21:43:52 UTC
Git commit 9f41620b77013258fb84136082693febd365d6b7 by Xaver Hugl.
Committed on 09/08/2022 at 20:18.
Pushed by zamundaaa into branch 'master'.

backends/drm: don't crash if beginFrame fails

M  +1    -1    src/backends/drm/drm_egl_cursor_layer.cpp
M  +1    -1    src/backends/drm/drm_egl_cursor_layer.h
M  +1    -1    src/backends/drm/drm_egl_layer.cpp
M  +1    -1    src/backends/drm/drm_egl_layer.h
M  +5    -5    src/backends/drm/drm_egl_layer_surface.cpp
M  +1    -1    src/backends/drm/drm_egl_layer_surface.h
M  +13   -14   src/backends/drm/drm_output.cpp
M  +5    -5    src/backends/drm/drm_qpainter_layer.cpp
M  +3    -3    src/backends/drm/drm_qpainter_layer.h
M  +3    -3    src/backends/drm/drm_virtual_egl_layer.cpp
M  +1    -1    src/backends/drm/drm_virtual_egl_layer.h
M  +1    -1    src/backends/virtual/virtual_egl_backend.cpp
M  +1    -1    src/backends/virtual/virtual_egl_backend.h
M  +1    -1    src/backends/virtual/virtual_qpainter_backend.cpp
M  +2    -2    src/backends/virtual/virtual_qpainter_backend.h
M  +1    -1    src/backends/wayland/wayland_egl_backend.cpp
M  +1    -1    src/backends/wayland/wayland_egl_backend.h
M  +1    -1    src/backends/wayland/wayland_qpainter_backend.cpp
M  +1    -1    src/backends/wayland/wayland_qpainter_backend.h
M  +1    -1    src/backends/x11/standalone/x11_standalone_egl_backend.cpp
M  +1    -1    src/backends/x11/standalone/x11_standalone_egl_backend.h
M  +1    -1    src/backends/x11/standalone/x11_standalone_glx_backend.cpp
M  +1    -1    src/backends/x11/standalone/x11_standalone_glx_backend.h
M  +1    -1    src/backends/x11/windowed/x11_windowed_egl_backend.cpp
M  +1    -1    src/backends/x11/windowed/x11_windowed_egl_backend.h
M  +1    -1    src/backends/x11/windowed/x11_windowed_qpainter_backend.cpp
M  +1    -1    src/backends/x11/windowed/x11_windowed_qpainter_backend.h
M  +8    -6    src/composite.cpp
M  +2    -1    src/outputlayer.h

https://invent.kde.org/plasma/kwin/commit/9f41620b77013258fb84136082693febd365d6b7
Comment 23 Zamundaaa 2022-08-09 22:28:16 UTC
Git commit 978fbd276366ab59cb7190778cf9521e5f2ff63c by Xaver Hugl.
Committed on 09/08/2022 at 22:25.
Pushed by zamundaaa into branch 'Plasma/5.25'.

backends/drm: don't crash if beginFrame fails
(cherry picked from commit 9f41620b77013258fb84136082693febd365d6b7)

M  +2    -2    src/backends/drm/drm_lease_egl_gbm_layer.cpp
M  +1    -1    src/backends/drm/drm_lease_egl_gbm_layer.h
M  +13   -14   src/backends/drm/drm_output.cpp
M  +7    -7    src/backends/drm/drm_qpainter_layer.cpp
M  +4    -4    src/backends/drm/drm_qpainter_layer.h
M  +1    -1    src/backends/drm/egl_gbm_cursor_layer.cpp
M  +1    -1    src/backends/drm/egl_gbm_cursor_layer.h
M  +1    -1    src/backends/drm/egl_gbm_layer.cpp
M  +1    -1    src/backends/drm/egl_gbm_layer.h
M  +5    -5    src/backends/drm/egl_gbm_layer_surface.cpp
M  +1    -1    src/backends/drm/egl_gbm_layer_surface.h
M  +3    -3    src/backends/drm/virtual_egl_gbm_layer.cpp
M  +1    -1    src/backends/drm/virtual_egl_gbm_layer.h
M  +1    -1    src/backends/virtual/egl_gbm_backend.cpp
M  +1    -1    src/backends/virtual/egl_gbm_backend.h
M  +1    -1    src/backends/virtual/scene_qpainter_virtual_backend.cpp
M  +1    -2    src/backends/virtual/scene_qpainter_virtual_backend.h
M  +1    -1    src/backends/wayland/egl_wayland_backend.cpp
M  +1    -1    src/backends/wayland/egl_wayland_backend.h
M  +1    -1    src/backends/wayland/scene_qpainter_wayland_backend.cpp
M  +1    -1    src/backends/wayland/scene_qpainter_wayland_backend.h
M  +1    -1    src/backends/x11/standalone/eglbackend.cpp
M  +1    -1    src/backends/x11/standalone/eglbackend.h
M  +1    -1    src/backends/x11/standalone/glxbackend.cpp
M  +1    -1    src/backends/x11/standalone/glxbackend.h
M  +1    -1    src/backends/x11/windowed/egl_x11_backend.cpp
M  +1    -1    src/backends/x11/windowed/egl_x11_backend.h
M  +1    -1    src/backends/x11/windowed/scene_qpainter_x11_backend.cpp
M  +1    -1    src/backends/x11/windowed/scene_qpainter_x11_backend.h
M  +8    -6    src/composite.cpp
M  +2    -1    src/outputlayer.h

https://invent.kde.org/plasma/kwin/commit/978fbd276366ab59cb7190778cf9521e5f2ff63c
Comment 24 Zamundaaa 2022-08-09 22:31:02 UTC
Does the patch only fix the specific crash you mentioned, or is the session working properly now?
Comment 25 Marco Rebhan 2022-08-10 22:03:29 UTC
(In reply to Zamundaaa from comment #24)
> Does the patch only fix the specific crash you mentioned, or is the session
> working properly now?

Yep, the session is working properly now. It also isn't segfaulting anymore when I change tty.
Comment 26 Nate Graham 2022-08-10 22:21:02 UTC
Great!