Bug 454639 - amdgpu driver: Flickering in Wayland session after suspend without lock screen enabled
Summary: amdgpu driver: Flickering in Wayland session after suspend without lock scree...
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.24.5
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-31 07:36 UTC by Jan Rathmann
Modified: 2024-01-06 08:21 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
jan.rathmann: Wayland+


Attachments
Video showing the flickering (2.92 MB, video/webm)
2022-05-31 07:36 UTC, Jan Rathmann
Details
Output of lshw (27.99 KB, text/plain)
2022-05-31 07:37 UTC, Jan Rathmann
Details
radeon driver: Corrupted screen after suspend (764.48 KB, video/webm)
2022-05-31 07:38 UTC, Jan Rathmann
Details
Output of lshw in english (25.42 KB, text/plain)
2022-05-31 07:44 UTC, Jan Rathmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Rathmann 2022-05-31 07:36:27 UTC
Created attachment 149345 [details]
Video showing the flickering

This is a follow-up report to https://bugs.kde.org/show_bug.cgi?id=447705

Steps how I experience the bug:
* Use Plasma Wayland session, screenlocking disabled, GPU driver set to amdgpu (see below)
* Do Suspend-to-RAM.
* Resume.

Result:
Sometimes heavy flickering of the whole screen, it goes away if I click on UI elements (see attached video).

Happens always?:
No. At the first resumes after boot chances are good that everythings's fine. But when flickering has happend one time, it seems it will also flicker on all subsequent resumes (until rebooting).

(I rarely see a similar flickering in Firefox at Firefox startup or when a new browser tab loads [usually only a small square part of the window is affected, it goes away almost immediately  <1 second. Not sure if it is related.].)

Additional notes:

Kubuntu 22.04 + Backports-PPA
Plasma 5.24.5
Frameworks: 5.94.0
Qt: 5.15.3
Kernel: 5.15.0-33-generic

== My system ==
Board: Gigabyte P35-DS3
CPU: Intel Core2Quad Q9550
Graphics card: Asus Radeon R7 240

Note that my graphics card can work with two different drivers: 
The default driver is radeon but amdgpu also works by manually enabling it by adding the following boot optionts to the linux command line in Grub:

radeon.si_support=0 radeon.cik_support=0 amdgpu.si_support=1 amdgpu.cik_support=1

