native: Add preferred-primary GPU selection via udev tag#811
Open
dongioia wants to merge 1 commit intolinuxmint:masterfrom
Open
native: Add preferred-primary GPU selection via udev tag#811dongioia wants to merge 1 commit intolinuxmint:masterfrom
dongioia wants to merge 1 commit intolinuxmint:masterfrom
Conversation
On multi-GPU SoCs like RK3588 (Rockchip), the mainline kernel exposes
two DRM devices: card0 (rockchip-drm, display-only, no 3D) and card1
(panthor, Mali-G610 GPU with full 3D). Muffin's choose_primary_gpu_unchecked()
selects the first platform device with render capability, which picks
card0 — a display controller with no OpenGL/Vulkan support.
This causes EGL clients to fall back to llvmpipe (software rendering),
as the compositor advertises the wrong device via wl_drm.
GNOME's Mutter solved this by introducing a udev tag mechanism
(mutter-device-preferred-primary) that lets system integrators
explicitly mark which GPU should be used as primary. This commit ports
that mechanism to Muffin using the tag "muffin-device-preferred-primary".
Changes:
- meta-udev.c/h: Add meta_is_udev_device_preferred_primary() that
checks for the "muffin-device-preferred-primary" udev tag
- meta-kms-types.h: Add META_KMS_DEVICE_FLAG_PREFERRED_PRIMARY flag
- meta-backend-native.c: Propagate the flag during GPU initialization
- meta-gpu-kms.c/h: Add meta_gpu_kms_is_preferred_primary() accessor
- meta-renderer-native.c: Check preferred_primary before platform_device
and boot_vga in choose_primary_gpu_unchecked()
Example udev rule for RK3588 boards:
SUBSYSTEM=="drm", KERNEL=="card1", DRIVERS=="panthor", \
TAG+="muffin-device-preferred-primary"
Tested on Rock 5B+ (RK3588) running BredOS with kernel 7.0-rc1 and
6.19.1, Cinnamon Wayland session. Verified that Muffin correctly
selects panthor (renderD128) as primary GPU with this patch applied.
Note: This fixes the compositor-side GPU selection (Part A). Full
client-side GPU discovery requires upgrading zwp_linux_dmabuf_v1
from v3 to v4+ with device feedback (Part B, separate work).
Ref: Mutter meta-udev.c meta_is_udev_device_preferred_primary()
Author
|
This PR addresses Part A of the issue described in linuxmint/wayland#194. See that issue for the full root cause analysis and the remaining Part B work (zwp_linux_dmabuf_v1 v4+ upgrade). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On multi-GPU SoCs like RK3588 (Rockchip), the mainline kernel exposes two DRM devices:
card0→rockchip-drm(display controller only, no 3D rendering)card1→panthor(Mali-G610 GPU, full OpenGL/Vulkan)Muffin's
choose_primary_gpu_unchecked()selects the first platform device with render capability, which pickscard0— a display controller with no OpenGL/Vulkan support. This causes all Wayland EGL clients to fall back to llvmpipe (software rendering).GNOME's Mutter solved this with a udev tag mechanism (
mutter-device-preferred-primary). This PR ports that mechanism to Muffin using the tagmuffin-device-preferred-primary.Changes
meta-udev.c/hmeta_is_udev_device_preferred_primary()— checks formuffin-device-preferred-primaryudev tagmeta-kms-types.hMETA_KMS_DEVICE_FLAG_PREFERRED_PRIMARYflagmeta-backend-native.cmeta-gpu-kms.c/hmeta_gpu_kms_is_preferred_primary()accessormeta-renderer-native.cTotal: +39 lines across 7 files. No behavioral change on systems without the udev tag.
Usage
System integrators add a udev rule to mark the 3D-capable GPU:
Testing
muffin-device-preferred-primarytag correctly detected viaudevadm info /dev/dri/card1renderD128(panthor) as primary GPU (verified via/proc/PID/fdand/sys/kernel/debug/dri/1/clients)Mali-G610 MC4 (Panfrost)✅Scope
This is Part A of a two-part fix for multi-GPU Wayland on Cinnamon:
zwp_linux_dmabuf_v1from v3 to v4+ withmain_devicefeedback, so that Wayland EGL clients know which render node to use. See related issue for details.Related
meta_is_udev_device_preferred_primary()zwp_linux_dmabuf_v1v4 feedback