Skip to content

drm/asahi: g16: take render scratch on T6030, fit both stages in a pool - #4254

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/g16-t6030-render-scs
Dec 4, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/g16-t6030-render-scs

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: Take render ray-query scratch on T6030 (M3 Pro), and make every g16 SCS pool window 256 MiB so that both render stages of Mesa's ray-query layout fit one pool on 18 cores. M3 Pro keeps native ray tracing: vertex, geometry and fragment ray queries no longer lose the device (QUEUE_CREATE refused the scratch with EOPNOTSUPP), and neither does a process that uses both stages (QUEUE_CREATE E2BIG at 128 MiB). This replaces #4184's way out, hiding RENDER_RAY_QUERY on T6030, which would also have taken away compute ray queries and ray-tracing pipelines there.

Tested: J516s decision row for #4184 (flag alone, old window; comment): compute, fragment, vertex and geometry ray queries 18/18 and 400/400 acceleration-structure cases pass with 0 faults and 0 recoveries; the vertex + fragment process lost the device, as the E2BIG predicted, which is what the window change here fixes. Host tests in the hosted-CI image: asahi-m4 1/1, g16 2/2, m3- 19/19. The new host test fails on the flag-only tree at required_seeds(18, [989, 989]) = Err(E2BIG). arm64 W=1 build of drivers/gpu/drm/asahi/: base and head build with the same 25 warnings (rustc 1.100 dead-code and deprecation warnings already on main, none new). checkpatch --strict: 0 errors, 0 warnings, 0 checks. rustfmt clean.

Risk: two-way · M3 Pro; M3 and M4 (where their SCS pools sit in the client VA)

Not yet: J516s row at this head (module kit; the mixed vertex + fragment processes must pass); J773g row at this head (the VA move on T8132)

Details