For at least a year(?) I solely used amdgpu on my system (the initial reason was something like amdgpu worked slightly better than radeon at one minor aspect, but I don't remember exactly anymore). Using amdgpu was so ubiquitous for me that I didn't even remember it when writing the original bug report.

For debugging purpose I tested how suspend/resume behaves with radeon driver in use (both on Wayland and X11), and it is different:

Resume from suspend under Wayland:
* amdgpu: flickers sometimes, as described above.
* radeon: no flickering, but even worse: graphics output completely distorted and corrupted (see attached video). Sometimes temporarily switching between different TTYs (Ctrl+Alt+F1-7) restores the desktop, when it does not it effectively crashes the whole session.
Resume from suspend under X11:
* Everything fine, no flicker (amdgpu), no corruption (radeon)

I also tested (under Wayland) what happens if the lock screen is enabled after suspend:
* amdgpu: Everythings fine now, couldn't reproduce the flickering anymore
* radeon: corrupted screen, as described above

Sorry it took so long to report this follow-up report, it took some time to investigate and test all those different subtly different surrounding conditions.

Kind regards, Jan
Comment 1 Jan Rathmann 2022-05-31 07:37:19 UTC
Created attachment 149346 [details]
Output of lshw
Comment 2 Jan Rathmann 2022-05-31 07:38:26 UTC
Created attachment 149347 [details]
radeon driver: Corrupted screen after suspend
Comment 3 Jan Rathmann 2022-05-31 07:44:36 UTC
Created attachment 149348 [details]
Output of lshw in english

Sorry, the output of lshw I first posted was in german, attaching an english version.
Comment 4 Javier Steinaker 2022-06-02 20:06:06 UTC
(In reply to Jan Rathmann from comment #2)
> Created attachment 149347 [details]
> radeon driver: Corrupted screen after suspend

Jan, the exact same thing is happening to me ever since I've switched to Plasma (using Wayland). I'm using an old HP Sleekbook 14 (old AMD card, radeon graphics driver) and I get the same results as you. Things I've tried:

- Disabling screen lock on suspend: same results, so likely kscreenlocker is not the culprit.
- Using a different DE/Compositor: resuming behaves correctly (tested on Sway and gtkgreet using Cage), so it seems to be a Plasma thing.

Running updated Arch Linux here. Might be a little difficult for me to try patches, unstable versions and the like since this is an old computer, but I can provide logs and run some tests if the devs need them.
Comment 5 Jan Rathmann 2022-06-04 09:22:59 UTC
Javier, is your card also supported by the amdgpu driver? (You can check by running 'lspci -k' and see if there is a line that says something like "Kernel modules: radeon, amdgpu") If yes, it could be helpful if you try it out and see if you can confirm the behaviour that I'm getting when using amdgpu (flickering when lock screen is disabled).

Have you tested if everything works fine when you use Plasma X11 session instead? This would also be interesting to know.
Comment 6 Javier Steinaker 2022-06-04 21:02:23 UTC
No, unfortunately my card is not supported, there's no way I'd be using the radeon driver if AMDGPU was available. About the Plasma X11 thing, I gave it a try the other day, the session never started, and I kind of gave up for now. Might give it a try again in a few days.
Comment 7 Javier Steinaker 2022-06-05 22:44:55 UTC
Ok so I did the test using a Fedora KDE Live CD and suspending and resuming a Wayland session brings the same results to the table. On the X11 session suspending and resuming works fine for me.
Comment 8 Jan Rathmann 2022-10-15 09:05:00 UTC
Update: I recently got a new PC and I don't see the bug there anymore, without changing anything on the installed OS.

For graphics now I use the integrated GPU of the Ryzen 7 5700G that also uses the amdgpu driver, same as before. So this bug may be a special problem related to my old graphics card, an Asus Radeon R7 240.

For other people still affected, I can present you a really ugly workaround that nevertheless worked for me:

* Create  a systemd service roughly like this (Don't know if all of those environment variables are actually necessary. Don't forget to insert your actual user name/computer name etc.):
------------------------
[Unit]
Description=Workaround to fix flickering after suspend under Wayland
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target


[Service]
ExecStart=/path/to/kwin-suspend-fix-flicker.sh
User=YOUR_USER_NAME
Environment=DISPLAY=:1
Environment=DESKTOP_SESSION="plasmawayland"
Environment=DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/YOUR_NUMERICAL_USERID/bus"
Environment=SESSION_MANAGER="local/YOUR_COMPUTER_NAME:@/tmp/.ICE-unix/1467,unix/YOUR_COMPUTER_NAME:/tmp/.ICE-unix/1467"
Environment=XDG_RUNTIME_DIR="/run/user/YOUR_NUMERICAL_USERID"
Environment=DESKTOP_SESSION="plasmawayland"
declare -x DISPLAY=":1"
Environment=XDG_SEAT_PATH="/org/freedesktop/DisplayManager/Seat0"
Environment=XDG_SESSION_PATH="/org/freedesktop/DisplayManager/Session2"
Environment=XDG_SESSION_TYPE="wayland"
[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
------------------------

* Then create a script kwin-suspend-fix-flicker.sh :
------------------------
#!/bin/bash
qdbus org.kde.KWin /component/kwin org.kde.kglobalaccel.Component.invokeShortcut "MinimizeAll"
sleep 0.5
qdbus org.kde.KWin /component/kwin org.kde.kglobalaccel.Component.invokeShortcut "MinimizeAll"
------------------------
This will run the Kwin effect "Minimize all" to stop the flickering, and the run the same effect a second time to restore the original positions of all windows.
Comment 9 Nate Graham 2022-10-15 14:00:33 UTC
It makes a lot of sense this this would be a GPU driver issue, yeah. You can file those at https://gitlab.freedesktop.org/drm/amd/-/issues.
Comment 10 WojtasJD 2023-04-23 14:24:03 UTC
I have similar issue with corrupted screen ( https://bugsfiles.kde.org/attachment.cgi?id=149347 ) in:
- openSUSE 15.4, kernel 5.14.x and KDE Plasma 5.24.4 (installed on disk) 
- neon-user-20230420-0722.iso (kernel 5.19; KDE Plasma 5.27.4 ; with user "neon" logged out from X11 and logged in to Wayland live session)

I have AMD Radeon HD 6570 (GPU name: TURKS, generation: Northern Islands) -  with radeon driver; amdgpu does not support this card.

In my case I don't need to suspend the machine, it is enough to switch from TTY1...6 (text login prompt) to TTY8 (Plasma) and screen is corrupted (with good mouse cursor).
To 'repair' this I need to switch to TTY7 (SDDM) and back to TTY8 (Plasma).
After repair, again switching to TTY1...6 (but not TTY7 (SDDM)) and back to TTY8 (Plasma) - screen is distorted (with good mouse cursor)...

Same behavior with KDE neon (TTY numbers different).
Comment 11 Francisco González 2023-05-09 22:01:51 UTC
(In reply to WojtasJD from comment #10)
> I have similar issue with corrupted screen (
> https://bugsfiles.kde.org/attachment.cgi?id=149347 ) in:
> - openSUSE 15.4, kernel 5.14.x and KDE Plasma 5.24.4 (installed on disk) 
> - neon-user-20230420-0722.iso (kernel 5.19; KDE Plasma 5.27.4 ; with user
> "neon" logged out from X11 and logged in to Wayland live session)
> 
> I have AMD Radeon HD 6570 (GPU name: TURKS, generation: Northern Islands) - 
> with radeon driver; amdgpu does not support this card.
> 
> In my case I don't need to suspend the machine, it is enough to switch from
> TTY1...6 (text login prompt) to TTY8 (Plasma) and screen is corrupted (with
> good mouse cursor).
> To 'repair' this I need to switch to TTY7 (SDDM) and back to TTY8 (Plasma).
> After repair, again switching to TTY1...6 (but not TTY7 (SDDM)) and back to
> TTY8 (Plasma) - screen is distorted (with good mouse cursor)...
> 
> Same behavior with KDE neon (TTY numbers different).

Got a HD 7750 (VERDE, Southern Islands).
In my system, the screen corruption appears with both of them radeon and amdgpu, in the same fashion and equally work-aroundable as yours.
At this point, I'm unsure if this is a GPU driver bug, from KDE or even Wayland, since this doesn't happen in GNOME (Wayland). Maybe they implemented some way to switch back from TTY without screen artifacts.
By the way, this corruption doesn't occur on XOrg.
Comment 12 thanantonop 2024-01-06 08:21:51 UTC
I can confirm the same with old AMD HD 5450 video card. With X11 all works fine. I can confirm that in Gnome with wayland everything also works fine so the problem is on Plasma. My current version is 5.27.10