Repository navigation
asahi: run the M3 (G15G, T8122) on the native AGX3 path, behind ASAHI_M3_EXPERIMENTAL - #71
scottjones wants to merge 3 commits into
Conversation
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>
7b8830c to
1d5ceb5
Compare
maralcbr
left a comment
There was a problem hiding this comment.
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.rsRuntime::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 whether0x7000000000..0x8000000000, the top half of the USC window and0x1000000000..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 fromm3_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-onlyuser_startandheap_below_uscbranches 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 both0x1000000000..0x1008000000and0x1074000000..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.
| * 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 = |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Done. G15G is back below the window, with the limit at 0x7000000000, so nothing in the main heap or its alias reaches 2^39.
| */ | ||
| /* 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)) { |
There was a problem hiding this comment.
Please add a test for the gate (unset means "recognised but not admitted"), since agx_chip_driver_supported(G15G) alone now says yes.
There was a problem hiding this comment.
Added. agx_chip_experimental_admitted() is tested with ASAHI_M3_EXPERIMENTAL unset, 0 and 1, and the other chips are always admitted.
| * 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) |
There was a problem hiding this comment.
These mirror m3_runtime.rs Runtime::new_vm by hand. Worth a note naming the kernel commit they match, until the kernel reports them.
There was a problem hiding this comment.
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).
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>
1d5ceb5 to
0163e7f
Compare
|
Thanks, the blocker was real: with the heap at 2^41, the Gallium screen's The env gate now lives in Agreed on the VA holes: they stay in Mesa behind the gate for now, and the kernel should report them through |
RyanTheTide
left a comment
There was a problem hiding this comment.
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 oldheap_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 andagx_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_EXPERIMENTALis unset or set to 1.
|
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. |
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_supportedstays a pure identity check, and the chip admission test covers it.Three commits:
asahi/clc: ag15gbuild of the internal programs. G15G shares agx3b with G15S, but it needs the scheduling stalls (agx_chip_needs_scheduling_stalls).asahi: keep G15G allocations out of the T8122 runtime's per-VM reservations, so binds there don't fail with EINVAL.asahi: the admission (chip 0x8122, one die, one cluster, AGX3, legacy firmware interface) and the native-path predicates.The kernel side is
drivers/gpu/drm/asahi/m3/m3_runtime.rs(Runtime::new_vm) on omacom/linux-auroraintegration/aurora.Evidence
Tested on a MacBook Air 13" M3 (J613), 14.8.3 firmware, kernel
7.2.11(omacom/linux-auroraintegration/aurorawith the T8122 runtime,asahi.t8122_start=1). This branch was built on the Mac and selected per process with env vars:Apple G15G uses the G15 command stream, which this driver does not implement. Clients fall back to softpipe.ASAHI_M3_EXPERIMENTAL=1, on an earlier version of this series (heap above the USC window; replaced after review because Gallium's screen-inittxf_samplercan't address it). The current layout has not run on hardware yet:gpu-heatran 11,916 frames in 3 s.Apple M3 (G15G C0).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 newg15glibagx target, or G15G's admission, which needs the env var. Other chips build and run exactly as before.Questions:
🤖 Generated with Claude Code