Skip to content

drm/asahi: g16: advertise RENDER_RAY_QUERY only where render SCS is supported - #4184

Closed
DjDeveloperr wants to merge 1 commit into
mainfrom
fix/g16-render-ray-query-follows-scs
Closed

DjDeveloperr wants to merge 1 commit into
mainfrom
fix/g16-render-ray-query-follows-scs

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: On T6030 (and T6031) the g16 runtime advertises RENDER_RAY_QUERY, then refuses the render scratch reservation the bit promises: DRM_IOCTL_ASAHI_QUEUE_CREATE with a nonzero render_scs_layout fails with EOPNOTSUPP, and the first ray query in a vertex, geometry or fragment shader becomes VK_ERROR_DEVICE_LOST. Set the bit from the same supports_render_scs capability the queue checks, so it is only offered where it works. See aurora-silicon/mesa#1585.

Cost on T6030 until supports_render_scs is measured there: current Mesa uses this one bit to decide on all native ray tracing, so T6030 loses VK_KHR_ray_query and VK_KHR_ray_tracing_pipeline completely: ray queries in compute and ray-tracing pipelines too, not only in graphics stages. VK_KHR_acceleration_structure stays. If T6030 passes a row with supports_render_scs: true, that flip is the better fix, and with this patch the bit comes back by itself.

Tested: no hardware run. Host tests and the arm64 build of drivers/gpu/drm/asahi/ pass; the Mesa side was checked offline (Evidence).

Risk: two-way · M3 Pro, M3 Max

Not yet: hardware row on J516s; a J516s run with supports_render_scs: true

Details

Why T6030 has supports_render_scs: false. It was never measured; nothing in the history says it fails.

The change. ray_tracing_features(cfg) gives RENDER_RAY_QUERY for supports_render_scs and BOUNDED_AS_BUILD for generation 15 and up, as before. No chip check. T8132 and T8122 report the same feature word as before.

BOUNDED_AS_BUILD is independent. DRM_ASAHI_COMPUTE_AS_BUILD only gives a compute command the longer allowance (rt::as_build(), rt::select()); it reserves no scratch, render or compute.

What Mesa does without the bit (read and run at mesa 484e42c96e9c, aurora-wip one merge behind its tip, which touches none of these files):

  • hk_g17p_rt_enabled() needs EXACT_PRIOR_BARRIERS | RENDER_RAY_QUERY; it goes false. hk_gen1_as_only_enabled() (EXACT_PRIOR_BARRIERS | BOUNDED_AS_BUILD) stays true, so the device keeps VK_KHR_acceleration_structure without traversal state. This is the existing path for kernels without traversal, with its own shim identity (g16s-as) and unit tests.
  • The extensions and the rayQuery / rayTracingPipeline features disappear, so an application cannot create a pipeline that uses them: nothing is refused at pipeline creation or at submit. There is no software fallback on AGX3 (it is for the AGX2 ISA).
  • Lost: VK_KHR_ray_query, VK_KHR_ray_tracing_pipeline, VK_KHR_ray_tracing_maintenance1, VK_KHR_ray_tracing_position_fetch, VK_EXT_ray_tracing_invocation_reorder, VK_EXT_pipeline_library_group_handles.
  • The kernel still accepts compute ray state (scs_layout, intersection tables) on T6030, and none of it needs render SCS. Keeping ray-tracing pipelines there would need a separate kernel bit for compute traversal and a Mesa change to read it; VK_KHR_ray_query needs the graphics stages.
  • Geometry and tessellation shaders without queries compile outside the native ray-query profile then (hk_native_rq_profile()), as on every kernel without the bit.

What enabling supports_render_scs on T6030 takes. Set it true on J516s and run what #3756 ran on the J615: the vertex, geometry and fragment ray-query probes, dEQP-VK.ray_query.builtin.flow and watertightness (vert, geom, frag), ray_query.acceleration_structures.*fragment_shader* and *vertex_shader*, with 0 GPU faults and 0 firmware recoveries. Both chips run the G15 26B123 protocol and register lists. The differences to watch are two clusters and up to 18 cores: required_seeds() and pool_seeds() scale the pool with the active cores, and the largest layout has to fit the SCS pool window (E2BIG otherwise).

