Skip to content

native: Add preferred-primary GPU selection via udev tag#811

Open
dongioia wants to merge 1 commit intolinuxmint:masterfrom
dongioia:fix/preferred-primary-gpu-selection
Open

native: Add preferred-primary GPU selection via udev tag#811
dongioia wants to merge 1 commit intolinuxmint:masterfrom
dongioia:fix/preferred-primary-gpu-selection

Conversation

@dongioia
Copy link

@dongioia dongioia commented Mar 9, 2026

Summary

On multi-GPU SoCs like RK3588 (Rockchip), the mainline kernel exposes two DRM devices:

  • card0rockchip-drm (display controller only, no 3D rendering)
  • card1panthor (Mali-G610 GPU, full OpenGL/Vulkan)

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 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 tag muffin-device-preferred-primary.

Changes

File Change
meta-udev.c/h Add meta_is_udev_device_preferred_primary() — checks for muffin-device-preferred-primary udev tag
meta-kms-types.h Add META_KMS_DEVICE_FLAG_PREFERRED_PRIMARY flag
meta-backend-native.c Propagate flag during GPU init
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

Total: +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:

# /etc/udev/rules.d/61-muffin-panthor.rules
SUBSYSTEM=="drm", KERNEL=="card1", DRIVERS=="panthor", TAG+="muffin-device-preferred-primary"

Testing

  • Hardware: Rock 5B+ (RK3588), Orange Pi 5 Plus (RK3588)
  • OS: BredOS (Arch Linux ARM), kernels 6.19.1 and 7.0-rc1
  • Session: Cinnamon Wayland
  • Verified:
    • muffin-device-preferred-primary tag correctly detected via udevadm info /dev/dri/card1
    • Muffin selects renderD128 (panthor) as primary GPU (verified via /proc/PID/fd and /sys/kernel/debug/dri/1/clients)
    • GBM EGL platform reports Mali-G610 MC4 (Panfrost)

Scope

This is Part A of a two-part fix for multi-GPU Wayland on Cinnamon:

  • Part A (this PR): Compositor-side GPU selection — Muffin picks the correct GPU internally
  • Part B (separate, larger work): Client-side device discovery — requires upgrading zwp_linux_dmabuf_v1 from v3 to v4+ with main_device feedback, so that Wayland EGL clients know which render node to use. See related issue for details.

Related

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()
@dongioia
Copy link
Author

dongioia commented Mar 9, 2026

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant