Skip to content

J813: the M5 GPU as an m5/ backend of drm/asahi (MacBook Air M5) - #847

Closed
sithglan wants to merge 6 commits into
aurora-silicon:integration/aurorafrom
sithglan:j813/feat/gpu-m5
Closed

sithglan wants to merge 6 commits into
aurora-silicon:integration/aurorafrom
sithglan:j813/feat/gpu-m5

Conversation

@sithglan

@sithglan sithglan commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This adds the J813 (M5, T8142, G17G) GPU as its own backend, drivers/gpu/drm/asahi/m5/, behind CONFIG_DRM_ASAHI_M5. It probes as ProbeConfig::M5 for apple,agx-t8142. Nothing changes for the other SoCs: the shared code only gains three small mmu additions and one register write, and the M5 parts of them are compiled only with the backend.

Why a separate backend

The M5's 25G76 firmware (RTKit-3255.160.4) has two coprocessors like the A18 Pro, but its interface is HAL300. It differs from both builds the shared G17 code runs (26A428, 25G83) in the init graph, queue records and register programs. This follows the same pattern as g16/ for the M4 and m3/. The intent is to fold it into the shared G17 code once the M5 Pro/Max work lands here as well.

What it shares

  • UAT: integration's mmu::Uat with published roots, adopted and mirrored as on the A18 Pro. The M5 application contexts are added in mmu/m5_context.rs: the client VM's root below, a private empty root above, published explicitly.
  • User VMs: they carry a status and a job lifetime, and the backend uses the tracked submission model of file.rs.
  • UAPI: integration's asahi_drm.h. The backend reports VM_STATUS (and its mirror) and SOFT_FAULTS, and one hardware command per submission.

Commits

  1. soc: apple: rtkit: Take a crash buffer the firmware maps itself. This is the same commit as in J813: AOP sound on the MacBook Air M5 (speakers, jack, microphones) #811; it drops out on rebase once that one is merged.
  2. drm/asahi: mmu: Map at a fixed address with a guard of any size
  3. drm/asahi: mmu: Keep the kernel range of a VM
  4. drm/asahi: mmu: Add M5 application contexts
  5. drm/asahi: regs: Add the M5 PMGR boot control
  6. drm/asahi: Add the M5 (T8142) backend

Depends on

Limits

  • There is one job in flight; a submission is polled to retirement.
  • Renders and compute outside the state the firmware programs are known to handle are refused with ENOTSUPP.
  • There is no recovery yet: a failed job stops both coprocessors and the device is lost until reboot.

Testing

J813 (8 GPU cores), aura one-shot trial boot, Mesa j813, compared with the same Mesa on the J813 kernel this comes from:

Suite Result Compared with kernel #5 (t70)
GLES2 16016 pass, 930 fail identical per case
GLES3 40832 pass, 3547 fail, 2 timeouts identical except one known flake
GLES31 (1 job) 32813 pass, 4517 fail t70 32804 / 4520; 32 cases differ: 9 fail→pass, the rest flakes

The sway desktop renders on the GPU from boot, and it kept rendering during all three runs.

Credits

This consolidates Acelogic's M5 work and DjDeveloperr's G17P render, UAPI and initdata encoders, with contributions by Ryan Murray, Eryk Wieliczko and Chris Kearney, ported onto integration's driver.

cc @Acelogic @DjDeveloperr @RyanTheTide @LiamRay10

The T8142 AOP keeps its crash buffer in its own slot of its DART stream
and asks for it on endpoint 1 with that IOVA. A client without
shmem_setup refused the request, so the firmware never got its crash
buffer acknowledged.

APPLE_RTKIT_FIRMWARE_OWNED_CRASHLOG takes such a buffer as the firmware's,
without a CPU mapping, and acknowledges the request unchanged; a later
crash is reported without a log. RtKit::new_with_firmware_crashlog()
selects it at runtime, so a driver can use it for one SoC only.

