Skip to content

gallium: Stub support for Asahi + DRM

Alyssa Rosenzweig requested to merge alyssa/mesa:asahi-drm-shim into main

Copy-paste a pile of winsys code from panfrost and find-and-replace the name to asahi. This should contain all the glue code needed for asahi+kmsro.

We haven't actually written a kernel driver for the Apple GPUs yet. Reverse-engineering is under way though (led by Asahi Lina, not me). My goal was rather to run shader-db, which expects a render node, which means drm-shim, which means DRM loader support. With this patch and a trivial drm-shim, shader-db runs.

In general I am reticent to touch UABI related code when the UABI hasn't been finalized upstream, or started design at all, hence the RFC. Realistically this patch assumes the following about the future UABI:

  1. It will be a DRM driver. This is nonnegotiable.

  2. The render node will be named "asahi". The other reasonable name would be "apple", which I'm using for the display controller (not yet upstream, but getting close).

  3. Display and rendering will be split in the kernel, requiring kmsro in userspace. This is the most dubious bit, I think, and probably needs a serious discussion upstream. The relevant points being:

  • The 3D accelerator (AGX) and the display controller (DCP) are completely orthogonal blocks with separate lineages. True, Apple A14 (~= M1) has AGX and DCP together, and it seems like all the chips that will get upstream support will have this for the forseeable future. Nevertheless, it's a historical coincidence. Apple A12 had an AGX block with a pre-DCP Apple display controller, which would use a completely different display driver. Older SoCs had a PowerVR block with an Apple shader core, with a pre-DCP Apple display controller. Even older SoCs had a pure PowerVR block (+ Apple display).

    The AGX and DCP kernel drivers are not expected to share any nontrivial code. We don't gain anything by bundling them together.

    [Likewise, the many codec blocks are completely orthogonal. This is all standard practice for Arm SoCs.]

  • AGX has never been used with a non-Apple display controller; it is highly unlikely this would change (either by AGX licensing out or something like Mali-DP getting licensed in -- yeah, when pigs fly). So Mesa shouldn't carry the kmsro complexity.

  • Nobody is seriously backporting this stuff to old iPhones. We can safely assume AGX = DCP, at least for now.

Signed-off-by: Alyssa Rosenzweig alyssa@rosenzweig.io

Merge request reports