Skip to contentSkip to conversation

drm: Add UAPI for the Asahi driver

PATCH Superseded Alyssa Rosenzweig 1 participant 1 message Mar 13, 2025

Subsystems (5)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm: Add UAPI for the Asahi driver

This adds the UAPI for the Asahi driver targeting the GPU in the Apple M1 and M2 series systems on chip. The UAPI design is based on other modern Vulkan-capable drivers, including Xe and Panthor. Memory management is based on explicit VM management. Synchronization is exclusively explicit sync.

This UAPI is validated against our open source Mesa stack, which is fully conformant to the OpenGL 4.6, OpenGL ES 3.2, OpenCL 3.0, and Vulkan 1.4 standards. The Vulkan driver supports sparse, exercising the VM_BIND mechanism.

This patch adds the standalone UAPI header. It is implemented by an open source DRM driver written in Rust. We fully intend to upstream this driver when possible. However, as a production graphics driver, it depends on a significant number of Rust abstractions that will take a long time to upstream. In the mean time, our userspace is upstream in Mesa but is not allowed to probe with upstream Mesa as the UAPI is not yet reviewed and merged in the upstream kernel. Although we ship a patched Mesa in Fedora Asahi Remix, any containers shipping upstream Mesa builds are broken for our users, including upstream Flatpak and Waydroid runtimes. Additionally, it forces us to maintain forks of Mesa and virglrenderer, which complicates bisects.

The intention in sending out this patch is for this UAPI to be thoroughly reviewed. Once we as the DRM community are satisfied with the UAPI, this header lands signifying that the UAPI is stable and must only be evolved in backwards-compatible ways; it will be the UAPI implemented in the DRM driver that eventually lands upstream. That promise lets us enable upstream Mesa, solving all these issues while the upstream Rust abstractions are developed.

https://github.com/alyssarosenzweig/linux/commits/agx-uapi-v2 contains the DRM driver implementing this proposed UAPI.

https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33984 contains the Mesa patches to implement this proposed UAPI. It is mirrored at
https://github.com/alyssarosenzweig/mesa/tree/agx-uapi-v2 to allow continued review during upcoming gitlab.freedesktop.org downtime.

That Linux and Mesa branch together give a complete graphics/compute stack on top of this UAPI.

---
Changes in v2:
- Flatten submits. Previously, the submit ioctl pointed to an array of command structures, which each pointed to separate payload structures, which pointed to attachment structures. This is a lot of indirection, which complicates greatly virtgpu. In the new approach, the submit
ioctl points to a single contiguous blob of plain-old-data, no CPU pointers, copied from userspace in one go and suitable as virtgpu wire protocol.
- Remove vm_page_size, userspace has to hardcode it anyway.
- Turn random #defines into enums for better kernel doc, etc.
- Improve comments, particularly around barriers[].
- Rename various flags/fields to better match canonical names when known
(a lot of the names are pulled from the drivers/gpu/drm/imagination, naturally).
- Drop unnecessary encoder_id, cmd_id handles.
- Fix padding in submit ioctl (thanks Ryan).
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 Documentation/gpu/driver-uapi.rst |    5 +
 MAINTAINERS                       |    1 +
 include/uapi/drm/asahi_drm.h      | 1194 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1200 insertions(+)
Documentation/gpu/driver-uapi.rst +5 -0
index 971cdb4816fc98d80a64d93637481d10c2e79718..1f15a8ca126516c23bd7374cc4aead0dfbbccf67 100644
@@ -27,3 +27,8 @@ drm/xe uAPI
 ===========
 
 .. kernel-doc:: include/uapi/drm/xe_drm.h
+
+drm/asahi uAPI
+================
+
+.. kernel-doc:: include/uapi/drm/asahi_drm.h
MAINTAINERS +1 -0
index d1050702f681fbd0e4e2d0457b2ba569a64070d9..7f692a935808d4ec82ee741324f8043302dae491 100644
@@ -2256,6 +2256,7 @@ F:	drivers/watchdog/apple_wdt.c
 F:	include/dt-bindings/interrupt-controller/apple-aic.h
 F:	include/dt-bindings/pinctrl/apple.h
 F:	include/linux/soc/apple/*
+F:	include/uapi/drm/asahi_drm.h
 
 ARM/ARTPEC MACHINE SUPPORT
 M:	Jesper Nilsson <[email protected]>
include/uapi/drm/asahi_drm.h new file +1194 -0

1,194 lines not on this page · raw message

---
base-commit: 0ed1356af8f629ae807963b7db4e501e3b580bc2
change-id: 20250307-agx-uapi-930579437f19

Best regards,

Signature · 1 line
Alyssa Rosenzweig <[email protected]>