Bug 495843 - Exiting and playing Dota2 will generate a lot of logs with warning "kwin_wayland_drm: atomic commit failed: Invalid argument"
Summary: Exiting and playing Dota2 will generate a lot of logs with warning "kwin_wayl...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (show other bugs)
Version: 6.2.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-05 15:02 UTC by Sigmund
Modified: 2024-11-22 17:00 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.2.4
Sentry Crash Report:


Attachments
30000 logs (2.80 MB, text/x-log)
2024-11-05 15:02 UTC, Sigmund
Details
drm-debug.00 (3.24 MB, application/x-7z-compressed)
2024-11-06 13:21 UTC, Sigmund
Details
drm-debug.01 (3.26 MB, application/x-7z-compressed)
2024-11-06 13:22 UTC, Sigmund
Details
drm-debug.02 (1.65 MB, application/x-7z-compressed)
2024-11-06 13:24 UTC, Sigmund
Details
Output of drm_info (119.42 KB, text/plain)
2024-11-18 01:50 UTC, Vojtěch Holub
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sigmund 2024-11-05 15:02:30 UTC
Created attachment 175549 [details]
30000 logs

SUMMARY
Exiting and playing Dota2 generates a lot of logs with message "kwin_wayland_drm: atomic commit failed: Invalid argument". These messages are taking up a lot of my storage.

I played dota2 for half an hour and there were about 30w warnings with the same content in logs. It is insane.

[System information generated by Steam](https://gist.github.com/1nj0k/a75a7a174e076e72b863a0d8e35edd8f)
[Steam Runtime Diagnostics](https://gist.github.com/1nj0k/d68f3af37b8486d7a48bd8d334a205a5)

I also reported it in github.(https://github.com/ValveSoftware/Dota-2/issues/2845)

STEPS TO REPRODUCE
1. Launch dota2
2. Exit it and check logs or play dota2 than check logs

OBSERVED RESULT
1. Too many logs with warning "kwin_wayland_drm: atomic commit failed: Invalid argument"

EXPECTED RESULT
1. No warning

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.2.2
KDE Frameworks Version: 6.7.0
Qt Version: 6.8.0
Kernel Version: 6.11.6-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 32 × AMD Ryzen 9 9950X 16-Core Processor
Memory: 60.4 GiB of RAM
Graphics Processor: AMD Radeon RX 7800 XT
Comment 1 Zamundaaa 2024-11-05 16:03:07 UTC
Please attach the output of drm_info, so we can get basic information about your GPU and display setup.
To figure out exactly why the driver fails the commit, we'll need to use drm debug logging. Just enable it, have the game fullscreen for a few seconds, and then you can disable it again. https://invent.kde.org/plasma/kwin/-/wikis/Debugging-DRM-issues describes how to do that, and how to get the logs from it.
Comment 2 Sigmund 2024-11-06 13:21:15 UTC
Created attachment 175578 [details]
drm-debug.00
Comment 3 Sigmund 2024-11-06 13:22:56 UTC
Created attachment 175579 [details]
drm-debug.01
Comment 4 Sigmund 2024-11-06 13:24:21 UTC
Created attachment 175580 [details]
drm-debug.02
Comment 5 Sigmund 2024-11-06 13:27:36 UTC
(In reply to Zamundaaa from comment #1)
> Please attach the output of drm_info, so we can get basic information about
> your GPU and display setup.
> To figure out exactly why the driver fails the commit, we'll need to use drm
> debug logging. Just enable it, have the game fullscreen for a few seconds,
> and then you can disable it again.
> https://invent.kde.org/plasma/kwin/-/wikis/Debugging-DRM-issues describes
> how to do that, and how to get the logs from it.

I split one drm-debug log into three.

Hope these logs can help.
Comment 6 Nate Graham 2024-11-08 21:25:59 UTC
Maybe https://gitlab.freedesktop.org/drm/amd/-/issues/2075?
Comment 7 Sigmund 2024-11-09 07:08:40 UTC
Ahhh, I think they are different things. For my logs are different from them and I use desktop. I also tried their solutions, didn't work.
Comment 8 Vojtěch Holub 2024-11-18 01:17:21 UTC
I can reproduce this by running `vkcube --present_mode 0` (VK_PRESENT_MODE_IMMEDIATE_KHR) and forcing fullscreen (ALT+F3 menu). This message appears when I actively move the mouse cursor over the screen - the cube rendering can be paused (SPACE).

I had the same problem with Dead by Daylight (game is using system cursor in menu/lobby), enabling vsync in game settings stopped the message from appearing. If I remember correctly, this started with Plasma 6.2. Maybe it's related to the atomic tearing changes?

`kwin_wayland_drm: atomic commit failed: Invalid argument` is the only message (one per frame), no kernel errors.


Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.11.7-300.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5700X 8-Core Processor
Memory: 31.2 GiB of RAM
Graphics Processor: AMD Radeon RX 6700 XT
Comment 9 Vojtěch Holub 2024-11-18 01:50:23 UTC
Created attachment 175898 [details]
Output of drm_info

My drm_info
Comment 10 Zamundaaa 2024-11-22 01:00:25 UTC
From the log, it's evident that KWin is trying to disable the cursor plane, so that it can enable tearing:

[  799.322487] amdgpu 0000:03:00.0: [drm:drm_ioctl] comm="DP-2" pid=1487, dev=0xe201, auth=1, DRM_IOCTL_MODE_ATOMIC
[  799.322488] amdgpu 0000:03:00.0: [drm:drm_atomic_state_init] Allocated atomic state 0000000016f80ea3
[  799.322489] amdgpu 0000:03:00.0: [drm:drm_atomic_get_plane_state] Added [PLANE:76:plane-6] 000000007791a1e9 state to 0000000016f80ea3
[  799.322490] amdgpu 0000:03:00.0: [drm:drm_atomic_set_fb_for_plane] Set [NOFB] for [PLANE:76:plane-6] state 000000007791a1e9
[  799.322490] amdgpu 0000:03:00.0: [drm:drm_mode_atomic_ioctl] need at least one CRTC for DRM_MODE_PAGE_FLIP_EVENT
[  799.322491] amdgpu 0000:03:00.0: [drm:drm_atomic_state_default_clear] Clearing atomic state 0000000016f80ea3
[  799.322492] amdgpu 0000:03:00.0: [drm:__drm_atomic_state_free] Freeing atomic state 0000000016f80ea3
[  799.322493] amdgpu 0000:03:00.0: [drm:drm_ioctl] comm="DP-2", pid=1487, ret=-22
[  799.322495] amdgpu 0000:03:00.0: [drm:drm_ioctl] comm="DP-2" pid=1487, dev=0xe201, auth=1, DRM_IOCTL_MODE_ATOMIC

that "need at least one CRTC for DRM_MODE_PAGE_FLIP_EVENT" means that the cursor plane is already disabled, so KWin is doing nonsense.
Comment 11 Bug Janitor Service 2024-11-22 01:06:08 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6817
Comment 12 Zamundaaa 2024-11-22 14:32:31 UTC
Git commit 769c896cdb5fba5f4078b3cb310ccf98f7c26f3a by Xaver Hugl.
Committed on 22/11/2024 at 14:09.
Pushed by zamundaaa into branch 'master'.

compositor_wayland: don't commit cursor changes if the layer wasn't actually enabled

The drm backend doesn't handle changes that do this well, as it requests a pageflip event and the
kernel can't give us a pageflip event for an already-disabled plane.

M  +5    -2    src/compositor_wayland.cpp

https://invent.kde.org/plasma/kwin/-/commit/769c896cdb5fba5f4078b3cb310ccf98f7c26f3a
Comment 13 Zamundaaa 2024-11-22 14:32:39 UTC
Git commit b8a16bffa619adc34c9ea6911a71616a0ade3618 by Xaver Hugl.
Committed on 22/11/2024 at 14:09.
Pushed by zamundaaa into branch 'master'.

backends/drm: reject cursor updates already in beginFrame

This avoids rendering the hardware cursor image each time while tearing is enabled, only to
then throw the result away when updating the plane fails

M  +1    -1    src/backends/drm/drm_egl_layer.cpp
M  +9    -4    src/backends/drm/drm_output.cpp
M  +1    -0    src/backends/drm/drm_output.h

https://invent.kde.org/plasma/kwin/-/commit/b8a16bffa619adc34c9ea6911a71616a0ade3618
Comment 14 Zamundaaa 2024-11-22 15:29:11 UTC
Git commit 04b329a14a783f3c80c14b8413586e9a725531f3 by Xaver Hugl.
Committed on 22/11/2024 at 14:51.
Pushed by zamundaaa into branch 'Plasma/6.2'.

compositor_wayland: don't commit cursor changes if the layer wasn't actually enabled

The drm backend doesn't handle changes that do this well, as it requests a pageflip event and the
kernel can't give us a pageflip event for an already-disabled plane.
(cherry picked from commit 769c896cdb5fba5f4078b3cb310ccf98f7c26f3a)

M  +5    -2    src/compositor_wayland.cpp

https://invent.kde.org/plasma/kwin/-/commit/04b329a14a783f3c80c14b8413586e9a725531f3
Comment 15 Zamundaaa 2024-11-22 15:29:19 UTC
Git commit 0539f18f7afcadbe95db991f85db6eb550d65041 by Xaver Hugl.
Committed on 22/11/2024 at 14:51.
Pushed by zamundaaa into branch 'Plasma/6.2'.

backends/drm: reject cursor updates already in beginFrame

This avoids rendering the hardware cursor image each time while tearing is enabled, only to
then throw the result away when updating the plane fails
(cherry picked from commit b8a16bffa619adc34c9ea6911a71616a0ade3618)

M  +1    -1    src/backends/drm/drm_egl_layer.cpp
M  +9    -4    src/backends/drm/drm_output.cpp
M  +1    -0    src/backends/drm/drm_output.h

https://invent.kde.org/plasma/kwin/-/commit/0539f18f7afcadbe95db991f85db6eb550d65041