Skip to content

Bring up T6041 M4 Max on G17P - #85

Merged
RyanTheTide merged 6 commits into
aurora-silicon:aurora-wipfrom
astaff:t6041/m4-max-g17p-20261027
Nov 5, 2026
Merged

RyanTheTide merged 6 commits into
aurora-silicon:aurora-wipfrom
astaff:t6041/m4-max-g17p-20261027

Conversation

@astaff

@astaff astaff commented Oct 27, 2026 •

Copy link
Copy Markdown

Why

Mesa's AGX driver already carries the M4 Pro (G17P, two clusters). The M4 Max is the same generation with four clusters and reports chip 0x6041. The USC helper tables assume at most two clusters, and the chip isn't admitted.

What

  • asahi: fill the USC base page on parts with more than two clusters; the two-cluster layout is unchanged.
  • asahi: admit the T6041 on the G17P path; add a drm-shim identity.
  • asahi: accept upstream UAPI parameters on the T6041. No aurora-silicon kernel reaches this path; it last ran with asahi_m4 on an earlier Mesa base.
  • rusticl: reject a zero-size local kernel argument; check local memory against the device limit at enqueue.

The linear PBE stride bias stays at 16. Every switch from earlier revisions is gone.

Testing

Mesa is this PR on a merge of the kernel PRs (aurora-silicon/linux#525 and its stack), no local patches, on a J616c running NixOS. Logs are at https://gist.github.com/astaff/d1f649ba0d29f5279762e2baa427e732.

  • glmark2 off-screen: 33/33 scenes, validation 27 success, 0 failure, 6 unknown.
  • glmark2 on the panel: 33/33 scenes, with 23 validation failures (the known on-panel baseline).
  • Linear render sweep passed.
  • Rusticl verifier passed at 32 KiB local memory.
  • Vulkan device listed and used by whisper.cpp: 800/800 transcripts on an earlier kernel merge, 123/123 on this one, 0 GPU recoveries.

Limits

  • Vulkan and OpenCL conformance on this chip are not qualified.
  • With the kernel driver named aurora, Rusticl needs RUSTICL_ENABLE=aurora; RUSTICL_ENABLE=asahi finds no device.

🤖 Generated with Claude Code

@astaff astaff changed the title asahi: bring up T6041 M4 Max on G17P Bring up T6041 M4 Max on G17P Oct 27, 2026
@astaff
astaff force-pushed the t6041/m4-max-g17p-20261027 branch from e5dabf4 to f81076a Compare October 27, 2026 22:00
@astaff
astaff force-pushed the t6041/m4-max-g17p-20261027 branch from f81076a to 96cff5b Compare October 28, 2026 21:43
@astaff
astaff marked this pull request as ready for review October 28, 2026 23:10
astaff added a commit to astaff/mesa that referenced this pull request Oct 30, 2026
Add T6041 admission/UAPI compatibility, four-cluster USC slots, Gen9
linear PBE pitch correction, shim coverage and Rusticl preflight checks.

Rebase PR aurora-silicon#85 onto aurora-wip cf4e081.
Resolve the Zink comment conflict while retaining the Borealis driver ID,
helper rename and M4 Max device ID. Preserve the other 15 PR file blobs.

The rebased commit still requires hardware verification before merge.
Software tests and clean merge checks do not establish hardware validation.

Original PR head: 96cff5b
Assisted-by: LLM
@astaff
astaff force-pushed the t6041/m4-max-g17p-20261027 branch from 96cff5b to 6916d73 Compare October 30, 2026 17:12

astaff commented Oct 30, 2026

Copy link
Copy Markdown
Author

Rebased onto aurora-wip at cf4e08105dfa526b8874318b6a52b3ce948f6297. New head: 6916d7316c12e5664a31b300437255858128bbfc.

Resolved the sole conflict in src/gallium/drivers/zink/zink_screen.c: retained the target branch's Borealis driver ID and helper rename, included M4 Max's 0x6041 device ID, and updated the comment. The other 15 PR file blobs are unchanged from the previous head.

Hardware verification is still required before merge for this exact rebased commit. No hardware testing was performed on the rebased head. The previous head's hardware results and the reported 119 software test passes do not validate this rebase on hardware.

Local verification: clean merge against the target, patch applicability and whitespace checks passed; the existing chip-admission test passed in a standalone GNU C build; a compiled comparison of the Zink predicate covered 4,194,304 driver/device combinations, with only Borealis/T6041 changing. A full Mesa build/test suite was not rerun for this rebase.

Before merge, rerun the relevant software suites and validate the exact head on M4 Max with the paired kernel and documented serial-render workaround, plus affected M4 Pro/M5 regression checks, especially shared Gen9 pitch and M5 USC/Gen10 behavior. This does not qualify Vulkan/OpenCL or full CTS, and does not resolve the known concurrent-render firmware restart/recovery issues.

@astaff
astaff force-pushed the t6041/m4-max-g17p-20261027 branch 2 times, most recently from ca90d8c to e6e04a9 Compare November 4, 2026 00:40

@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.

Thanks. The four-cluster helper-slot sizing is the core of this, and the tests around it are good. A few things need to change before it can go into aurora-wip.

Required fixes

  1. Signed-off-by (hard blocker). e6e04a9 has Assisted-by: LLM but no Signed-off-by:. Please add yours, same as on the kernel PRs.
  2. Gen9 linear PBE stride bias (src/asahi/lib/agx_pbe_agx3_core.c, stride_bias()/linear_stride_bias()). This changes the linear bias from 16 to 4 for every AGX_PBE_AGX3_GENERATION_9 descriptor, which includes the A18 Pro (MacBook Neo) and the M4 Pro, not only T6041. The PR body says this still needs a check on other Gen9 devices. We're running a linear-target render test on our M4 Pro and Neo, and results follow in a comment. Unless they come back identical, please scope the change to the chip that needs it, or show why 16 was wrong everywhere. Either way, please remove the ASAHI_G17P_LINEAR_PBE_STRIDE_BIAS override, since we don't add env knobs for hardware encodings.
  3. ASAHI_T6041_PROFILE=g16g (src/asahi/lib/agx_chip.c, in agx_chip_from_params) is a debug override for chip identification. Please drop it, along with the 0x6041 branch in the AGX_CHIP_G16G admission that exists only for it.
  4. New VA hole 0x7100000000..0x7300000000 (src/asahi/lib/agx_va_runtime_hole.c) applies to every G17P device and has no comment. What reserves that range on the kernel side? If it's the T6041 split firmware area from aurora-silicon/linux PR 525, please document it there and scope the hole to T6041.
  5. Unrelated changes in the same commit. The Rusticl local-memory checks (CL_INVALID_ARG_SIZE for a zero-size local arg, the overflow-checked layout) and agx_params_fixup_upstream_uapi() are reasonable, but they aren't T6041 bring-up. Please split them into their own commits so each can be reviewed and reverted on its own.
  6. Commit message. Please replace "The commit still requires hardware verification before merge" with what you ran on the M4 Max.

What passed so far: an A/B on our M4 Pro (J616s, fleet16 kernel, SELinux enforcing), comparing aurora-wip 05ddb00 with and without this PR, built as overlays from the same tree.

  • glmark2 full set: 18543 (base) vs 18704 (this PR); the packaged system Mesa scored 18649.
  • Vulkan smoke (compute plus a draw readback) passes on all three.

The Neo and linear-target results follow in a comment. The kernel side (PR 525) isn't mergeable yet, and 0x6041 admission is only useful together with it, so this waits for 525 either way.

@RyanTheTide

Copy link
Copy Markdown

These are the A/B results promised in the review. Both runs use aurora-wip 05ddb00, without this PR (base) and with it, built from the same tree as overlays. The kernel is fleet16 (no kernel changes), with SELinux enforcing.

M4 Pro (J616s) A18 Pro (Neo)
glmark2-es2-gbm full set, base 18543, 18524 9258, 9098
glmark2-es2-gbm full set, this PR 18704, 18576 9033, 9172
per-scene FPS (J616s) same 33 scenes, all within run-to-run spread
Vulkan smoke (compute + draw readback) pass pass
GPU faults or recoveries none none

The Neo is fanless and sat at 91 to 95 C, so its spread is wider. Neither machine shows a regression.

Linear colour targets. This is the case the stride-bias change targets. I rendered the same triangle into VK_IMAGE_TILING_OPTIMAL and VK_IMAGE_TILING_LINEAR RGBA8 attachments at widths 64, 100, 333 and 1000, and compared the readbacks byte for byte. They were identical on both machines with base and with this PR. So the 16 to 4 change shows no difference here. That could mean the hardware ignores the low four bits of the field for 16-byte-aligned strides, or that this path doesn't reach the linear PBE encoding. Either way, it's not evidence that 4 is right on Gen9 in general, so the request to scope or justify it stands. Did you see a visible difference on the M4 Max, and which workload showed it?

None of this changes the blockers in the review: the Signed-off-by, the env knobs, the VA hole and splitting the commit.

clSetKernelArg must return CL_INVALID_ARG_SIZE when arg_size is zero for
an argument declared with the local qualifier. The comment above the match
already says so, but MemLocal has no check.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
An oversized local argument is only known at enqueue, and the launch
closure cannot return an OpenCL error once it is queued. Pick the kernel
variant before building the closure and fail the enqueue with
CL_OUT_OF_RESOURCES when static local memory plus the local arguments,
laid out with the alignment the launch uses, exceed the device's local
memory. Use the same checked helper for the argument offsets at launch so a
huge size cannot wrap them.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
The G17P slot rule 0x100 + 16 * (16 * cluster + core) puts clusters 2 and
3 of a four-cluster part at +0x300..+0x390 and +0x400..+0x490, past both
helper tables. Give native AGX3 parts with more than two clusters the return
fill G15C already has, starting after the second table's terminals. Two
cluster parts keep the plain page and G15C's page does not change.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Generation 16 variant C with chip 0x6041, one die, four clusters, USC 3 and
HAL 200 takes the G17P contract, as the M4 Pro does. Admit it in Zink's
Borealis G17P check too.

Run on the M4 Max (J616c, 25F84 firmware) with an earlier revision of this
series as the system Mesa, which also carried a Gen9 linear PBE stride bias of
4 and a VA hole at 0x7100000000 that this series no longer has, on a kernel
with aurora-silicon/linux PRs 525, 732, 749 and 920 and local opt-in GPU
switches:

- Installed desktop profile with serial rendering on: renderer "Apple M4 Max
  (G16C B1)", display manager and both connected outputs up, no GPU
  recoveries.
- Ten boots with serial rendering off, three with no switch and seven with a
  local switch dropping the firmware's QoS preemption: the niri desktop on
  GLES 3.2 while whisper.cpp ran twenty times per boot on Honeykrisp (Vulkan
  compute). 200/200 transcripts correct, no GPU recoveries or faults.
- The same load with the QoS switch, stopped by request after 152 runs, no
  GPU recoveries.

glmark2 and the Rusticl verifier did not run on that revision. They ran on Mesa
f2c9dc3 with these changes as separate patches and serial rendering on:
glmark2 33/33 scenes, and Rusticl with 32 KiB of local memory, 32 rounds, no
mismatches and four invalid requests rejected. This final tree has not run on
hardware.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
ASAHI_SHIM_CHIP=t6041 reports the T6041 on the G17 kernel: variant C, USC 3,
HAL 200, the G17 feature word and queue limits, and the G17 render aux alias
and stream validation rules. Run the Gallium shim tests against it.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
A kernel built against the upstream UAPI ends drm_asahi_params_global at
command_timestamp_frequency_hz, so usc_generation and gpu_hal_generation
stay zero, and its feature bits above SOFT_FAULTS mean something else here.
When usc_generation is zero, mask the features to SOFT_FAULTS and, for the
T6041 only, imply USC 3 and HAL 200.

Admit variant X, which the out-of-tree asahi_m4 T6041 kernel reports, and add
a t6041x shim identity. Kernels that report usc_generation are untouched,
including aurora-silicon/linux with its variant C T6041, so no hardware run on
this tree reaches this path. It last ran on the M4 Max with asahi_m4 on an
earlier Mesa base.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
@astaff
astaff force-pushed the t6041/m4-max-g17p-20261027 branch from e6e04a9 to 53b30c6 Compare November 5, 2026 02:49

@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.

Thanks, every point from the review is done. The stride bias is back at 16, the env switches and the VA hole are gone, and the Rusticl and UAPI pieces are their own commits now.

Here, on aurora-wip c175370 with and without this PR: the asahi and vulkan suites are 76/76 on both, Rusticl builds clean, no new warnings. For the M4 Pro and the Neo the GL and Vulkan paths are the same as before, since the base page fill only kicks in above two clusters and the upstream UAPI fixup only runs when the kernel reports usc_generation 0, which none of ours do. The earlier A/B on both machines covered a bigger version of this. The kernel side is merged as of aurora-silicon/linux#958, so merging!

One small question for later. Variant X and the upstream UAPI path are for the out-of-tree asahi_m4 kernel, which nothing here ships. If nobody needs it anymore I'd rather drop it than carry it, what do you think?

@RyanTheTide
RyanTheTide merged commit 4371cf8 into aurora-silicon:aurora-wip Nov 5, 2026
satchlj added a commit that referenced this pull request Nov 5, 2026
aurora-wip gained the T6041 G17P path (#85). It adds
agx_params_fixup_upstream_uapi() in agx_chip.c and agx_chip.h at the
spot where this branch adds agx_params_native_kernel_abi_supported().
The two are independent; keep both, this branch's first.

They do not interact. agx_open_device() calls the ABI check only for
G15G, so the T6041 upstream UAPI path, whose features the fixup masks to
SOFT_FAULTS, never reaches it. The fixup only acts on parameters with
usc_generation 0, and G15G is admitted only with usc_generation 3.
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