Repository navigation
drm/asahi: g16: take render scratch on T6030, fit both stages in a pool - #4254
Conversation
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>
|
J516s (M3 Pro, T6030, G15S B1, 18 active GPU cores, OS firmware 27.2) module-only hardware verification for All three mixed vertex+fragment processes ( |
|
Hardware row at head Kit: |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
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_LISThad 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, andalloc_pb_heap_chunkstays inside it), so it ends where render window 0 starts. Placement::Scsrefuses 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
2a823d9921edreserves 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-m4passed 27/27. That includestest-ray-tracing.py(24 passed, with the new core-count test) andtest-abi-26b123.py.g16passed 4/4. - On main
bd3112c58d65: the same two families passed, and so didm3-(19/19) andg15-(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.
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_QUERYon 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-m41/1,g162/2,m3-19/19. The new host test fails on the flag-only tree atrequired_seeds(18, [989, 989]) = Err(E2BIG). arm64 W=1 build ofdrivers/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 reserves0x0130000060010070(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.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: itsPB_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 fromobject.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_QUERYtosupports_render_scschanges no feature word today. It still guards a configuration that refuses the scratch (T6031 once it starts). Its test edits the same two lines oftest-ray-tracing.pyas this PR (the T6030 pin and item 11), so it needs a small rebase after this lands.Evidence
Head
20d3215a45efon mainb0de7f101996.Host tests,
tools/asahi/run-host-tests.py --only <family>inlocalhost/aurora-linux-host-tests:ubuntu2404(ubuntu 24.04, rust 1.96.0,--network=none):asahi-m41/1 (the whole suite, 27 tests),g162/2,m3-19/19.test-ray-tracing.py, the same file on three trees: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 wordsarm64 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): baseb0de7f101996and 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 ing16/.aurora.osha256: basedce036526ca6, head400c502695af.