Why two stages did not fit. A render pool holds the base 8192 seeds plus, per stage, (pages + pages/256 + 8) x cores (rt::required_seeds, the M4 Pro's formula), in whole 2-MiB rows. Mesa reserves 0x0130000060010070 (989 pages per core) for any stage with ray queries, and replaces its queue with both stages reserved once a process has used both. A 128-MiB window held 31744 seeds (62 rows) and its 4-MiB freelist: two stages fit up to 11 active cores.

active cores one stage both stages fits 128 MiB fits 256 MiB
10 (J773g, J615) 18432 28672 yes yes
14 (binned M3 Pro) 22528 36352 one stage yes
18 (J516s) 26624 44544 one stage yes
20 (T6030 core slots) 28672 48640 one stage yes

The window. 256 MiB holds 126 rows (64512 seeds) and the freelist. The basis is the most cores of a configuration that takes render scratch: the T6030's 20 core slots need 95 rows (190 MiB) and the 4-MiB freelist for both stages. The pool table has 256 rows; macOS 27.2 on the J773g has used 108-row pools.

Where the windows go. The two SCS compute windows keep their start after DYNAMIC (0x7060000000) and now fill the same span up to the CT window (0x7080000000). The two render windows move after the PB heap window: PB_HEAP + PB_HEAP_SIZE = 0x70d0000000 up to 0x70f0000000, below the context-0 work range of lower aliases (0x70f1000000, Objects::alloc_private_in). g16 placed nothing there: its PB_BLOCK_LIST (0x70e0000000) was never used and goes (g15 keeps its own). The const asserts check the new placement; the ray-tracing host test checks the context-0 bound, reading it from object.rs.

What changes on other chips. Pools are still sized from the request, so on the 10-core T8132 and T8122 every pool keeps its size (the host test pins Mesa's 18432 / 28672 / 24576 / 25088). Only addresses move there: SCS compute pool 1 0x7068000000 to 0x7070000000, SCS render pools 0x7070000000 / 0x7078000000 to 0x70d0000000 / 0x70e0000000. The J773g row covers that.

What gets larger on T6030. At 18 cores the render pools a one-stage queue creates already hold both stages (44544 seeds, 174 MiB, was 26624), so the queue Mesa recreates with both stages fits them; compute SCS pools hold two dispatches as on the 10-core parts. Pool memory is allocated from the request; the 256 MiB is address space.

T6031 (M3 Max) stays without render scratch: no hardware row, and its start is refused. At 40 cores both stages need 88576 seeds, more than this window, which its own row will have to settle.

#4184. With this, every configuration that can start takes render scratch, so tying RENDER_RAY_QUERY to supports_render_scs changes no feature word today. It still guards a configuration that refuses the scratch (T6031 once it starts). Its test edits the same two lines of test-ray-tracing.py as this PR (the T6030 pin and item 11), so it needs a small rebase after this lands.

Evidence

Head 20d3215a45ef on main b0de7f101996.

Host tests, tools/asahi/run-host-tests.py --only <family> in localhost/aurora-linux-host-tests:ubuntu2404 (ubuntu 24.04, rust 1.96.0, --network=none): asahi-m4 1/1 (the whole suite, 27 tests), g16 2/2, m3- 19/19.

test-ray-tracing.py, the same file on three trees:

tree result
this PR 24 passed
main + the T6030 flag only (the decision row's kernel) 3 failed: mesa_ray_query_render_stages_fit_on_every_core_count (required_seeds(18, [989, 989]) = Err(-7)), the window size pin, the largest-pool encoder words
main fails at the T6030 admission pin

arm64 W=1 of drivers/gpu/drm/asahi/ (J516s config: gcc 16.2.0 cross, rustc 1.100.1; warm, base and head each in a fresh overlay of the same build tree): base b0de7f101996 and head both build (83 s and 94 s, 4 Rust and 27 C objects each). 42 warning lines each, 25 distinct, the same set on both; none in g16/. aurora.o sha256: base dce036526ca6, head 400c502695af.

T6030 (M3 Pro) refused every render scratch reservation while
RENDER_RAY_QUERY was advertised, so Mesa lost the device on the first
ray query in a vertex, geometry or fragment shader. Take it there, as
on T8132 and T8122.

A 128-MiB SCS pool window held a pool for both render stages of Mesa's
ray-query layout (989 pages per core) on at most 11 active cores. On an
18-core M3 Pro, a process that runs a ray query in one render stage and
then in the other makes Mesa recreate its queue with both stages
reserved, and that QUEUE_CREATE failed with E2BIG: a lost device too.
Make each window 256 MiB. The T6030's 20 core slots need 95 rows
(190 MiB) and the 4-MiB freelist for both stages.

The two compute windows keep their start after the dynamic range and
now fill it up to the CT window. The two render windows move after the
PB heap window, where g16 places nothing (its PB_BLOCK_LIST constant was
unused and goes). Pools are still sized from the request, so the pools
of the 10-core T8132 and T8122 keep their sizes; only where their render
pools and second compute pool sit in the client VA changes.

J516s (18 cores, firmware 27.2) with the flag alone and the old window:
compute, fragment, vertex and geometry ray queries 18/18 and 400/400
acceleration-structure cases passed with no fault or recovery, and the
vertex + fragment process lost the device as the E2BIG predicted. The
ray-tracing host test now checks both stages on 18 cores and on the
core slots of every configuration that takes render scratch.

T6031 (M3 Max) stays refused: it has no hardware row.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

DjDeveloperr commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor Author

J516s (M3 Pro, T6030, G15S B1, 18 active GPU cores, OS firmware 27.2) module-only hardware verification for linux#4254 (20d3215a45efb08250229acb62304e32b6f13e84, backported 38 driver lines onto 7.3.0-f3822 + #4198, signed aurora.ko build-id 6795d111633c5460d7c449013fe6aa9cfcdf4c5d, boot 8c660d59-bb33-478b-bdea-dd6f283032a7): VERDICT PASS (19 PASS, 0 FAIL, 0 INCOMPLETE)

All three mixed vertex+fragment processes (4a 2/2, 4b 2/2, 4c 10/10) and all 400 AS cases passed at C=18 with 0 GPU faults/recoveries, 0 DART/IOMMU faults, and 0 kernel warnings.

PASS       kernel release :: 7.3.0-f3822
PASS       loaded aurora.ko is an arm of this kit :: 6795d111633c5460d7c449013fe6aa9cfcdf4c5d = scs
PASS       same boot_id start..end :: 8c660d59-bb33-478b-bdea-dd6f283032a7 -> 8c660d59-bb33-478b-bdea-dd6f283032a7
PASS       watchdog (1min) and dead-man armed :: wd=1min dm=armed-20min
PASS       active GPU core count C :: C=18
PASS       clean start stats (0 recoveries/quarantined) :: {'recoveries': 0, 'recovery_receipts': -1, 'quarantined': 0}
PASS       recoveries/receipts/quarantined unchanged :: {'recoveries': 0, 'recovery_receipts': -1, 'quarantined': 0} -> {'recoveries': 0, 'recovery_receipts': -1, 'quarantined': 0}
PASS       0 GPU faults / recoveries / event=0x7x in klog :: 0 lines []
PASS       0 DART/IOMMU faults in klog :: 0 lines []
PASS       0 WARN/BUG/Oops/SError in klog :: 0 lines []
PASS       Test 0 compute ray queries :: 3/3 Pass
PASS       Test 1 fragment :: 5/5 Pass
PASS       Test 2 vertex :: 5/5 Pass
PASS       Test 3 geometry :: 5/5 Pass
PASS       Test 0b ray-tracing-pipeline ray queries :: rgen=Pass, chit=Pass
PASS       Test 4a mixed vertex + fragment in one process (both render stages in one SCS pool) :: C=18 2/2 Pass, order ['builtin.flow.frag.triangles', 'builtin.flow.vert.triangles']
PASS       Test 4b mixed vertex + fragment in one process (both render stages in one SCS pool) :: C=18 2/2 Pass, order ['builtin.flow.vert.triangles', 'watertightness.nomiss.frag.triangles']
PASS       Test 4c mixed vertex + fragment in one process (both render stages in one SCS pool) :: C=18 10/10 Pass, order ['builtin.flow.frag.aabbs', 'builtin.flow.frag.triangles', 'builtin.flow.vert.aabbs', 'builtin.flow.vert.triangles', 'watertightness.nomiss.frag.aabbs', 'watertightness.nomiss.frag.triangles', 'watertightness.nomiss.vert.aabbs', 'watertightness.nomiss.vert.triangles', 'watertightness.singlehit.frag.triangles', 'watertightness.singlehit.vert.triangles']
PASS       Test 5 (300 frag + 100 vert AS) :: 400/400 clean (400 Pass, 0 NotSupported)
VERDICT PASS (19 PASS, 0 FAIL, 0 INCOMPLETE, stopped=None)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Hardware row at head 20d3215a45ef on J773g (Apple Mac mini M4, T8132, G16G B0, 10 cores, 27.2): PASS (19 PASS, 0 FAIL, 0 INCOMPLETE).

Kit: work/rows-scs6030-j773g-20261203 (KIT.sha256 034b440bcf29…, --check 14/14, check j773g 8/8).
Kernel: 7.3.0-j773g-main3685+, aurora-scs.ko build ID 4b648243c167c3250d7534b9d3206bc584d52aba, boot_id=79d64ca4-79e9-426f-8861-d06c2a096aa5.
Receipt: work/rows-scs6030-j773g-20261203/results/scs/verdict.txt.

PASS       kernel release :: 7.3.0-j773g-main3685+
PASS       loaded aurora.ko is an arm of this kit :: 4b648243c167c3250d7534b9d3206bc584d52aba = scs
PASS       same boot_id start..end :: 79d64ca4-79e9-426f-8861-d06c2a096aa5 -> 79d64ca4-79e9-426f-8861-d06c2a096aa5
PASS       watchdog (1min) and dead-man armed :: wd=1min dm=armed-20min
PASS       active GPU core count C :: C=10
PASS       clean start stats (0 recoveries/quarantined) :: {'recoveries': 0, 'recovery_receipts': -1, 'quarantined': 0}
PASS       recoveries/receipts/quarantined unchanged :: {'recoveries': 0, 'recovery_receipts': -1, 'quarantined': 0} -> {'recoveries': 0, 'recovery_receipts': -1, 'quarantined': 0}
PASS       0 GPU faults / recoveries / event=0x7x in klog :: 0 lines []
PASS       0 DART/IOMMU faults in klog :: 0 lines []
PASS       0 WARN/BUG/Oops/SError in klog :: 0 lines []
PASS       Test 0 compute ray queries :: 3/3 Pass
PASS       Test 1 fragment :: 5/5 Pass
PASS       Test 2 vertex :: 5/5 Pass
PASS       Test 3 geometry :: 5/5 Pass
PASS       Test 0b ray-tracing-pipeline ray queries :: rgen=Pass, chit=Pass
PASS       Test 4a mixed vertex + fragment in one process (both render stages in one SCS pool) :: C=10 2/2 Pass, order ['builtin.flow.frag.triangles', 'builtin.flow.vert.triangles']
PASS       Test 4b mixed vertex + fragment in one process (both render stages in one SCS pool) :: C=10 2/2 Pass, order ['builtin.flow.vert.triangles', 'watertightness.nomiss.frag.triangles']
PASS       Test 4c mixed vertex + fragment in one process (both render stages in one SCS pool) :: C=10 10/10 Pass, order ['builtin.flow.frag.aabbs', 'builtin.flow.frag.triangles', 'builtin.flow.vert.aabbs', 'builtin.flow.vert.triangles', 'watertightness.nomiss.frag.aabbs', 'watertightness.nomiss.frag.triangles', 'watertightness.nomiss.vert.aabbs', 'watertightness.nomiss.vert.triangles', 'watertightness.singlehit.frag.triangles', 'watertightness.singlehit.vert.triangles']
PASS       Test 5 (300 frag + 100 vert AS) :: 400/400 clean (400 Pass, 0 NotSupported)
VERDICT PASS (19 PASS, 0 FAIL, 0 INCOMPLETE, stopped=None)

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review December 4, 2026 02:10
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 4, 2026 02:10
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Merge readiness at 20d3215a: not ready yet

Check Detail
CI at head ok 10 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 20d3215a
Conflicts ok none
PR text ok Risk: two-way · M3 Pro; M3 and M4 (where their SCS pools sit in the client VA)

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review: clean. I reviewed head 20d3215a45ef and found no defects, so this is ready to merge. (This account wrote the PR, so GitHub only lets me post this as a comment.)

Which chips run this code. g16 drives T8132 (M4), T8122 (M3), T6030 (M3 Pro) and T6031 (M3 Max, which is still refused at start). M4 Pro/Max (T6040/T6041), M5 and J700 (G17P) probe through g17, so this change does not touch them. On T8122 the only change is the same address move as on T8132, with the same 10-core pool sizes. The J773g row covers that shared code and the J516s row covers G15, so T8122 does not need its own row.

Memory and address space. Pools are still allocated at the size the request needs (Placement::pool_bytes, seeds × 4 KiB). The 256 MiB is only address space. With Mesa's layouts on the 10-core chips, pool sizes stay the same. On the J516s a ray-query render pool grows from 104 MiB to 174 MiB. A VM has at most two of these, and only a process that uses render ray queries gets one. A larger request than Mesa's can now get a pool of up to 252 MiB (it was 124 MiB). That is still bounded, and E2BIG beyond it.

Placement.

  • The compute windows cover the same span as before (0x7060000000 up to the CT window).
  • The render windows use 0x70d0000000 to 0x70f0000000. g16 had nothing mapped there: PB_BLOCK_LIST had no g16 users, because its block lists live in the render unit records.
  • The PB heap is exactly 256 MiB (2048 blocks of 128 KiB, asserted in resources.rs, and alloc_pb_heap_chunk stays inside it), so it ends where render window 0 starts.
  • Placement::Scs refuses local slots 2 and up, so a third render window cannot happen.
  • Everything stays below the context-0 lower range at 0x70f1000000 and inside 0x7000000000 to 0x7100000000. Mesa aurora-wip 2a823d9921ed reserves that whole range on every native AGX3 chip (agx_va_runtime_hole.h), so no user buffer can land there.

Window math. 256 MiB gives 126 rows (64512 seeds) plus the 4 MiB freelist, which fills the window exactly. Each window starts on a 256 MiB boundary. required_seeds uses checked arithmetic and returns E2BIG past the cap.

The constant. SCS_POOL_WINDOW is part of the kernel's own client address layout. It is not a value from the ADT or the firmware. The comment shows where the number comes from (the T6030's 20 core slots and Mesa's 989-page layout need 95 rows and the freelist), and the new host test checks it against the core counts in the configs. The T6030 flag change rests on the J516s row.

ABI. The feature word does not change: T6030 already advertised RENDER_RAY_QUERY. The difference is that QUEUE_CREATE now accepts render_scs_layout where it used to return EOPNOTSUPP. No UAPI struct changes. In check-abi-26b123.rs only the T6030 assert flips, so current Mesa is fine.

Tested here. I merged the head into main and ran the host tests in the pinned CI image with --network=none. Neither #4240 nor #4246 shares a file with this PR.

  • On main c042c5f9a8e6: asahi-m4 passed 27/27. That includes test-ray-tracing.py (24 passed, with the new core-count test) and test-abi-26b123.py. g16 passed 4/4.
  • On main bd3112c58d65: the same two families passed, and so did m3- (19/19) and g15- (18/18).

Hardware rows at this head. Both passed with 0 faults and 0 recoveries:

  • J516s, at C=18: 19/19, including mixed vertex and fragment 4a, 4b and 4c.
  • J773g, at C=10: 19/19.

@DjDeveloperr
DjDeveloperr merged commit 9b8e29f into main Dec 4, 2026
13 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/g16-t6030-render-scs branch December 4, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant