Skip to content

asahi: run the M3 (G15G, T8122) on the native AGX3 path, behind ASAHI_M3_EXPERIMENTAL - #71

Closed
scottjones wants to merge 3 commits into
aurora-silicon:aurora-wipfrom
scottjones:t8122-g15g-native
Closed

scottjones wants to merge 3 commits into
aurora-silicon:aurora-wipfrom
scottjones:t8122-g15g-native

Conversation

@scottjones

@scottjones scottjones commented Oct 24, 2026 •

Copy link
Copy Markdown

Summary

This admits G15G (T8122, the M3 MacBook Air) on Eryk's native AGX3 path with the G15S profile, against the Aurora kernel's T8122 runtime on the 14.8.3 firmware. It's experimental: the device opens only with ASAHI_M3_EXPERIMENTAL=1, and prints mesa-m3's warning line. Without that, the driver says G15G is recognised but not admitted. agx_params_driver_supported stays a pure identity check, and the chip admission test covers it.

Three commits:

  1. asahi/clc: a g15g build of the internal programs. G15G shares agx3b with G15S, but it needs the scheduling stalls (agx_chip_needs_scheduling_stalls).
  2. asahi: keep G15G allocations out of the T8122 runtime's per-VM reservations, so binds there don't fail with EINVAL.
  3. asahi: the admission (chip 0x8122, one die, one cluster, AGX3, legacy firmware interface) and the native-path predicates.
 G15G VA layout (native AGX3 default -> T8122)
-  USC window  [2^40, 2^40 + 4 GiB)   # top half is runtime-owned
+  USC window  [2^40, 2^40 + 2 GiB)
   user heap   below the window, as on G15S, but its limit is
+              0x7000000000: heap [0x4000000000, 0x5000000000),
+              alias [0x5000000000, 0x6000000000), all below 2^39
+  VDM aliases skip [0x1000800000, 0x1002000000)   # runtime USC base

The kernel side is drivers/gpu/drm/asahi/m3/m3_runtime.rs (Runtime::new_vm) on omacom/linux-aurora integration/aurora.

Evidence

Tested on a MacBook Air 13" M3 (J613), 14.8.3 firmware, kernel 7.2.11 (omacom/linux-aurora integration/aurora with the T8122 runtime, asahi.t8122_start=1). This branch was built on the Mac and selected per process with env vars:

  • Before: Apple G15G uses the G15 command stream, which this driver does not implement. Clients fall back to softpipe.
  • After, with ASAHI_M3_EXPERIMENTAL=1, on an earlier version of this series (heap above the USC window; replaced after review because Gallium's screen-init txf_sampler can't address it). The current layout has not run on hardware yet:
    • Vulkan (honeykrisp), a compute test: PASS, 1396 runs, 0 wrong.
    • GL through zink on honeykrisp: a GLES draw with readback passes (109,760 frames in 3 s, exact pixels). gpu-heat ran 11,916 frames in 3 s.
    • GL on the Gallium driver: the same draw passes (99,706 frames in 3 s, exact pixels), renderer Apple M3 (G15G C0).
    • No GPU fault, timeout or firmware error in the kernel log.

Checked without hardware: the chip admission test, which covers G15G's identity, the env gate (unset, 0, 1) and the heap layout against the runtime's reservations and 2^39. It fails when the G15G cap or the gate is removed.

Not covered: a run of this layout, a debug-build Gallium screen, texture sampling, MSAA, tessellation/geometry, queries, sparse or indirect paths, conformance tests, a desktop session, the 26.x (HAL200) firmware and the 15-inch J615.

Merge Danger

Door: two-way

Blast Radius: G15G only

Every change is behind dev->chip == AGX_CHIP_G15G, the new g15g libagx target, or G15G's admission, which needs the env var. Other chips build and run exactly as before.

Questions:

  • Eryk: is the G15S profile right for G15G on the legacy firmware, or does it need its own records somewhere these tests don't reach?
  • Ryan / DJ: would you rather have the T8122 holes here, like the G17/G17P hole lists, or have the kernel runtime moved to the G15 driver's VA layout?

🤖 Generated with Claude Code

G15G (T8122, M3) shares the agx3b encoding with G15S but needs explicit
scheduling stalls (agx_chip_needs_scheduling_stalls), so the G15S build
of the precompiled programs is not usable on it. Add a g15g target.
Nothing selects it yet.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Scott Jones <scottajones@gmail.com>

@maralcbr maralcbr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @scottjones, nice to see the Air on the native path. One blocker, then my take on the VA question.

