Skip to content

drm2: wire up PRIME (DRI3) + render node#2220

Open
b1nc0d3x wants to merge 1 commit into
freebsd:mainfrom
b1nc0d3x:submit/d4-drm2-prime-render
Open

drm2: wire up PRIME (DRI3) + render node#2220
b1nc0d3x wants to merge 1 commit into
freebsd:mainfrom
b1nc0d3x:submit/d4-drm2-prime-render

Conversation

@b1nc0d3x
Copy link
Copy Markdown

Summary

  • PRIME ioctls, struct drm_minor *render, and the matching helpers were stubbed under #ifdef FREEBSD_NOTYET since the 2012 import. Unguard them and add the missing implementation.
  • New sys/dev/drm2/drm_prime.c implements handle_to_fd / fd_to_handle on FreeBSD's struct file (falloc_caps + custom fileops), not Linux dma-buf. Single-driver PRIME — exported fds are only meaningful to other drm2 drivers, which is what X.org modesetting + DRI3 actually need.
  • Drivers that advertise DRIVER_RENDER (new flag, 0x8000) get /dev/dri/renderD<n>.
  • No functional change for in-base drm2 drivers — none of them set DRIVER_PRIME or DRIVER_RENDER, so the new paths are dormant for them.

Test plan

  • make buildkernel TARGET=arm64 KERNCONF=GENERIC (drm2 statically linked) — clean.
  • A loadable drm2 driver that sets DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER now exposes /dev/dri/{card0,controlD64,renderD128} and Xorg logs (II) Initializing extension DRI3.
  • drmModeDirtyFB + PRIME ioctls round-trip cleanly; SLiM and startxfce4 render through the modesetting driver against the new render node.

PRIME ioctls, drm_minor *render, and the matching helpers were
stubbed under FREEBSD_NOTYET since the 2012 import.  Unguard
them and add the missing pieces:

  - sys/dev/drm2/drm_prime.c: handle_to_fd / fd_to_handle on
    top of FreeBSD's struct file (falloc_caps + custom fileops),
    not Linux dma-buf.  Single-driver PRIME — exported fds only
    work in other drm2 driver opens, which is what X.org DRI3
    needs.
  - drmP.h: unguard PRIME helper externs, add
    struct drm_minor *render, define DRIVER_RENDER 0x8000.
  - drm_drv.c: unguard PRIME ioctl table entries.
  - drm_ioctl.c: DRM_CAP_PRIME reports IMPORT|EXPORT.
  - drm_platform.c: register render minor when DRIVER_RENDER set.
  - sys/conf/files: build drm_prime.c.

No functional change for in-base drm2 drivers — none advertise
DRIVER_PRIME or DRIVER_RENDER, so the new paths are dormant.
A loadable drm2 driver that opts in now gets /dev/dri/renderD<n>
and X.org's DRI3 extension initialises against it.

Signed-off-by: Kyle Crenshaw <B1nc0d3x@gmail.com>
@b1nc0d3x b1nc0d3x requested a review from bsdimp as a code owner May 22, 2026 01:34
@github-actions
Copy link
Copy Markdown

Thank you for taking the time to contribute to FreeBSD!

Some of files have special handling:

Important

@bsdimp wants to review changes to sys/dev/drm2

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