Bug 455771 - Plasma Wayland (5.25.1) freezing glitches on gaming
Summary: Plasma Wayland (5.25.1) freezing glitches on gaming
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (show other bugs)
Version: 5.25.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-22 03:51 UTC by McCak
Modified: 2022-07-01 00:50 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description McCak 2022-06-22 03:51:50 UTC
SUMMARY
Plasma Wayland (5.25.1) freezing glitches on gaming.. Morelikely a hiccups of freezes..

STEPS TO REPRODUCE
1. Login to Plasma Wayland 
2. Run Games
3. Wait several sec

OBSERVED RESULT
freezes happen.. need to do Alt + Tab to fix this but happen every several sec
EXPECTED RESULT
Normal gaming time 

SOFTWARE/OS VERSIONS

Linux : Arch Linux
KDE Plasma Version: 5.25.1
KDE Frameworks Version: 5.95.0
Qt Version: 5.15.5
Mesa : 22.1.2-1

ADDITIONAL INFORMATION
I only tested to game with fullscreen and borderless option.. that is Apex Legends and Control.. Which is both of em installed on my Machine and from steam with Proton 7.0.3.. 

Hardware Specifications
Laptop : MSI Delta 15
CPU :Ryzen 7 5800H
GPU0 : RX 6700M 
GPU1: Vega 8
Monitor Freesync : Enabled

Logs
There is no stack trace or Coredump but i see repeat message on journalctl

kwin_wayland[1335]: kwin_wayland_drm: Atomic commit failed! This should never happen! Invalid argument 
kwin_wayland[1335]: kwin_wayland_drm: Presentation failed! Invalid argument

and some of em are

kernel: [drm:dm_plane_helper_prepare_fb [amdgpu]] *ERROR* Failed to pin framebuffer with error -22
kernel: [drm:dm_plane_helper_prepare_fb [amdgpu]] *ERROR* Failed to pin framebuffer with error -22
Comment 1 Zamundaaa 2022-06-22 08:40:27 UTC
This sounds a lot like a driver bug, if the atomic test works, the atomic commit must not fail.

I assume you're running the games on the dedicated GPU, but displaying them on the laptop screen?
Does setting one or both of these environment variables make a difference?
KWIN_DRM_USE_MODIFIERS=0
KWIN_DRM_NO_DIRECT_SCANOUT=1
Comment 2 McCak 2022-06-22 08:59:37 UTC
(In reply to Zamundaaa from comment #1)
> This sounds a lot like a driver bug, if the atomic test works, the atomic
> commit must not fail.
> 
> I assume you're running the games on the dedicated GPU, but displaying them
> on the laptop screen?
> Does setting one or both of these environment variables make a difference?
> KWIN_DRM_USE_MODIFIERS=0
> KWIN_DRM_NO_DIRECT_SCANOUT=1

No.. I try to run the game on dedicated GPU but on external monitor which is connected directly to the dGPU.. the laptop monitor is disabled.. but i will try your method and will report it..
Comment 3 McCak 2022-06-22 11:32:11 UTC
(In reply to Zamundaaa from comment #1)
> This sounds a lot like a driver bug, if the atomic test works, the atomic
> commit must not fail.
> 
> I assume you're running the games on the dedicated GPU, but displaying them
> on the laptop screen?
> Does setting one or both of these environment variables make a difference?
> KWIN_DRM_USE_MODIFIERS=0
> KWIN_DRM_NO_DIRECT_SCANOUT=1

Alr.. tried that by exporting those env var and making sure its already loaded.. same issue still happen..
Comment 4 Zamundaaa 2022-06-22 14:28:34 UTC
Where did you export them? kwin_wayland needs to get them. Easiest way to ensure that is to put them into /etc/environment and rebooting
Comment 5 McCak 2022-06-23 00:03:13 UTC
(In reply to Zamundaaa from comment #4)
> Where did you export them? kwin_wayland needs to get them. Easiest way to
> ensure that is to put them into /etc/environment and rebooting

oh yeah turns out the testing was wrong on my end.. yeah after adding those env var the problem seems gone..Do u know exactly what happen here?
Comment 6 Matej Starc 2022-06-30 13:34:34 UTC
Had the same issue, and it has been fixed by those env variables (at least it hasn't crashed so far).
Comment 7 Zamundaaa 2022-06-30 20:00:26 UTC
(In reply to McCak from comment #5)
> (In reply to Zamundaaa from comment #4)
> > Where did you export them? kwin_wayland needs to get them. Easiest way to
> > ensure that is to put them into /etc/environment and rebooting
> 
> oh yeah turns out the testing was wrong on my end.. yeah after adding those
> env var the problem seems gone..Do u know exactly what happen here?

Sorry about missing your response. The issue is caused by KWin directly using buffers from the game to drive the display (direct scanout); the driver tells KWin that doing that will work and yet when actually trying to present an image it fails.

I'll ask around if compositors are expected to handle this situation but I think this is something the driver has to prevent 100% of the time or things will get a lot more complicated for compositors. 

Either way, this is a driver bug, can you report it to https://gitlab.freedesktop.org/drm/amd/-/issues?
The relevant things to mention are that atomic commits fail with direct scanout on the dedicated GPU, and the error message you found before (kernel: [drm:dm_plane_helper_prepare_fb [amdgpu]] *ERROR* Failed to pin framebuffer with error -22). If you link the issue here I'll try to provide any additional information that could help
Comment 8 McCak 2022-07-01 00:04:19 UTC
 - Dmesg log (full log)
 - Xorg log
 - Any other log(In reply to Zamundaaa from comment #7)
> (In reply to McCak from comment #5)
> > (In reply to Zamundaaa from comment #4)
> > > Where did you export them? kwin_wayland needs to get them. Easiest way to
> > > ensure that is to put them into /etc/environment and rebooting
> > 
> > oh yeah turns out the testing was wrong on my end.. yeah after adding those
> > env var the problem seems gone..Do u know exactly what happen here?
> 
> Sorry about missing your response. The issue is caused by KWin directly
> using buffers from the game to drive the display (direct scanout); the
> driver tells KWin that doing that will work and yet when actually trying to
> present an image it fails.
> 
> I'll ask around if compositors are expected to handle this situation but I
> think this is something the driver has to prevent 100% of the time or things
> will get a lot more complicated for compositors. 
> 
> Either way, this is a driver bug, can you report it to
> https://gitlab.freedesktop.org/drm/amd/-/issues?
> The relevant things to mention are that atomic commits fail with direct
> scanout on the dedicated GPU, and the error message you found before
> (kernel: [drm:dm_plane_helper_prepare_fb [amdgpu]] *ERROR* Failed to pin
> framebuffer with error -22). If you link the issue here I'll try to provide
> any additional information that could help

I already report it to there and this is the link https://gitlab.freedesktop.org/drm/amd/-/issues/2075 just ask me there if u need some info..
Comment 9 Zamundaaa 2022-07-01 00:50:33 UTC
good, let's continue tracking it there then