Bug 448818 - Wayland display image freezes on multi-GPU VA-API usage
Summary: Wayland display image freezes on multi-GPU VA-API usage
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (other bugs)
Version First Reported In: 5.23.90
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: regression, wayland-only
Depends on:
Blocks:
 
Reported: 2022-01-20 12:16 UTC by Schlaefer
Modified: 2022-02-01 17:52 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.24
Sentry Crash Report:


Attachments
VLC plasma 5.23.90 full log - see at end for error (297.43 KB, text/plain)
2022-01-20 12:16 UTC, Schlaefer
Details
drm_info output (219.43 KB, text/plain)
2022-01-21 10:19 UTC, Schlaefer
Details
dmesg log until VLC fullscreen freeze (104.34 KB, text/x-log)
2022-01-24 17:59 UTC, Schlaefer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Schlaefer 2022-01-20 12:16:57 UTC
Created attachment 145661 [details]
VLC plasma 5.23.90 full log - see at end for error

SUMMARY
The display freezes showing a static image.

This happens on a system with a dedicated AMDGPU and Intel iGPU. AMD is the main card with all monitors connected. The iGPU is only used for certain apps to utilize the integrated media encoder/decoder. For example VLC is started with `DRI_PRIME=1 /usr/bin/vlc`.

STEPS TO REPRODUCE
1. Launch VLC with `DRI_PRIME=1 /usr/bin/vlc`
2. Start playing a video
3. Double click the video to trigger fullscreen

OBSERVED RESULT

The app goes fullscreen and display image freezes. The screen is still "there", so you can move the mouse over and interact with its content, but the display is never updated. Error:

kwin_wayland_drm: drmModeAddFB2WithModifiers on GPU "/dev/dri/card1" failed for a buffer with format XR24 and modifier 0 Invalid argument
kwin_wayland_drm: Atomic commit failed! This should never happen! Device or resource busy

EXPECTED RESULT

The display image shouldn't freeze. This was working as expected in plasma 5.23.

SOFTWARE/OS VERSIONS
Operating System: EndeavourOS
KDE Plasma Version: 5.23.90
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.15.15-237-tkg-bmq (64-bit)
Graphics Platform: Wayland
Processors: 12 × 11th Gen Intel® Core™ i5-11400 @ 2.60GHz
Memory: 31,2 GiB of RAM
Graphics Processor: AMD Radeon RX 5500 XT

ADDITIONAL INFORMATION
This happens not only with VLC but other applications started via `DRI_PRIME=1` , e.g. Firefox (wayland mode) switching a video to fullscreen. 

Fullscreen only triggers the issue immediately, often it runs fine in non-fullscreen mode but freezes eventually.
Comment 1 Vlad Zahorodnii 2022-01-21 09:47:04 UTC
Can you post the output of "drm_info"? If you use an Arch based distro, you could install it from the glorious AUR, otherwise you would need to build it yourself from source code https://github.com/ascent12/drm_info
Comment 2 Schlaefer 2022-01-21 10:19:51 UTC
Created attachment 145695 [details]
drm_info output

(In reply to Vlad Zahorodnii from comment #1)
> Can you post the output of "drm_info"? 

Done.
Comment 3 Vlad Zahorodnii 2022-01-24 11:38:44 UTC
Okay, it looks like XR24 and linear modifier are in IN_FORMATS.
Comment 4 Vlad Zahorodnii 2022-01-24 17:28:01 UTC
Can you attach the dmesg output when the screen is frozen?
Comment 5 Bug Janitor Service 2022-01-24 17:41:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1938
Comment 6 Schlaefer 2022-01-24 17:59:43 UTC
Created attachment 145871 [details]
dmesg log until VLC fullscreen freeze

(In reply to Vlad Zahorodnii from comment #4)
> Can you attach the dmesg output when the screen is frozen?

Done.
Comment 7 Zamundaaa 2022-01-24 20:38:57 UTC
Git commit db1f7414b746aec69d6ba951acf9568598fef513 by Xaver Hugl.
Committed on 24/01/2022 at 20:23.
Pushed by zamundaaa into branch 'master'.

backends/drm: add additional check for direct scanout buffers

While in principle Mesa should already check if the buffer can be scanned
out, this may not always work. If we can't create a framebuffer object for
the buffer, fall back to compositing.

M  +6    -0    src/backends/drm/egl_gbm_backend.cpp

https://invent.kde.org/plasma/kwin/commit/db1f7414b746aec69d6ba951acf9568598fef513
Comment 8 Zamundaaa 2022-01-27 13:50:41 UTC
Git commit ed80bbbaba6e9b7c4521ed892cc128cbfaaae765 by Xaver Hugl.
Committed on 27/01/2022 at 13:50.
Pushed by zamundaaa into branch 'Plasma/5.24'.

backends/drm: add additional check for direct scanout buffers

While in principle Mesa should already check if the buffer can be scanned
out, this may not always work. If we can't create a framebuffer object for
the buffer, fall back to compositing.


(cherry picked from commit db1f7414b746aec69d6ba951acf9568598fef513)

M  +6    -0    src/backends/drm/egl_gbm_backend.cpp

https://invent.kde.org/plasma/kwin/commit/ed80bbbaba6e9b7c4521ed892cc128cbfaaae765
Comment 9 Schlaefer 2022-02-01 15:54:19 UTC
I'm running a 5.24.80-git build from 2022-01-31 right now and can't replicate the issue anymore. No freezing. So it seems to be fixed.

But if I go fullscreen - triggering the former issue - there's 

```
kwin_wayland_drm: drmModeAddFB2WithModifiers on GPU "/dev/dri/card1" >
```
emitted into journald dozens of times *per second* now. (Close this bug report and file a new one for that?)
Comment 10 Nate Graham 2022-02-01 17:52:44 UTC
Yeah, go ahead.