Bug 465809 - external display running through an egpu is very laggy
Summary: external display running through an egpu is very laggy
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: multi-screen (show other bugs)
Version: 5.26.5
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-16 02:52 UTC by Matt Keith
Modified: 2023-12-08 19:35 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments
drm_info output from freshly installed fedora 37 with all updates (295.25 KB, text/plain)
2023-02-20 21:42 UTC, Matt Keith
Details
Arch Linux drm_info output (136.58 KB, text/plain)
2023-12-08 19:33 UTC, Matt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Keith 2023-02-16 02:52:15 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Install Fedora 37 KDE spin
2. plug in an egpu RX 5700
3. plug in monitor into egpu
4. reboot


OBSERVED RESULT
both laptop and external display work. laptop display is buttery smooth. external display is choppy.

EXPECTED RESULT
Both laptop and the external display work. laptop display is buttery smooth. external display is buttery smooth

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Fedora 37 KDE spin Plasma: 5.26.5
(available in About System)
KDE Plasma Version: 5.26.5
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION
I am running wayland with a display plugged into an egpu Radeon RX5700. I created a post with my laptop manufacturer with some additional details:
https://community.frame.work/t/linux-poor-performance-of-egpu-driven-external-monitor-in-fedora-37-kde-spin/27290

After running the following script to designate my egpu as primary per this project:
https://github.com/ewagner12/all-ways-egpu/wiki

I now observe the external display is smooth and the integrated display is now choppy.

My suggestion would be to either run the display on the gpu for which it is designated and give options to switch this or provide an option within KDE to select which GPU to use and note that the other will perform poorly

Perhaps the choppiness is also an issue with wayland or kwin that could in itself be resolved? Being able to choose which gpu to use is still needed for tasks like running games though
Comment 1 Matt Keith 2023-02-16 02:54:37 UTC
probably a duplicate of https://bugs.kde.org/show_bug.cgi?id=452219
Comment 2 Zamundaaa 2023-02-20 19:10:49 UTC
Bug 452219 is more about NVidia GPUs specifically, but yeah it's most likely the same underlying issue.
Please attach the output of drm_info (https://gitlab.freedesktop.org/emersion/drm_info), whether or not KWin falls back to CPU copy should be visible in there.
Comment 3 Matt Keith 2023-02-20 21:42:32 UTC
Created attachment 156551 [details]
drm_info output from freshly installed fedora 37 with all updates

This drm_info was collected from a freshly installed fedora 37 kde spin with the updates as of today, which includes kde 5.27
Comment 4 Matt Keith 2023-02-20 21:43:43 UTC
(In reply to Zamundaaa from comment #2)
> Bug 452219 is more about NVidia GPUs specifically, but yeah it's most likely
> the same underlying issue.
> Please attach the output of drm_info
> (https://gitlab.freedesktop.org/emersion/drm_info), whether or not KWin
> falls back to CPU copy should be visible in there.

The file is attached. I reinstalled fedora 37 onto a new partition so that I could ensure the egpu script i ran was not a factor. I'll keep it this way for troubleshooting purposes for a while
Comment 5 Zamundaaa 2023-04-12 13:48:19 UTC
Git commit b14f7959eb5f4d2b690ac26fdfee76abc837240c by Xaver Hugl.
Committed on 12/04/2023 at 13:28.
Pushed by zamundaaa into branch 'master'.

backends/drm: add another multi gpu fallback

With the dmabuf multi-gpu path, a buffer is imported to the secondary GPU
and presented directly, but importing a buffer that's usable for scanout
is not possible that way on most hardware. To prevent CPU copy from being
needed in those cases, this commit introduces a fallback where the buffer
is imported for rendering only, and then copied to a local buffer that's
presented on the screen.
Related: bug 452219

M  +73   -43   src/backends/drm/drm_egl_backend.cpp
M  +5    -3    src/backends/drm/drm_egl_backend.h
M  +92   -15   src/backends/drm/drm_egl_layer_surface.cpp
M  +7    -3    src/backends/drm/drm_egl_layer_surface.h
M  +5    -0    src/composite.cpp
M  +1    -2    src/libkwineffects/kwinglutils.h
M  +18   -0    src/platformsupport/scenes/opengl/eglcontext.cpp
M  +7    -3    src/platformsupport/scenes/opengl/eglcontext.h

https://invent.kde.org/plasma/kwin/commit/b14f7959eb5f4d2b690ac26fdfee76abc837240c
Comment 6 Nate Graham 2023-04-15 00:19:56 UTC
^^ That should fix it!
Comment 7 Matt 2023-12-08 19:25:26 UTC
Significant stutter still present on secondary monitor, and shortly after moving cursor to primary eDP display. 

EXPECTED RESULT:
Plasma selects the proper GPU/Prime topology upon login and provides a smooth consistent 60fps through the external and internal display

Operating System: Arch Linux 
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.112.0
Qt Version: 5.15.11
Kernel Version: 6.6.4-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i5-8250U CPU @ 1.60GHz
Memory: 7.5 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620
(Secondary GP: AMD 5500XT via Sonnet Breakaway Box over Thunderbolt 3)
Manufacturer: Dell Inc.
Product Name: XPS 13 9370
Comment 8 Zamundaaa 2023-12-08 19:28:31 UTC
(In reply to Matt from comment #7)
> Significant stutter still present on secondary monitor, and shortly after
> moving cursor to primary eDP display. 
That's expected, you're on 5.27, which doesn't have the fix.
Comment 9 Matt 2023-12-08 19:33:45 UTC
Created attachment 164024 [details]
Arch Linux drm_info output
Comment 10 Matt 2023-12-08 19:35:29 UTC
(In reply to Zamundaaa from comment #8)
> (In reply to Matt from comment #7)
> > Significant stutter still present on secondary monitor, and shortly after
> > moving cursor to primary eDP display. 
> That's expected, you're on 5.27, which doesn't have the fix.

Oh, my mistake. I misread the version info; the amount of time we've spent in 5.27 is pretty crazy!