Not changed: validate_render_entry() still takes a render stage's intersection words from generation 15 on. Without a reservation it refuses scratch (EINVAL), as before.

Evidence

Head f0259abfefbcca3166635fd2aaa2d506fda178ba on a05d99c9dbc2 (main has moved 10 commits since, none in these files).

Host tests in the hosted-CI image (ubuntu 24.04, rust 1.96.0), tools/asahi/run-host-tests.py --only: asahi-m4 1/1 (the whole asahi-m4 suite), g16 2/2, g15-display-order 1/1, m3-recovery 2/2. test-ray-tracing.py: 24 passed.

The new test takes each configuration in hw.rs and generations 13 to 16 with both flag values, and checks that the bit is set exactly when reserve_render_scs() takes the reservation:

source result
this PR 24 passed
old condition (gpu_generation >= 15) in the helper fails: left == right failed: 15 false
BOUNDED_AS_BUILD following the flag fails

arm64 LLVM=1 W=1 drivers/gpu/drm/asahi/ (asahi profile, DRM_ASAHI=m, G15 and G16 on, clang 23, rustc 1.100): builds, no new warning. Base and head print the same 39 warnings of that newer toolchain, line for line; asahi_core.o differs between them. checkpatch on the diff: 0 errors, 0 warnings.

