Skip to content

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

Merged
Acelogic merged 7 commits into
aurora-silicon:aurora-wipfrom
sithglan:j813/rb/gpu-m5
Nov 6, 2026
Merged

Acelogic merged 7 commits into
aurora-silicon:aurora-wipfrom
sithglan:j813/rb/gpu-m5

Conversation

@sithglan

@sithglan sithglan commented Nov 5, 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 the sound PR of this series; it drops out 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

  • the T8142 mailbox and CLPC PR of this series
  • the J813 DT PR of this series
  • aura publishing /chosen/aurora,m5-gpu-firmware-profile

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

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

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.

On the rebased tree (integration/aurora 11eccbe, all nine J813 branches) the backend probes and starts the 25G76 firmware in a full boot; the Mesa runs above have not been repeated on the new base yet.

Stability caveat: a second boot of the same image hung about 38 s in, just after the NTP step set off the daily fstrim/apt timers, with no panic record (no pstore). The first boot went through the same timer burst and stayed up for minutes. The hang is not attributed yet; until it is, the combined tree is not proven stable across reboots.

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.

Rebased onto integration/aurora c6cc36e (2026-11-06); this branch builds with the J813 config (Image.gz and modules). Booted on the MacBook Air M5 (J813) on 2026-11-06 in the combined stack: this branch merged with the other J813 branches, built as 7.3.0-aurora-j813-rb+ (Image.gz and 65 modules), trial-booted with the t8142-j813 DTB and promoted to the configured ESP boot, where it now boots by default. NVMe root, the N1 Wi-Fi, the DCP panel at 2560x1600, the aurora GPU driver (WebGL with EXT_shader_texture_lod), the AVD and ISP nodes, AOP sound (AppleJ813 card; a 1 kHz tone played to the speakers is captured by the HPAI microphone at about -50 dBFS) and the PMP all come up; systemd reports no failed units. btcentauri still returns -16, the known pre-existing condition.

cc @Acelogic @DjDeveloperr @RyanTheTide @LiamRay10

Acelogic added a commit that referenced this pull request Nov 6, 2026
Integrate the M5 backend alongside the G18 backend from #984. Give the G18
execution context its own name and share the VM kernel-range field and
accessor. Keep firmware-owned RTKit crash buffers separate from the early
endpoint-start requirement so each backend retains its handshake.

Validated all four M5/G18 configuration combinations, linked the combined
module, and compared both original UAPI layouts and constants. Hardware
runtime validation of the combined stack remains pending.
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]>
integration/aurora added a bound-device owner to the platform driver data and
a usage client to Gpu::new_queue. Create the owner in the M5 probe path like
the other backends and accept the usage client on the M5 queue.

Signed-off-by: Thomas Glanzmann <[email protected]>
@Acelogic
Acelogic changed the base branch from integration/aurora to aurora-wip November 6, 2026 11:07
@Acelogic
Acelogic merged commit b197013 into aurora-silicon:aurora-wip Nov 6, 2026
RyanTheTide added a commit that referenced this pull request Nov 6, 2026
Carries the work merged on aurora-wip since #1018 into the release
branch: M5 T8142/J813 bring-up (#995 #996 #997 #998 #1001 #1002 #1003),
T8152/J873 bring-up (#984 #1009 #1013 #1022), J813 AVD/ISP (#1026)
and the selftest harness updates (#1014). The merge is clean; the 13
integration/aurora commits since #1018 are kept.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
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