Signed-off-by: Thomas Glanzmann <[email protected]>
Vm::map_at() reserves at most one guard page after a mapping. The M5
backend maps the driver's pools at the same address in each client VM
with two guard pages after each, as it does when it allocates them.

Add Vm::map_at_with_guard_size() and express map_at() through it.

Signed-off-by: Thomas Glanzmann <[email protected]>
The kernel range of a VM, reserved at VM_CREATE for kernel-managed
objects, is only handed to GPUVM. The M5 backend places its per-client
objects in that range and checks that userspace commands stay out of it.

Keep the range in the Vm and add an accessor.

Signed-off-by: Thomas Glanzmann <[email protected]>
The M5 (T8142) 25G76 firmware runs application work in a TTBAT context
whose lower half is the client VM's root and whose upper half is an
empty root of its own; the firmware's upper mappings are not shared with
applications. The context is claimed when the work is set up and
published explicitly once it is prepared, and a later client takes it
over without giving up the context number.

Add M5ExecutionContext for that, built only with the M5 backend. It
claims numbers from the execution context mask, publishes and retracts
under the handoff lock, and a mapping change reaches it through the
existing invalidation of every context that names a VM's root.

Signed-off-by: Thomas Glanzmann <[email protected]>
The native 25G76 driver sets the low bit of the GPU's PMGR boot control
word (SGX + 0xe90000) before either M5 firmware instance starts; the
word reads 0x30000 on J813. Add the write, for the M5 backend only,
refusing any other starting value.

Signed-off-by: Thomas Glanzmann <[email protected]>
Add a backend for the M5 GPU (J813, G17G) running the 25G76 firmware
(RTKit-3255.160.4), as ProbeConfig::M5 for apple,agx-t8142 behind
CONFIG_DRM_ASAHI_M5. It changes nothing for the other SoCs.

The 25G76 firmware has two coprocessors, GFX and GFX1, as the A18 Pro
has, but a HAL300 interface that differs from the 26A428 and 25G83
builds the shared G17 code runs. The backend therefore builds its own
initialization graph and talks to the firmware over its own queues,
while using the shared parts of the driver:

 - the UAT is the shared one with published roots, adopted and mirrored
   as on the A18 Pro, plus the M5 application contexts;
 - user VMs carry a status and a job lifetime, and the backend uses the
   tracked submission model of file.rs;
 - the UAPI is the shared one. The backend reports VM_STATUS and
   SOFT_FAULTS and one hardware command per submission.

The boot loader (aura) loads the firmware, checks both TEXT images
against the 25G76 build and says so in
/chosen/aurora,m5-gpu-firmware-profile; the backend refuses to start
without it.

One render pair and one compute queue serve all clients and are handed
from client VM to client VM; a submission is polled to retirement
before the ioctl returns. Renders and compute are admitted only within
the state the firmware programs are known to handle, and refused with
ENOTSUPP otherwise. There is no recovery yet: a job that fails stops
both coprocessors and retains every firmware-visible object until
reboot.

The driver's pools are mapped at their own address in each client VM
the job is handed to, except in the VM that owns them, and the compute
storage is reserved together with the parameter buffer, so that its
address is free in every such VM.

Tested on J813 (M5, 8 GPU cores) on the aura one-shot trial boot, with
Mesa j813, against the same Mesa on the J813 kernel this code comes
from: GLES2 16016 pass, 930 fail (identical per case); GLES3 40832 pass,
3547 fail, 2 timeouts (identical but for one known flake);
GLES31 32813 pass, 4517 fail (t70: 32804/4520; the 32 differing cases
are 9 fail->pass and flakes); the sway desktop renders on the GPU from
boot, also during the CTS runs.

This consolidates the M5 work of Acelogic <[email protected]> and
the G17P render, UAPI and initdata encoders of DjDeveloperr
<[email protected]>, with contributions by Ryan Murray, Eryk Wieliczko and
Chris Kearney, from the J813 kernel tree, ported onto integration's
driver.

Signed-off-by: Thomas Glanzmann <[email protected]>

MrNews89 commented Nov 2, 2026

