https://bugs.kde.org/show_bug.cgi?id=524535
Bug ID: 524535
Summary: KWIN_DRM_DEVICES cannot express /dev/dri/by-path
names, so there is no stable way to pin KWin to a
specific GPU
Classification: Plasma
Product: kwin
Version First 6.7.4
Reported In:
Platform: unspecified
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: platform-drm
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
Created attachment 195328
--> https://bugs.kde.org/attachment.cgi?id=195328&action=edit
Reassemble adjacent tokens into a valid path if they don't already reference a
valid PCI device
DESCRIPTION
Entries in KWIN_DRM_DEVICES are delimited by a ":", but the stable device names
under /dev/dri/by-path/ embed the PCI address and therefore contain ':'
themselves:
/dev/dri/by-path/pci-0000:08:00.0-card is an example.
GpuManager::splitPathList() splits unconditionally on ':', so such a name is
tokenized into three fragments that do not exist. The device list is silently
discarded and KWin falls back to selecting a render device using its built in
algorithm as if KWIN_DRM_DEVICES did not exist.
/dev/dri/cardX devices are not usable, as they are not stable. When using a
pluggaqble graphics device those enumerators can change between reboots (card0
and card1 can swap devices). It's even possible that they could change on a
kernel upgrade, leaving the machine in an unbootable state until
KWIN_DRM_DEVICES is updated with the new enumerations.
STEPS TO REPRODUCE
1. On a machine with more than one GPU, create /etc/environment.d/10-kwin.conf
containing: KWIN_DRM_DEVICES=/dev/dri/by-path/<pci-id>-card
2. Reboot or log out and run "loginctl terminate-user <username>" and log back
in to a Wayland session.
3. Observe which GPU KWin renders on. Note that no matter which pci id you
pick, KWin always renders on the same device.
OBSERVED RESULT
The setting has no effect. KWin selects devices itself, as though the variable
were unset. splitPathList() has split the name into
"/dev/dri/by-path/pci-0000", "08" and "00.0-card". None of these exist, so
nothing is matched and nothing is reported.
EXPECTED RESULT
The named device is used.
SOFTWARE/OS VERSIONS
Operating System: CachyOS Linux
KDE Plasma Version: 6.7.4
KDE Frameworks Version: 6.29.0
Qt Version: 6.11.2
Kernel Version: 7.2.0-1-cachyos (64-bit)
Graphics Platform: Wayland
ADDITIONAL INFORMATION
/dev/dri/cardN is not stable on multi-GPU systems. Not only does it vary
between boots, it can vary within a single boot, because a re-probed device
reuses whichever minor number was freed. On this machine the same GPU was
card0, card1 and card2 across three consecutive boots, as a Thunderbolt eGPU
re-enumerated during startup. /dev/dri/by-path is the only stable name the
kernel offers, so at present there is no dependable way to express "render on
the eGPU vs the iGPU". I mitigated the issue by creating a systemd unit that
creates stable colon free links to /dev/dri/by-path devices on boot, and
referenced those links in KWIN_DRM_DEVICES.
splitPathList() does already honor a backslash escape before the delimiter, but
it is not usable in practice: Neither systemd's environment.d nor a display
manager's "GreeterEnvironment=" preserves the backslash, so the escaped form
never reaches KWin intact.
PATCH
Attached, against current master (96f0c78cbe). After tokenizing as before, it
reassembles adjacent tokens where the joined result names a path that exists,
preferring the longest match.
Lists of plain "/dev/dir/cardX" are unaffected, since a single token that
already exists is taken as-is.
Tested on 6.7.4 with a two-GPU setup, both by-path and cardX.
NOTE ON A SECOND SITE
src/compositor.cpp contains its own private copy of this parser, used by
selectRenderDevice(). The attached patch deliberately does not touch it, so
by-path names will still be mis-split on that path. Whether to fix it in place
or de-duplicate it against GpuManager::splitPathList() seemed like a decision
for
KWin maintainers rather than something to bundle into this patch.
--
You are receiving this mail because:
You are watching all bug changes.