Mesa 484e42c96e9c (x86, asserts on) with the noop drm-shim as "Apple M3 Pro (G15S B1)", reporting the g16 feature word with and without bit 15 (0x81026001c001 / 0x810260014001 on top of the shim's G15S bits). The shim copy was patched to refuse render_scs_layout like T6030 and to skip its old-backend G15S packet rules. It runs no GPU work, so "Fail" below only means "submitted, no pixels".

bit set (main) bit clear (this PR)
device extensions 185 179 (the 6 above)
accelerationStructure / rayQuery / rayTracingPipeline 1 / 1 / 1 1 / 0 / 0
device with every extension and feature enabled created created
ray_query.builtin.flow compute and ray-tracing stages submitted NotSupported
ray_query.builtin.flow.frag.aabbs QUEUE_CREATE refused, VK_ERROR_DEVICE_LOST NotSupported
ray_query.{misc,builtin.flow,watertightness} 112/112 NotSupported, 0 crashes, 0 lost
ray_tracing_pipeline.{misc,builtin,watertightness} 649/649 NotSupported, 0 crashes, 0 lost

Without ray tracing the two arms agree: geometry (200), tessellation (1,114), clipping (308), api.info (10,490), info, transform_feedback.simple.basic*, pipeline.monolithic.stencil (58,496): 0 crashes or lost devices in either. Three tessellation.tess_io.level_io cases flipped once under load (the shim's memory is not initialised) and were equal in 4 of 4 reruns. In subgroups.basic only the 5 ray_tracing.* cases change, to NotSupported.

…upported

RENDER_RAY_QUERY tells userspace that a queue takes render_scs_layout, the
scratch its render stages' ray queries run on. The g16 runtime sets the bit
on every GPU from generation 15 on, but reserve_render_scs() refuses a
nonzero layout with EOPNOTSUPP on a configuration whose supports_render_scs
is false: T6030 and T6031. Userspace that trusts the bit fails to create
the queue of its first render with a ray query in a graphics stage, and
reports a lost device.

Set the bit from supports_render_scs. BOUNDED_AS_BUILD keeps its generation
check: AS builds are compute commands with a longer allowance and reserve no
scratch. T8132 and T8122 report the same feature word as before.

The host test checks that a configuration advertises the bit exactly when
its queues take the reservation, for every configuration in hw.rs. It fails
with the old condition.

Fixes: cc04c5d ("drm/asahi: g16: admit ray queries and bounded AS builds on G15")
Signed-off-by: DjDeveloperr <hey@djdev.me>

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The render feature now reflects the same scratch capability used by queue creation. Bounded acceleration builds remain independently advertised. The shim shows the reported queue failure turns into an unavailable feature. Mesa also withdraws compute traversal on these identities because it shares the bit, as documented. That trade-off and T6030 hardware qualification remain visible.

@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 of f0259abfefbc by a reviewing agent that didn't write it. The code does what it says, but I don't think this should merge. Measure the other direction first.

What fails today on T6030 (main, flag false): a vertex, geometry or fragment ray query makes Mesa create a queue with a nonzero render_scs_layout; reserve_render_scs() returns EOPNOTSUPP and Mesa marks the device lost. Nothing is submitted, and mesa#1585 reports no recovery from it. Compute and ray-tracing-pipeline queries need no reservation, so the kernel accepts them. That is from the code: I found no J516s run that shows their results are right.

Why not this PR: Mesa uses the same bit for all native ray tracing, so it also removes compute ray queries and ray-tracing pipelines, which the kernel accepts today, to avoid a failure that only graphics stages are known to have. #3132 gave no measurement for the false, and #3756 set true on T8122 from J615 runs and left T6030 "until measured".

What true would change, read from the code: QUEUE_CREATE takes the reservation; a stage with scratch gets two more records (0x017e1 = 1, 0x017d9 = 1; TA 74 to 76, FS 82 to 84), START_SCS = 1, and the size / window / stack / tail / table words, on a larger UMA pool. T8122 runs the same lists and words.

A limit to know before flipping it. With Mesa's layout (989 pages per core) the pool window holds two stages only up to 11 active cores. At 14 or 18 cores required_seeds() (compiled from this tree) gives one stage 22528 or 26624 seeds, which fits, and both stages E2BIG. So on a 12+ core part a queue that runs a vertex and then a fragment ray query still loses the device. SCS_POOL_WINDOW would have to grow for that. A CTS run that mixes the two in one process would look like a failure of the flip.

Row that decides it (one boot, J516s): main plus only the flip and the two tests that pin the old value (check-abi-26b123.rs, test-ray-tracing.py); read the active core count from dmesg first; ray_query.builtin.flow and watertightness for frag, vert and geom each in its own process, then a vert + frag process as the predicted E2BIG case, then a sample of the AS fragment and vertex cases. Pass: all pass, no new recovery, fault or quarantined slot, and the mixed case as predicted.

Please keep this one as a draft until that row. If it passes, the flip plus a larger window replaces this PR, and the change here to tie the bit to the flag is still right as a follow-up.

Run on the merge with main dbfe45ac89b6: asahi-m4 1/1, g16 2/2.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Keeping this PR in draft until the remaining hardware decision row runs.

What is left before leaving draft (or closing as superseded)

  • J516s (T6030, G15S, os-fw 27.2 / 26B123) decision row on main (with the T6030 PCIe PWREN fix #4213) + t6030::CONFIG.supports_render_scs = true (plus the two test pins in check-abi-26b123.rs and test-ray-tracing.py):
    • Record the active core count from dmesg and clean initial aurora-g16/stats (recoveries=0, quarantined=0).
    • Run the compute ray-query control, single-stage fragment / vertex / geometry dEQP-VK.ray_query.{builtin.flow,watertightness} lists (each in its own process), the predicted E2BIG mixed vertex+fragment single-process case (for >= 12 active cores), and an acceleration-structure fragment/vertex sample.
    • If that row passes with zero faults/recoveries/quarantined slots, flipping supports_render_scs = true together with enlarging SCS_POOL_WINDOW supersedes hiding RENDER_RAY_QUERY on T6030 (and tying the feature bit to supports_render_scs here can still land cleanly as a follow-up).
    • If it fails, #4184 (f0259abfefbc) remains the fix and needs a J516s row at main + #4213 + f0259abfefbc verifying RENDER_RAY_QUERY is cleared, BOUNDED_AS_BUILD remains, and zero faults/recoveries occur. (T8132's feature word is unchanged since supports_render_scs is true there.)

Merge status

  • Merges cleanly onto current main (2eceb1f24262) and onto #3340 (a134833c6f92); no code changes needed until the J516s decision row runs.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (MacBook Pro 14-inch M3 Pro, T6030, G15S B1, 18 active GPU cores, OS firmware 27.2 / 26B123) decision row for t6030::CONFIG.supports_render_scs = true: HARDWARE PASS.

Stack under test

  • Kernel: 7.3.0-rs4184 (base linux:main 9ea227719398 + t6030::CONFIG.supports_render_scs = true and the two host selftest pins in check-abi-26b123.rs / test-ray-tracing.py; commit 8a78285ee81b, tree 828af95ee9af, vmlinux build-id 9c14362f60153d4ad1f48ad4135b0ab128836571, aurora.ko build-id c80417217bf947f9a1c8a1022d20cb1c10ad90cb).
  • Mesa ICD: private aurora-wip 80c8e761fcd5 (libvulkan_asahi.so sha256 b342054edc80fe2c5a877060c134f2b254d41f430f1dbd7d247e22e2398df22b), shader cache disabled.
  • Vulkan CTS: vulkan-cts-1.4.7.1-2-g3fd4ea318fe2a2ec320371ef555a78b947bc9edc.
  • Boot: b36be6f6-6421-4fac-92e4-86f03d80620e (single boot start..end, 2026-12-03T23:22:36Z..23:22:47Z, T6030: 18 cores enabled).

Results

  • Test 0 (control compute ray query): 3/3 Pass.
  • Test 1 (fragment ray query): 5/5 Pass.
  • Test 2 (vertex ray query): 5/5 Pass.
  • Test 3 (geometry ray query): 5/5 Pass.
  • Test 4 (mixed frag+vert in one device, predicted E2BIG for C=18 >= 12): dEQP-VK.ray_query.builtin.flow.frag.triangles ran first and passed (Pass), then dEQP-VK.ray_query.builtin.flow.vert.triangles hit the expected queue-creation limit (DeviceLost: vk.queueSubmit(queue, 1u, &submitInfo, *fence): VK_ERROR_DEVICE_LOST at vkCmdUtil.cpp:338), with 0 GPU recoveries and 0 faults.
  • Test 5 (300 fragment + 100 vertex acceleration-structure / ray-query cases): 400/400 Pass (0 NotSupported, 0 Fail, 0 timeouts; 100/100 across all four chunks).
  • GPU & kernel health: jobs 481 -> 7072 (render_ordinal 481 -> 1351, compute_ordinal 0 -> 6589), recoveries 0 -> 0, hang_kills 0 -> 0, quarantined 0 -> 0, recovery_receipts: affected_full 0 aborted 0, 0 GPU faults / event=0x7x, 0 DART/IOMMU faults, 0 WARN/BUG/Oops/SError.

Conclusion

t6030::CONFIG.supports_render_scs = true works cleanly on T6030 (G15S B1, 18 cores) across fragment, vertex, and geometry ray-query stages and all 400 acceleration-structure cases, with the expected E2BIG boundary when both vertex and fragment reserve render SCS on the same 18-core device. Flipping supports_render_scs = true for t6030 (alongside #4184 gating RENDER_RAY_QUERY on supports_render_scs) preserves full VK_KHR_ray_query + VK_KHR_ray_tracing_pipeline support on M3 Pro.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

The decision row above passed with the flag alone except the vertex + fragment process, which lost the device at QUEUE_CREATE (E2BIG: 44544 seeds for both stages at 18 cores, 31744 in a 128-MiB window). #4254 takes render scratch on T6030 together with 256-MiB SCS pool windows, so both stages fit; its host test fails on the flag-only tree at required_seeds(18, [989, 989]). J516s and J773g module kits at its head are with the M3 and M4 leads.

After it lands, tying RENDER_RAY_QUERY to supports_render_scs here changes no feature word (every configuration that starts takes render scratch). It still guards T6031 for when that starts, so this can rebase on #4254 (the T6030 pin and item 11 of test-ray-tracing.py conflict) or close.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Superseded by #4254 (merged as 9b8e29f). T6030 now takes render scratch, so it keeps RENDER_RAY_QUERY. Tying the flag to render-scratch support can come back with the T6031 bring-up.

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