Repository navigation
drm/asahi: G18 (Mac mini M6, T8152) backend on the current driver - #984
Merged
Merged
Conversation
The G18 backend (T8152, Mac mini M6) takes this driver's command layout. Two of its abilities have no equivalent among the shared features, so they take the next free feature bits: - DRM_ASAHI_FEATURE_G18_GRAPHICS_SCRATCH (bit 31): render commands may carry struct drm_asahi_g18_render_resources, flagged with DRM_ASAHI_RENDER_G18_RESOURCES (render flag bit 25). The kernel sizes the shared TA/3D private-memory pool from it. - DRM_ASAHI_FEATURE_G18_NATIVE_TILE_SAMPLES (bit 32): single-sample renders with 32x32 utiles also accept 40-, 56- and 72-byte samples. It is a #define after enum drm_asahi_feature: a 64-bit enumerator would widen that enum to unsigned long, which bindgen maps to usize. Compute commands get two G18-only flags: DRM_ASAHI_COMPUTE_USES_TEXTURE_STATE (bit 18) selects the native texture compute mode, and DRM_ASAHI_COMPUTE_G18_RESOURCES (bit 19) adds struct drm_asahi_g18_compute_resources. The flagged payloads, struct drm_asahi_cmd_render_g18 (528 bytes) and struct drm_asahi_cmd_compute_g18 (264 bytes), are the complete render or compute command followed by its resources. Every field of the command keeps its meaning. The flag numbers leave render bits 21-24, compute bits 16-17 and feature bits 25, 27 and 30 to the M5 runtime's userspace, which uses them. No existing struct, field or value changes. G18 reports DRM_ASAHI_GPU_HAL_300; say so in its documentation.
The G18 backend maps an alias into the unmapped guard pages that trail a kernel mapping, and must give the guard back if the alias is undone. Add NodeData::split_tail(), which turns the tail of a reservation into a node of its own, and NodeData::rejoin_tail(), which merges an adjacent tail back. Both are limited to allocators without colour callbacks, allocate before they mutate, and leave both reservations unchanged on failure.
The M6 (T8152) GPU has two coprocessors, GFX and GFX1, behind ASCWrap v8 wrappers. Add an "apple,t8152-gfx-ascwrap-v8" provider: - a counted FIFO for its post-office window; - the lifecycle helpers the G18 backend uses to start and stop the coprocessors, gated on the PMGR PSD service of each role; - a receive poller. Starting or stopping a coprocessor needs apple_mailbox.ascwrap_v8_cpu_control=1. The receive interrupt is used only with apple_mailbox.ascwrap_v8_rx_irq=1; otherwise the receive side is polled. Both default to off and are read-only at runtime. Ported from our earlier out-of-tree M6 port onto this tree's mailbox core.
The G18 GPU firmware places its crash buffer in memory the GPU UAT already maps, so the RTKit core must neither allocate nor map it. Add the APPLE_RTKIT_FIRMWARE_OWNED_CRASHLOG ops flag, in the style of the existing CoreAnalytics flag, and RtKit::new_g17p() to create such a client from Rust. Based on earlier work by DjDeveloperr.
Import the G18 backend of the Mac mini M6 (J873, T8152, G18G B1) from our earlier out-of-tree M6 port, which ran it on an older copy of this driver, together with its UAT support, mmu/t8152.rs. That port passed every test of the OpenGL 4.6 CTS once on the M6. The files are unchanged apart from some comments. Nothing builds them yet: the following commits move the backend to this driver's command layout and core, and then wire it up behind its own Kconfig option. Credits: - The G17P init-data model in g18/fw/initdata.rs (InstanceRole, ChannelEntry, the UAT level descriptors, the region runs, INITDATA_VERSION_WORD and the serializers around them, about 227 lines) is DjDeveloperr's work, from his August 2026 rebuild of the G17P (T8140) init-data model. Eryk Wieliczko carried it into the port, where it was adapted for G18. It was not published before. - The rest of the backend is Acelogic's.
The earlier out-of-tree M6 interface used a 272-byte render and an 88-byte compute command. Parse this driver's instead: struct drm_asahi_cmd_render (448 bytes) and struct drm_asahi_cmd_compute (200 bytes), zero-extending shorter payloads. - prior_vdm/prior_cdm move to 320/328 (render) and 136/144 (compute). They stay trivially satisfied: G18 retires each command before the next one starts. - scs_layout moves to 128. - Words G18 does not implement and does not report must be zero: timestamp copies, ray queries, the compute auxiliary allocation and intersection tables. - With DRM_ASAHI_RENDER_G18_RESOURCES (now bit 25) or DRM_ASAHI_COMPUTE_G18_RESOURCES (now bit 19) the payload is the complete command followed by the resources, and must be complete. USES_TEXTURE_STATE is now bit 18. The translation after parsing is unchanged.
T8152's two GPU coprocessors publish their own page-table roots and never touch the handoff page. Add UatFirmware::NoPeerRoots and the hooks it needs: - refuse a live firmware peer in the handoff page; - prepare, confirm and mirror the firmware-published high roots (mmu/t8152.rs); - preflight GPUVM maps against driver-owned aliases; - per-page range TLB invalidation; - downgrade cached mappings to uncached before unmapping them, with no cache flush request; - execution-context leases on contexts 3..63 instead of the slot allocator; - guard-page mappings and guard-tail aliases, with the GEM helpers they use. T8152 uses the default UatQuirks, the policy the earlier M6 port ran this UAT with. Everything new is under CONFIG_DRM_ASAHI_G18, so other GPUs' code is unchanged. Based on the earlier out-of-tree M6 port's T8152 UAT code, adapted to this tree's UAT code.
Adapt the imported backend to this driver. - It implements gpu::Gpu and queue::Queue as they are now. It uses the tracked-submission model, which is what the earlier port's batched VM_BIND and copy-before-sync submit amounted to. - Its timestamps are the shared CPU-written timestamp buffers, published at retirement. Their CPU path is now also built for G18. - The DRM device type, the IoMem/devres, MMIO, VMap and firmware request APIs, and the module's name are updated. - Its module parameters live in g18/params.rs. They are registered the way kernel::module! registers parameters, but only when the backend is built. - The T8152 SoC entry moves to hw/t8152.rs. - The G18-only PRIME import hook is dropped: this driver already gives core-created objects their driver data.
Add CONFIG_DRM_ASAHI_G18. With it, the module registers an "aurora-g18" platform driver for "apple,agx-t8152", as G16 does for its SoC. Its probe: - first checks the G18 parameters; - maps SGX and allocates the DRM device and DMA binding; - starts the firmware session the parameters select; - at the application stage, registers the render node over it; - in a diagnostic stage, keeps the firmware owner without one. The firmware session is retained until reboot, so manual unbind is suppressed.
Describe the M6 GPU in t8152-j873-gpu.dtsi: - the "apple,agx-t8152" node with its SGX window and PSD service blocks; - its eight reserved regions; - the GFX and GFX1 ASCWrap v8 mailboxes. Include it from t8152-j873g.dts. The reserved regions and the mailboxes stay disabled. A boot loader fills them from this boot's ADT and enables them, then writes the /chosen firmware receipt the driver checks.
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft. Adds a G18 backend for the Mac mini M6 (T8152, G18G GPU) to the current driver, so that the M6 uses this driver's userspace interface.
Tested on an M6 with this branch (
3abc8618d010) plus a test-only SMC thermal-telemetry patch that is not part of this PR, booted from aura. The G18 firmware starts andaurora-g18binds the render node. With Mesa #164, GL 4.6 renders directly: pixel-exact readbacks pass, and so do a 13-case CTS canary and a 32-case texture and multisample slice. Every logged GPU job retired, with no faults or recoveries. No kernel change was needed. No full CTS run yet.What it adds
drivers/gpu/drm/asahi/g18/andhw/t8152.rs, behindCONFIG_DRM_ASAHI_G18(default n).t8152-j873g.dts.The GPU starts only after the boot loader has prepared it. Otherwise the driver stops before it touches the firmware.
Numbers for dj to ack
DRM_ASAHI_FEATURE_G18_GRAPHICS_SCRATCH1ULL << 31DRM_ASAHI_FEATURE_G18_NATIVE_TILE_SAMPLES1ULL << 32(a#define)DRM_ASAHI_RENDER_G18_RESOURCES1U << 25DRM_ASAHI_COMPUTE_USES_TEXTURE_STATE1L << 18DRM_ASAHI_COMPUTE_G18_RESOURCES1L << 19Verified offline
Credits and sources
g18/fw/initdata.rsand the RTKit crash-buffer change are adapted from DjDeveloperr's earlier work, which was not published before. dj, add your Signed-off-by if you want, or tell us how you'd like it credited.