Repository navigation
drm/asahi: G14 27.2: bind timestamp buffers, fix timestamp operations, admit sampler heaps and helpers - #3086
Conversation
The Timestamp operation of a firmware command stream carries one word for the user timestamps. In the 13.5 command layout and in the M3 27.2 runtime that word names the command's pair of user start and end destinations; the firmware reads the destination from that pair. The G14 27.2 render streams instead stored the start destination in the start operation and the end destination in the end operation, so the firmware would have read the user buffer's contents as the pair and written its stamps wherever they pointed. The compute stream left the word and the pair empty, so compute commands never got user timestamps. No user timestamps reach this runtime yet, since it refuses to bind timestamp buffers, so neither has been seen. Make the word name the pair the render commands already carry, or zero without user timestamps, as the M3 27.2 render and compute encoders do. Give the compute command its pair after the internal timestamp pointers, where the 13.5 compute command and the 27.2 render commands keep it, and pass the packet's compute destinations to it. The pair placement and the operation word are host-tested. Signed-off-by: Ryan Murray <[email protected]>
GEM_BIND_OBJECT with USAGE_TIMESTAMPS returned ENOTSUPP on the G14 firmware 27.2 runtime, so Vulkan could not create timestamp query pools and OpenCL profiling failed. That firmware reaches the kernel window through its own copy of the window's second-level entries, made once before it starts (FirmwareWindow::mirror), so a leaf table created later for a timestamp buffer would never be seen by it. The graph already keeps its private allocations below the 64 MiB timestamp aperture that the 27.2 root hands to the firmware. Link the aperture's leaf tables, with no mappings, before the window is mirrored, the way the kernel lower tables are prepared for a firmware that samples its root only at start (Uat::prepare_lower_tables, now sharing one helper with the new prepare_kernel_tables). Page tables are only freed with their VM, so the mirrored entries stay valid; leaf entries written later are cleaned to the point of coherency by the adopted UAT's page table as for every other firmware mapping. The graph records its profile's timestamp aperture, and the common GpuManager::map_timestamp_buffer maps into it: the native aperture as before, the 27.2 one for the 27.2 profile. The 27.2 backend delegates to it as it does for its parameters and clock, so timestamp buffers are bound, retained by the commands that name them and unmapped exactly as on the 13.5 path. Signed-off-by: Ryan Murray <[email protected]>
The G14 firmware 27.2 runtime takes its client commands through the front end shared with the M3 runtime, whose 26.x commands stream their sampler state and carry no helper program, so that front end refuses both. On the M2 this refused every render command that names a sampler heap with ENOTSUPP: Zink renders through Borealis, which always names its heap, so Zink applications lost the device on their first such pass. Compute commands with a helper program, which Mesa uses for scratch and stack setup, were refused with EINVAL by the common compute translator. The G14 27.2 render builders already write the sampler heap and both helper programs where the 13.5 render commands keep them, and the 27.2 compute command carries the 13.5 compute JobParameters1, which holds the helper. Let a queue say that its builders encode these, as it already says which depth and stencil compression layouts it encodes, and set it for the G14 27.2 queues. Their render admission then checks the sampler heap like the compute translator does instead of refusing it, and their compute commands take the helper from the client and write it to the JobParameters1 places the 13.5 compute path fills. The vertex helper's configuration goes to the tiling parameters, as on 13.5. The M3 queues refuse both as before. The 27.2 compute command's sampler placement is not known, so compute commands with a sampler heap are still refused. Signed-off-by: Ryan Murray <[email protected]>
|
J473 row: J413 row: same three commits before the rebase onto main, on the J413 (M2 Air, 13.5): pass. gpubench Vulkan 99 ok / 0 fail (timestamp and occlusion queries included), Geekbench 6 Vulkan 8/8, s2idle pass, 0 failed units after restore. Evidence
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Verdict at Blockers: Checked: The sampler heap uses the existing validator, the timestamp aperture is prepared before mirroring, and the ordinary J473 workload row is recorded. Completion of a valid workload does not exercise helper admission checks. Please repeat the exact J473 target row after the runtime change and identify the matching J413 regression build. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: HOLD at 7521672b
Blockers:
drivers/gpu/drm/asahi/m3/m3_submit.rs:402-419, 472-504: User-supplied helper descriptors (compute.helper,render.vertex_helper,render.fragment_helper) are admitted onsamplers_and_helpersqueues without validation. The compute path stripspayload.helperviacore::mem::replacebeforeagx_uapi::translate_compute_command(also zeroingpayload.helperbefore the rejection log on line 409), andvalidate_renderskips the non-empty helper rejection without checkingvertex_helperorfragment_helper. Every other user-supplied GPU program/address inm3_submit.rsis checked againstQueueUscWindowandAddressSpace(including!driver_range_overlaps). Validate all three helper descriptors before encoding (reject malformed descriptors withbinary == 0and non-zeroconfig/data, verifybinarytagging and mapped read coverage insideQueueUscWindow/AddressSpace, and validateconfig), or keep helper admission disabled and land timestamp binding, timestamp operations, and render sampler heaps separately.- §5 hardware evidence: After updating helper admission, re-run and record the exact-head J473 (G14G, firmware 27.2) row (with SELinux/unit/kernel-error regression counts and helper validation coverage) and identify the exact tested commit SHA/build for the J413 (13.5) regression row.
Checked: §1–§4 and §6 pass (except §2/§3 helper validation blocker above); §5 J473 tree e207372c matches 7521672b, J413 row lacks commit SHA and J473 needs re-run after fix; CI green (host-tests, readiness, pr-text); zero AI attribution; clean human DCO across all 3 commits.
Evidence
- Timestamp buffer binding (
g14_v27_2.rs,gpu.rs,gpu/v27_2.rs,mmu.rs): Sound.prepare_kernel_tableslinks all L3 tables forIOVA_G14_V27_2_TIMESTAMP_RANGE(0xffffffa181400000..0xffffffa185400000) withclean_pocbeforeFirmwareWindow::mirror/install.GpuManager::map_timestamp_buffermaps uncached (PROT_FW_SHARED_RW), keeps L3 tables on unmap, and invalidates viakernel_vm.slot() == Some(0).GraphProfile::NativekeepsIOVA_KERN_TIMESTAMP_RANGEunchanged for G13/G14 12.3/13.5/14.x; G15–G18 paths are unaffected. - Timestamp operations (
g14_v27_2_abi.rs,g14_v27_2_render.rs,gpu/v27_2.rs,g14_v27_2.rs): Sound. Vertex (+0x5e4), fragment (+0x948), and compute (+0x2dc) pass the pair VA (or 0 when[0, 0]) to both start/end Timestamp ops; compute+0x2dc..+0x2ecdoes not overlap encoded or firmware-written fields. - Render samplers (
m3_submit.rs,agx_uapi.rs):validate_samplerenforcescount <= 1024, zero-pair consistency, 8-byte alignment, andAddressSpaceread coverage; M3 queues keepsamplers_and_helpers: false; compute sampler heaps stay rejected withENOTSUPP. - Non-blocking observations:
drivers/gpu/drm/asahi/m3/m3_submit.rs:472:DRM_ASAHI_RENDER_VERTEX_SCRATCH(1 << 0) is still rejected withENOTSUPPandg14_v27_2_render.rsdoes not setuses_scratch, so Borealis vertex-scratch passes that set both the flag andvertex_helperwill still be rejected until wired up.drivers/gpu/drm/asahi/g14_v27_2_render.rs:417, 908:sampler_max(0x564,0x8c8) is written asr.sampler_countrather thanr.sampler_count + 1as on G14 13.5 (queue/render.rs:872, 1323); worth verifying boundary indexing atsampler_count - 1.
- Commits & CI: All 3 commits (
e11accde9300,9bc8fcc62648,7521672bcdc3) authored/committed byRyan Murray <[email protected]>with validSigned-off-by:;host-tests,readiness / readiness, andpr-text / pr-textallSUCCESSat7521672bcdc30572e3f42d2a71e7c3f86d567cae; PR isOPEN,isDraft: false,MERGEABLE.
The G14 firmware 27.2 queues take render and compute helper programs from the client and write them into the firmware commands, but nothing checked them first. The common compute translator refuses any helper, so the compute path removed the helper before translation, and the render admission only checked that queues without helper support saw none. Check each helper descriptor before a queue takes it. It must either be empty, or name a tagged program offset that the queue's USC window maps readable, plus an 8-byte-aligned argument block that the submitting VM maps read-write. A configuration word or argument block without a program is refused. The render vertex and fragment helpers and the compute helper all go through the same check, which sits next to the sampler validation in the shared UAPI module. Queues that do not encode helpers refuse them as before. The m3-uapi host test covers empty, valid, stray, unmapped, misaligned and read-only descriptors. Signed-off-by: Ryan Murray <[email protected]>
The G14 firmware 27.2 compute command left its JobMeta flush_stamps word clear. That did not matter while compute commands carried no user timestamps. Once they do, a queue of them stops retiring: on the M2 mini, gpubench compute.light at queue depth 16 timed out within one or two runs. The firmware had fetched the commands but never retired them, no MMU fault was pending and no firmware timeout event came. Set flush_stamps, as the 27.2 render commands already do for their JobMeta and as the M3 27.2 compute command does when it does not coalesce. With it, the same loop ran eight times with every case passing and no timeout. Signed-off-by: Ryan Murray <[email protected]>
|
Status: draft. A compute hang was found with timestamps enabled, so this is not mergeable yet. Review fixes (pushed):
What blocks it: with timestamp binding working, gpubench
An earlier run at Next:
Evidence
|
…tamps # Conflicts: # drivers/gpu/drm/asahi/g14_v27_2_abi.rs
The comments added with the compute flush_stamps word said that a clear word stalls a compute queue that writes user timestamps. A later A/B on the M2 mini showed that those hangs came from the raised GPU performance-state cap (reverted in #3091). With the cap restored, the same compute loop ran 24 times clean. Say only why the word is set: the 27.2 render commands and the M3 27.2 compute command set it. Comment-only change. Signed-off-by: Ryan Murray <[email protected]>
|
J473 row: J413 row: Evidence
|
|
Independent review at I verified that the only delta from the hardware-tested parent |
|
@DjDeveloperr, your blocker at
MERGETRAIN6's independent pass at |
|
Merged at |
What: On the G14 firmware 27.2 runtime (M2 mini), three uAPI paths that work on 13.5 were refused or broken:
GEM_BIND_OBJECTwithUSAGE_TIMESTAMPSreturned ENOTSUPP, so Vulkan timestamp query pools failed (vkCreateQueryPool-2) and OpenCL profiling failed. The firmware copies the kernel window's second-level entries once, before it starts. The fix links the 64 MiB timestamp aperture's leaf tables, with no mappings, before the window is mirrored, the same way the lower tables are prepared. The commonmap_timestamp_bufferthen maps into the profile's aperture, so binding, retention and unmapping are the 13.5 code.flush_stampslike the 27.2 render and M3 27.2 compute commands do.samplers_and_helpers, likezls_compression_all_layouts). The sampler heap is then validated rather than refused. Every helper descriptor must be either empty, or a tagged program in the queue's USC window plus an 8-byte-aligned argument block the VM maps read-write. M3 queues refuse both as before.Tested: J473 (M2 mini, G14G, firmware 27.2), kit built from
1135c9ef. This headb77cd168only changes two code comments on top (shown in the commit). Default cmdline, saved fleet89 Stage 2, GNOME session:compute.lightwith GPU timestamps (16-64 commands in flight): 24 of 24 loops, 7/7 ok each, 0 timeouts.render.postfxMSAA4 (fleet87 Zink 39/41, with 2 segfaults).rejected, 0 MMU faults, 0 timeouts, 0 Oops. gnome-shell kept its PID, and fresh vkcube and vulkaninfo returned 0.J413 (M2 Air, 13.5, shares the common timestamp path), same kit: gpubench Vulkan 99 ok / 0 fail, GL native and Zink 43/43, Geekbench 6 Vulkan 8/8, s2idle pass. This is identical to its fleet89 baseline.
Host tests:
g14_v27_2_abi.rs8/8, plusm3-uapi(with the new helper cases),queue-priorityandasahi-m4all pass.Risk: two-way · J473 and any G14G Mac on 27.2 (all changes), and every Mac using the native graph (the timestamp range moves from a constant to a graph field with the same value). M3 queues keep their refusals. M3 27.2 on main still needs #2147, so no M3 Mac runs this front end from main today.
Not yet:
RUSTICL_ENABLE, Geekbench 6 OpenCL now runs Background Blur and Face Detection on the GPU. It then stops at Horizon Detection in Fedora's libclc (nir_shader not fully linked), which is userspace (fedora-aurora#498).Review history
9579e14b, which validates all three descriptors.4a0eae2e(computeflush_stamps) still credits the word with fixing those hangs, which was a wrong reading before the A/B. The word stays because the sibling commands set it.b77cd168corrects the code comments.Evidence
Our own traces,
traces/gpu/20261125-m2gpu-next/:20261125-093451-j473-u1d-m2t7(J473, this kit):row/hang/it*(the 24 compute loops),gpubench,gl-native,gl-zink,glmark2-*,gb6-*,klog-*.j413-t7(J413).*-j473-ab-m2z1,*-j473-ab-m2z2lab,*-j473-ab-m2rv1.traces/gpu/20261124-neon-bench-fleet.