Copy link
Copy Markdown

Which public Mesa repository and exact commit were used for the J813 Sway/GLES tests? Is the ‘Mesa j813’ branch and build recipe available? I’m trying to reproduce GPU-accelerated Linux on J815/T8142 (10 GPU cores). Also, has this backend been validated with macOS 27 beta5 firmware, or only 25G76?

@sithglan

sithglan commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@MrNews89

Mesa: https://github.com/aurora-silicon/mesa-aurora, branch thomas/j813-m5-next at e1690cd0c3d. That branch is the merge of the series PRs on the j813 base: #24 (uAPI), #26 (compiler), #27 (gallium), #28 (hk) and #25 (layout). The build I tested reports git-eef003af2a. That was an earlier merge of the same series, and its tree is identical: git diff eef003af2a e1690cd0c3d is empty.

Build, natively on the M5 (Debian sid):

meson setup build -Dprefix=/opt/mesa-j813 -Dbuildtype=release \
  -Dgallium-drivers=asahi,zink -Dvulkan-drivers=asahi -Dplatforms=wayland,x11 \
  -Dglx=dri -Dgles1=disabled -Dllvm=enabled -Dtools=drm-shim
ninja -C build install

Run it with:

LD_LIBRARY_PATH=/opt/mesa-j813/lib/aarch64-linux-gnu
LIBGL_DRIVERS_PATH=/opt/mesa-j813/lib/aarch64-linux-gnu/dri
GBM_BACKENDS_PATH=/opt/mesa-j813/lib/aarch64-linux-gnu/gbm
__EGL_VENDOR_LIBRARY_FILENAMES=/opt/mesa-j813/share/glvnd/egl_vendor.d/50_mesa.json
GSK_RENDERER=gl   # GTK 4

Sway runs on wlroots with WLR_RENDERER=gles2.

J815: the probe accepts 8 or 10 cores, but the backend has only run on the J813's 8 cores. The init data and register programs it replays were measured on the J813, so a 10-core part likely needs its own measurement. You would also need a J815 DT with the GPU node; #812 has the J813 one.

Firmware: only 25G76 (RTKit-3255.160.4). The probe refuses unless aura publishes exactly that profile in /chosen/aurora,m5-gpu-firmware-profile. The init graph and queue records are specific to that build. I haven't looked at the macOS 27 beta 5 GPU firmware, so the backend won't run on it.

MrNews89 commented Nov 2, 2026

Copy link
Copy Markdown

Thanks, that identifies the matching series. The Mesa URL https://github.com/aurora-silicon/mesa-aurora currently returns 404 through both GitHub and the API; e1690cd0c3d is also unavailable in aurora-silicon/mesa and sithglan/mesa-aurora. Is mesa-aurora still private, or is there another public URL for thomas/j813-m5-next? Could you make the matching source or patch series accessible?

@sithglan

sithglan commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

mesa-aurora is private at the moment, which is why you get a 404. It will be released to the public soon. Once it is, thomas/j813-m5-next (including e1690cd0c3d) will be available at https://github.com/aurora-silicon/mesa-aurora.

MrNews89 commented Nov 2, 2026 •

Copy link
Copy Markdown

J815/T8142 (10 GPU cores) now passes native initialization and four DRM jobs (clear/copy/draw/copy), with full 64x64 readback and guard checks. This used programs captured from public Mesa 8990cdb219b2, with query/timestamp outputs disabled and one command per submission.

Could you publish the matching thomas/j813-m5-next/e1690cd0c3d series, or provide a source archive or repository access?

@sithglan

sithglan commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, and congratulations on getting J815/T8142 through native init and the four DRM jobs with full readback. That's good progress.

I have to decline for now, though. The Mesa side (the thomas/j813-m5-next series) is proprietary work at the moment and will stay that way until it is complete and released, so I can't publish the branch, send a source archive or give out repository access before then.

@sithglan

sithglan commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1003: the same work rebased onto integration/aurora 11eccbe and boot-tested on the J813.

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.

2 participants