Blocker: Gallium screen creation on G15G. With the heap above the window, the split puts the main heap at 2^41. agx_pipe.c:2724-2733 packs the USC_SAMPLER txf_sampler with cfg.buffer set to an ordinary (main-heap) BO at screen creation, for every chip. That field is an absolute shr(3) 36-bit address, so its bound is 2^39 (cmdbuf.xml:901-907; the generated packer checks < 0x8000000000). In builds without NDEBUG, that's UNREACHABLE the moment a GL client opens the screen. In release builds the address silently loses its high bits. hk already handles this by packing the legacy record only on AGX2 and zeroing it otherwise (hk_device.c:119-128). Gallium needs the same guard. I didn't find another reachable absolute USC texture/sampler emitter on G15G: native compute dispatches through Ioto and returns before agx_build_pipeline (agx_state.c:8673-8745), and native graphics and BG/EOT do the same. So the comment at agx_device.c:1085-1090 is right in practice, apart from this one.

VA holes. I'd keep them in Mesa for now, behind the experimental gate, in one place:

  • The kernel's reservations (m3_runtime.rs Runtime::new_vm) are not in the UAPI. Mesa hardcoding them couples us to kernel internals, but that's the precedent G17/G17P already set, and nothing else can tell us yet whether 0x7000000000..0x8000000000, the top half of the USC window and 0x1000000000.. are firmware-imposed or just the runtime's choice. Moving the kernel side to G15's layout (only [0x7000000000, 0x7100000000)) is the better end state, but only once someone shows on hardware that the runtime can relocate them.
  • Longer term, the kernel should report its reserved ranges (or a flag for the layout) through GET_PARAMS, so Mesa stops copying addresses from m3_runtime.rs.
  • Within Mesa, consider keeping G15G on the same below-window layout as G15S and capping the user limit at 0x7000000000. The existing halving loop then gives main [0x4000000000, 0x5000000000) and the sparse shadow [0x5000000000, 0x6000000000), all below 2^39 and clear of the runtime's range. That drops the G15G-only user_start and heap_below_usc branches and removes the whole 2^39 class of problems, including the one above. Keep the USC window shrink and the compact-alias exclusion: your reservation plus the existing carveout already covers both 0x1000000000..0x1008000000 and 0x1074000000..0x1074028000.

Tests. The admission test drops the negative G15G asserts and adds positive and wrong-identity cases, which is right. Please also cover the env gate (unset means recognised but not admitted) and the G15G VA layout (no heap or alias range touches the kernel's reservations, nothing above 2^39 if you switch layouts). Before un-drafting: a debug-build Gallium screen, texture sampling, MSAA, and compute that samples textures on the J613.

Policy: opt-in only. agx_chip_driver_supported(G15G) is now true with no env check, but every device open goes through agx_open_device (Gallium and both hk paths), so the env gate holds. Fine as an experiment.

Comment thread src/asahi/lib/agx_device.c Outdated
* absolute 36-bit-shr(3) and 38-bit-shr(2) fields of the legacy USC records,
* which G15G's native path does not emit (it uses Ioto pointers and compact
* VDM aliases). */
const bool heap_below_usc =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heap moves to 2^41 here, which puts Gallium's screen-init txf_sampler (agx_pipe.c:2724-2733, legacy USC_SAMPLER, 2^39 bound) out of range: UNREACHABLE in non-NDEBUG builds, truncated in release. Either guard that pack the way hk does (hk_device.c:119-128), or keep G15G below the window with the user limit capped at 0x7000000000.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. G15G is back below the window, with the limit at 0x7000000000, so nothing in the main heap or its alias reaches 2^39.

