Bug 494749

Summary: Heuristic for selecting primary GPU
Product: [Plasma] kwin Reporter: superm1
Component: platform-drmAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description superm1 2024-10-14 16:18:23 UTC
SUMMARY
On some laptops Kwin can pick the wrong GPU as the primary.  This is most notable if the PCI device ordering of the dGPU comes before the integrated GPU in the APU.

OBSERVED RESULT
Wrong GPU picked on some ASUS Strix laptops

EXPECTED RESULT
Right GPU picked on some ASUS Strix laptops

ADDITIONAL INFORMATION

A heuristic proposal was submitted to GNOME/mutter to look at the connectors [1].  I think Kwin can do the same thing.

I think it would be a good idea to add a heuristic that walks all the DRM connectors.  The compositor should look specifically for eDP connectors.  If any eDP connectors have an enabled display then mark the DRM device associated with them as the primary GPU.
If multiple eDP connectors or no eDP connectors have an enabled display then don't do anything differently.

There is a tangential issue that the kernel picks the wrong boot VGA device [2].

[1] https://gitlab.gnome.org/GNOME/mutter/-/issues/3746
[2] https://lore.kernel.org/linux-pci/4c33a9ad-fbdb-42ca-aff7-e50420c1347e@kernel.org/T/#m205ed43a258cdc892eeb1a2365603c86d51c40b0
Comment 1 Bug Janitor Service 2024-10-22 02:19:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6679
Comment 2 Zamundaaa 2024-10-29 15:34:34 UTC
Git commit 5133842717679787074682aa8eebbf92e41f48da by Xaver Hugl.
Committed on 29/10/2024 at 15:21.
Pushed by zamundaaa into branch 'master'.

backends/drm: be smarter about picking the primary GPU

By default, we want the primary GPU to be one that displays are connected to, and if we're
on a laptop, one that the internal display is connected to.

M  +17   -0    src/backends/drm/drm_backend.cpp

https://invent.kde.org/plasma/kwin/-/commit/5133842717679787074682aa8eebbf92e41f48da