Repository navigation
asahi: reuse private syncobjs and share completion with GL fences - #1418
Conversation
Signed-off-by: DjDeveloperr <hey@djdev.me>
Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: HOLD at 6e79ebde
Blockers:
- Pending second GPU-generation hardware row listed under Not yet before merge.
Checked:
src/gallium/drivers/asahi/agx_fence.c,agx_fence.h,agx_pipe.c,agx_state.h: verifiedsubmit_syncobjsfront/back partition invariant (ready + returned <= capacity), single-ioctl batchdrmSyncobjReset()whenreturned == capacity(with destroy fallback on reset error), non-overlapping cleanup loop inagx_destroy_screen(), andowns_private_handlegating so externally imported syncobj handles (agx_fence_from_fd) are destroyed rather than recycled.src/gallium/drivers/asahi/agx_batch.c,agx_fence.c: verifiedbatch->syncobjandsubmit_syncobjshare the same accepted submission's output fence,agx_retire_batch()still runsagx_check_batch_fence()before retiring onexported_fence->signaled, release/acquire ordering viap_atomic_set()/p_atomic_read()(__ATOMIC_RELEASE/__ATOMIC_ACQUIRE),last_submit_batch/last_submit_completehandoff across immediate retirement and faulted contexts (ctx->any_faults), and zero recycling ofsubmit_syncobjon failed/split submit error paths.- Hardware/test evidence at exact head
6e79ebde: J700 (A18 Pro, G17P B1) paired ABBA/BAABcompute.lightFIFO (-6.74%at depth 16,-9.28%at depth 64; binary waits2.515 -> 1.610/dispatch),2,360/2,360native GLES31 CTS, cross-context GL server-wait readback, and 23 Gallium host tests.
Evidence
agx_fence_populate()setsf->owns_private_handle = truebeforeutil_queue_fence_signal(&f->ready), andbatch->exported_fenceholds a reference onfuntilagx_batch_cleanup()on the context thread, avoiding any use-after-free or torn-flag race on threaded-context teardown.agx_destroy_context()drains all submitted batches viaagx_sync_all()(droppingbatch->exported_fencerefs) and destroys any unconsumedctx->last_submit_fenceunderscreen->destroy_lock.- Non-blocking note:
agx_poll_batch()andagx_sync_batch()still wait directly onbatch->syncobjrather than short-circuiting onbatch->exported_fence->signaled; safe as written sinceagx_cleanup_batches()already takes the fast path.
|
Review at What I checked:
What's left before merge: a hardware row at this head on a second GPU generation (G15 or G16). |
There was a problem hiding this comment.
Verdict: HOLD at 557db281
Blockers:
- Second GPU-generation hardware row remains pending before merge (
Not yet: only MacBook Neo J700G17P B1has been run so far).
Checked:
- Forward merge
557db281(6e79ebde..557db281): only unrelatedsrc/asahi/compiler/agx_nir_lower_cmat.cand M5 BVH files entered fromaurora-wip; zero changes tosrc/gallium/drivers/asahi/(agx_fence.{c,h},agx_pipe.c,agx_state.h,tests/test-fence.cpp,+135/-27). - Private syncobj pool partition (
ready + returned <= capacity), single-ioctl batchdrmSyncobjReset(),owns_private_handlegating of imported handles, and shared batch/GL-fence completion (__ATOMIC_RELEASE/__ATOMIC_ACQUIRE) remain intact.
Evidence
- Code remains clean with zero defects found at
557db281; ready to approve once the second GPU-generation hardware row is posted.
|
J773g (M4 mini, T8132 G16G) peer row: parity. Native GL d16 at The PR head is now
GLES31 conformance: 2,360 cases per arm (195 compute, 104 synchronization, 2,061 SSBO). Base and this PR both gave 2,360 Pass, 0 Fail, with identical case-by-case status, and both native server-wait readbacks passed. 0 GPU faults, driver warnings, recoveries or hang kills. |
There was a problem hiding this comment.
Verdict: MERGE at 557db281
Blockers: none.
Checked:
src/gallium/drivers/asahi/agx_fence.{c,h},agx_pipe.c,agx_state.h, andtests/test-fence.cpp(+135/-27): private syncobj pool (ready + returned <= capacity) resets returned handles in onedrmSyncobjReset()ioctl (with destroy fallback on error),owns_private_handlekeeps imported handles out of the pool,agx_destroy_screen()destroys non-overlapping slices, andagx_retire_batch()/agx_check_batch_fence()share completion across submitted batch and exported GL fence with release/acquire atomics and safe TC teardown ordering.- Forward merge
557db281ontoaurora-wip: zero conflicts, zero diff vs6e79ebdeinsrc/gallium/drivers/asahi/. - Dual GPU-generation hardware verification complete:
- MacBook Neo (
J700,A18 Pro,G17P B1):-6.74%paired depth-16 latency (16.687 -> 15.540 µs,1.00%A/A bound), binary waits2.515 -> 1.610/dispatch,2,360/2,360GLES31 CTS pass, cross-context GL server-wait pass, 23 host tests pass, 0 faults. - Mac mini M4 (
J773g,T8132,G16G): depth-16 parity (37.355 -> 37.321 µs,-0.269%paired inside0.321%A/A drift across 4 A/B + 4 A/A blocks),2,360/2,360GLES31 CTS pass identical to base, both native server-wait readbacks pass, 0 GPU faults/warnings/recoveries/hangs.
- MacBook Neo (
Evidence
- Code independently verified clean; both GPU-generation hardware and GLES31 conformance rows pass with zero faults or regressions. Ready to merge into
aurora-wip.
|
@DjDeveloperr, code-owner heads-up: App approval at |
What
Native Gallium paid for a private syncobj on every submit, then batch retirement and the GL client could each wait on the same GPU work. Cache driver-owned binary handles on the screen and reset returned handles in a single ioctl before reusing them. When a GL fence takes the private output of an accepted submission, link it to that batch so either side can use completion observed by the other.
Tested
MacBook Neo (J700, A18 Pro, G17P B1), stock Fedora 44 kernel
7.3.0-41.fc44.aurora.aarch64, release Mesa base89ddabbf72c251ff2eaabecb8ebf0ec4755a0269and head6e79ebde27138e4e4114e93e6a2953fa4b50a209. Native Gallium and EGL mappings were checksum-verified for each arm. Depth-16 latency fell from 16.687 to 15.540 µs per completed dispatch, a 6.74% paired reduction against a 1.00% same-depth A/A bound.In three separately instrumented depth-16 runs per arm, binary waits fell from 2.515 per dispatch on base to 1.610 on head. Private-handle reuse alone (
53af2b7a006b) still issued 2.588 waits. Both reuse variants issued about one reset per sixteen dispatches and zero creates or destroys in the timed windows. All three arms issued one GPU submit per dispatch.The checked
compute.lightFIFO uses the shader from GPUBencha5409150182f9dd0f951ace2d009a832c3d449a1. Eachlight-gl DEPTH rateinvocation used a 300 ms warmup, five 250 ms windows and per-slot result and guard readback. CPU policy bounds were fixed to 2.472 and 1.464 GHz, the application inherited its normal CPU mask, and each qualified block held GPU P10 at 1.470 GHz. Native GL used a private EGL vendor manifest,EGL_PLATFORM=surfaceless,MESA_LOADER_DRIVER_OVERRIDE=asahiandMESA_SHADER_CACHE_DISABLE=true.Four qualified A/B blocks alternated ABBA and BAAB at each depth, with four matched base/base blocks. Paired latency change is the median of the blockwise ratios. The A/A bound is the largest absolute matched base/base change.
The depth-2 increase was within same-depth drift. Fixture source, exact commands, raw FIFO windows, DRM counts and scorer
All 2,360 native GLES31 CTS cases passed on both arms with identical case statuses (195 compute, 104 synchronization, 2,061 SSBO). The cross-context GL server-wait readback also passed on both arms. The head passed all 23 selected Gallium submit, retirement, asynchronous fence, server-wait and memory-barrier host tests. Zero GPU faults, kernel WARNs or AVCs were recorded. The Neo returned to stock with its CPU policies restored.
Risk
Batch retirement still checks asynchronous errors before publishing completion. The batch holds a reference to its exported fence until retirement. Completion sharing applies only to the private output from the same accepted submission. Resetting the recycled handle before reuse preserves the distinction between a newly published fence and a failed submission.
Not yet
A second GPU-generation hardware row is pending before merge.