Comment thread src/asahi/lib/agx_device.c Outdated
*/
/* G15G (T8122) runs on the native path only on explicit request. */
if (dev->chip == AGX_CHIP_G15G && agx_params_driver_supported(&dev->params)) {
if (!debug_get_bool_option("ASAHI_M3_EXPERIMENTAL", false)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for the gate (unset means "recognised but not admitted"), since agx_chip_driver_supported(G15G) alone now says yes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. agx_chip_experimental_admitted() is tested with ASAHI_M3_EXPERIMENTAL unset, 0 and 1, and the other chips are always admitted.

Comment thread src/asahi/lib/agx_va_runtime_hole.h Outdated
* the 2^40 USC window and 0x7000000000 up to 0x8000000000, as well as its own
* USC base at 0x1000000000 (drivers/gpu/drm/asahi/m3/m3_runtime.rs,
* Runtime::new_vm). A bind that touches one fails with EINVAL. */
#define AGX_T8122_RUNTIME_WINDOW_HIGH UINT64_C(0x10080000000)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These mirror m3_runtime.rs Runtime::new_vm by hand. Worth a note naming the kernel commit they match, until the kernel reports them.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The comment names Runtime::new_vm in drivers/gpu/drm/asahi/m3/m3_runtime.rs as of omacom/linux-aurora 4888ad0a0f (merged in be6381f9d2).

scottjones and others added 2 commits October 24, 2026 18:42
The T8122 kernel runtime reserves four ranges in every VM: its USC base
at 0x1000000000, the top half of the 2^40 USC window, 0x1074000000 and
0x7000000000 up to 0x8000000000. Binds that touch them fail with EINVAL.
The native AGX3 layout puts the internal programs at the top of the
window, the sparse alias of the heap across 0x7000000000, and compact
VDM aliases at 0x1000800000.

On G15G, use the lower half of the window, cap the heap and its sparse
alias below 0x7000000000 (agx_va_user_limit: heap [0x4000000000,
0x5000000000), alias up to 0x6000000000, below the 2^39 bound of the
absolute USC Texture/Sampler field), and keep the compact alias heap out
of the runtime USC base. The 0x1074000000 range already falls inside the
alias heap's reserved span. The constants mirror the kernel's
Runtime::new_vm by hand. Nothing admits G15G yet.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Scott Jones <scottajones@gmail.com>
Run the M3 (T8122, G15G) on the native AGX3 path with the G15S profile
(G15 records, Gen4 samplers, classic queues), with its own build of the
internal programs and its scheduling stalls, against the kernel's T8122
runtime on the 14.8.3 firmware. G15G is admitted only for chip 0x8122,
one die and one cluster, AGX3 and the legacy firmware interface, and the
device opens it only with ASAHI_M3_EXPERIMENTAL=1, the switch mesa-m3
already uses (with mesa-m3's warning line), through
agx_chip_experimental_admitted(). Without it the driver says so instead
of reporting an unknown command stream. The chip admission test covers
G15G's identity, the gate (unset, 0 and 1) and the G15G heap layout
against the runtime's reservations and the 2^39 bound.

On a J613 (MacBook Air 13-inch, M3) with the T8122 runtime, an earlier
version of this series, with the heap above the USC window, passed
compute-check and a GLES draw with readback through zink on honeykrisp
and on the Gallium driver. This layout has not run on hardware yet.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Scott Jones <scottajones@gmail.com>
@scottjones

Copy link
Copy Markdown
Author

Thanks, the blocker was real: with the heap at 2^41, the Gallium screen's txf_sampler (agx_pipe.c:2728) can't hold the address. We took your second option. G15G now keeps the G15S layout below the window, with the user limit capped at 0x7000000000 (agx_va_user_limit). That gives a heap of [0x4000000000, 0x5000000000) with its alias up to 0x6000000000, all below 2^39. The G15G-only user_start and heap_below_usc branches are gone. The USC window shrink and the compact alias exclusion stay.

The env gate now lives in agx_chip_experimental_admitted(), which agx_open_device uses. The admission test covers it with the variable unset, set to 0 and set to 1. It also checks the G15G layout against all four of the runtime's reservations and against 2^39. Removing the G15G cap or opening the gate makes it fail.

Agreed on the VA holes: they stay in Mesa behind the gate for now, and the kernel should report them through GET_PARAMS later. The PR stays a draft until the J613 has run this layout: a debug-build Gallium screen, texture sampling, MSAA, and compute that samples textures. The Air is off right now. Until then, the hardware numbers in the body are from the earlier layout, and it says so.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ran this on our side: a build, the asahi unit tests and an M1 Pro (G13) no-regression pass. The comparison base is 4911479, which is what this PR sits on.

One test needs updating. asahi-agx3-packing fails at src/asahi/genxml/tests/test-agx3-packing.c:934 ("got 0x1, expected 0x0"). The test still lists AGX_CHIP_G15G in narrow (line 924) and expects agx3_cdm_barrier_pack() to refuse the wide-visibility form on it, but this PR adds G15G to agx3_cdm_barrier_wide_visibility_grounded(). Moving G15G from narrow to the wide list (line 902) fixes it. With that change the whole test passes (26,051,936 checks). CHECK_EQ exits on the first failure, so we ran the rest of that binary with the change in place, and nothing else in it fails. Apart from this test, the asahi suite gives the same results on base and on this PR.

Other chips are unchanged. A generated test takes the base versions of the functions this PR touches and compares them, for every chip identity except G15G, against the new ones:

  • agx_va_user_limit() against the old heap_below_usc ? AGX_G17P_USER_LIMIT : kernel_start, for both heap modes and seven kernel_start values;
  • agx_chip_native_agx3(), agx_chip_native_indirect_compute(), agx_chip_native_imageblock(), the two CDM predicates and agx_chip_driver_supported().

Across 18 chip identities and 504 checks, all are equal. asahi-chip-admission passes.

M1 Pro (G13S C0), base and PR release builds on the same boot:

  • Vulkan CTS stride50 (64,952 names) and tessellation (1,103 names): 20,490 and 390 Pass on both, with 0 status changes.
  • vulkaninfo reports the same device whether ASAHI_M3_EXPERIMENTAL is unset or set to 1.

@scottjones

scottjones commented Oct 26, 2026 •

Copy link
Copy Markdown
Author

Closing this: the same G15G support, including the layout fix and the wide-visibility test change, landed in omacom#12 and ships in mesa-aurora. We're running Marcelo's hardware list against that build on the Air now and will post the results there.

@scottjones scottjones closed this Oct 26, 2026
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.

3 participants