Repository navigation
Conversation
…ned barrier When a G17 submission carries more than MERGED_DEPENDENCIES (8) scheduler dependencies, sync_input::merge() previously allocated a cursor array and delegated to __dma_fence_unwrap_merge(), which walks every input twice, heap-allocates and sorts a second pointer array, and wraps the result in a dma_fence_array. Every dma_fence_array completion also queues an irq_work (IPI) even when its final child signals inside asahi_g17_signal_fence(). Generalize sync_scope's per-CPU active_scopes deferred-completion node and add asahi_g17_barrier, a compact single-allocation variable-fan-in barrier that joins the same inline drain pass when triggered from asahi_g17_signal_fence() (falling back to irq_work only for foreign signalers or when SCOPE_ATOMIC_BATCH is reached). Update asahi_g17_merge_fences() and sync_input::merge() to: - use stack scratch buffers up to 64 fences (heap-allocating only above 64), - skip already-signalled non-error fences in a single pass, - deduplicate identical pointers and same-context fences (keeping the latest seqno) for small active sets while keeping large merges O(N), - preserve already-signalled error fences instead of dropping their status, - return the stub or single remaining fence directly without allocating a barrier when 0 or 1 fences remain. Extend tools/testing/selftests/drivers/gpu/asahi-m4/test-fence-signalling.py to cover asahi_g17_merge_fences() fast paths, same-context deduplication, error-fence preservation, and the >64 heap path. Signed-off-by: oreater <145754695+oreater@users.noreply.github.com>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 22d1339fe02a15d90074e230d4c1a161c4247428
Blocker: The new host merge tests mock asahi_g17_barrier_create(), so they only test selection of inputs. At this head there is also no hardware run of the production barrier. Please exercise the new callback/refcount path, including a child already complete during registration, the last child completing in the inline drain and from a foreign signaler, and a negative child status. Show one barrier completion and balanced child refs. The exact-head J716c stress and peer rows remain due.
Checked: Reviewed the collector, reference ownership, constructor guard, deadline snapshotting, and the bounded inline drain. The test cases for deduplication, error inputs and large inputs do not enter the production barrier. No DT, board gating, private material, or attribution changes.
|
Thanks @oreater. The review is waiting on tests that exercise the real barrier: a child already signalled at registration, the last child in the inline drain and from a foreign signaler, and a negative status. It also needs before/after numbers for the >8-dependency case and an exact-head J716c stress row. Can you add these within 24 h? If not, we park it and pick it up when there is room (maintainer edits are on). |
erikwb
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 22d1339fe02a
Blockers: the J716c row at this head is missing.
Checked: Traced callback registration, the constructor guard, callback and drain references, error publication, and deadline snapshots. No new hardware gates, runtime parameters or safety limits. The readiness checks passed and the branch has no conflicts. The equivalent-path boot predates this head. Exact-head J716c and peer rows are still due.
Evidence
Question, not blocking until measured: drivers/gpu/drm/asahi/g17/sync_input.c:161 keeps timeline chain wrappers as barrier children. That may cost the signalling path this change optimizes. Take a render submit with eight other pending inputs and a two-point chain whose leaves have distinct contexts. Let the newest leaf complete first and the predecessor complete last, after the first chain work has rearmed the callback and the other inputs have completed. The old merge unwraps the chain and queues one array completion. The new merge queues chain work for each leaf, then queues barrier work because the chain signals outside the driver's inline drain. Keep the flat fast path and retain the existing unwrap path for container inputs, or preserve the old leaf-level waiting in the new merge. A count of deferred work items per signal on that case, against main, would settle it.
drivers/dma-buf/dma-fence-chain.c:122 rearms via irq_work and signals with plain dma_fence_signal(). The render path in g17/queue/mod.rs:257 does not fold external inputs into firmware waits. The host merge tests replace the real barrier with a mock. Exercise the production callback path and show one barrier completion with balanced refs when a child completes during construction, the last callback runs on the inline path or a foreign path, and a child reports a negative status.
|
J716c (16-inch M5 Max) at EvidenceBuilt into batched kernel
Every fail and flaky case on both kernels is in |
… tests The merge tests replace asahi_g17_barrier_create() with a mock, so the new barrier's callback and reference path had no coverage. Compile the production g17/sync_scope.c unchanged against a single-CPU dma_fence, llist, per-CPU and irq_work model (ASan/UBSan on) and check, for children already signalled at registration, the last child signalled in the asahi_g17_signal_fence() drain or by a foreign signaler (irq_work fallback), a negative child status, a barrier waiting on a barrier and more ready barriers than SCOPE_ATOMIC_BATCH: one barrier completion, the expected inline or irq_work path, balanced child references and the barrier's release. Dropping the callback's barrier put, the inline drain, the error propagation, the child release on completion or the constructor guard each fails the test. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Thanks @oreater. I pushed 06a530f on top of your commit (test-only, no driver change) to answer the App finding. |
There was a problem hiding this comment.
Verdict: HOLD at 06a530fe for hosted CI and the J716c hardware row.
Checked: This delta compiles production sync_scope.c and exercises children already signalled at registration, inline and foreign completion, negative child status, nested barriers, early caller put, and the bounded drain handoff. The cases assert one completion and balanced references, addressing the host-coverage finding. The test models one CPU, so keep the current-head J716c stress and peer validation for the real IRQ path.
There was a problem hiding this comment.
Verdict: MERGE at 06a530fe1cfb
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: This delta compiles production sync_scope.c and exercises children already signalled at registration, inline and foreign completion, negative child status, nested barriers, early caller put, and the bounded drain handoff. The cases assert one completion and balanced references, addressing the host-coverage finding. The test models one CPU, so keep the current-head J716c stress and peer validation for the real IRQ path.
Follow-ups (not blocking): hosted CI; J716c IRQ-path stress row
DjDeveloperr
left a comment
There was a problem hiding this comment.
Changes needed at 06a530fe1cfb. The barrier code is sound, but the PR's own test fails once it is merged with current main.
Blocker: test-fence-signalling.py does not compile on the merge with main. At this head the script passes (exit 0). On a clean git merge-tree of this head with main 3d7cc83dffb1 it exits 1, because the extracted C harness fails to build:
test_sync_input.c:125,:153,:300,:310-312,:352:struct dma_fencehas no member namedstatus;g17/sync_input.c:186: implicit declaration ofdma_fence_get_status().
This is the hostedhost-testsfailure (asahi-m4→not ok 4 - test-fence-signalling.py). Fix: merge main in (merge commit, no force push) and give the harness's mockdma_fencethestatusfield and adma_fence_get_status()that the mergedasahi_g17_merge_fences()and main's new cases both build against.
Checked and fine:
- The constructor guard (
pending = count + 1) means no child can complete the barrier during setup. - Each installed callback holds one barrier reference, and a child that has already signalled puts its reference straight back.
- The last arrival either completes inline in the
asahi_g17_signal_fence()drain or, for a foreign signaller, throughirq_work, holding a reference. barrier_signaled()readspendingwith acquire after the errorcmpxchg, so a reported error is visible.- Children are dropped only after every callback has run, and
barrier_release()puts the rest. - The Rust side keeps the stack array within its 64 entries.
A question, not a blocker, which also bears on erikwb's chain-unwrap point: the old merge unwrapped dma_fence_chain inputs into their leaves, and dma_fence_array carries a leaf's later error. dma_fence_chain signals without copying its contained fence's error (dma_fence_chain_irq_work()), so a pending timeline point whose leaf fails now reaches the barrier with error 0. If anything reads the merged dependency's error, unwrapping containers before asahi_g17_barrier_create() keeps the old behaviour and also answers the deferred-work question.
Still owed after the fix: the >8-dependency before/after numbers, and exact-head J716c stress and M4 rows.
No textual conflicts. Signed-off-by: DjDeveloperr <hey@djdev.me>
main now reads fence status through asahi_g17_fence_status(), and its sync_input host harness models a fence with signaled and error fields instead of a status field. asahi_g17_merge_fences() still called dma_fence_get_status(), so test-fence-signalling.py no longer built on the merge with main. Use the same helper in the merge path. Move this branch's merge cases to the new mock fields. Give the barrier harness the locked-signal helpers that main's signal_with_error() uses. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Pushed fixes for today's change request to your branch (maintainer edits). These are normal commits on top of
Checked on pc at
Still blocking, and this one is a design call for you. Hosted Still needed after that: the >8-dependency before/after numbers, plus exact-head G17 stress rows on an M5 and a second G17 generation. Fork CI is approved at this head. |
Fixed in 909a84c (merge with main plus the harness and fence-status fix); see the comment above.
signal_draining_scopes() now completes struct asahi_g17_deferred nodes through their complete() hook instead of calling scope_complete() on a scope. The g17-output-fence-tests model still declared the old scope node and stub, so the extracted function no longer built. Declare the deferred node and drop the unused stub. No node is ever drained in these cases, as before. Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: REQUEST CHANGES at cff3e23
Failure: the hosted asahi KUnit run fails published_export_coalesce_key_tracks_epoch_qid_and_invalidation at drivers/gpu/drm/asahi/g17/fence.rs:765. It merges three distinct-context export fences and expects collect_coalesced() to return all three leaves. The current barrier is opaque to the existing unwrapping path, so the test loses the earlier per-export error dependencies. The head changes only the output-fence test model after the same runtime code. Preserve all three error dependency leaves through coalescing.
Checked: The new output-fence test model matches the deferred node API. Host tests pass and the KUnit coalescing failure remains.
Signed-off-by: DjDeveloperr <hey@djdev.me>
The dependency barrier hides its children from dma_fence_unwrap, so collect_coalesced() returned the barrier as one leaf and input_sources() lost the error dependency of each merged export. published_export_coalesce_key_tracks_epoch_qid_and_invalidation fails. Walk a barrier's children in the collector, as is done for a scope: asahi_g17_barrier_child() takes a reference under the fence lock while the barrier is pending. A signalled barrier drops its children, maybe during the walk, so read its status afterwards: if it succeeded every child signalled cleanly, and if it failed it is the failed leaf. For that to hold, a barrier has to see each leaf's error. A dma_fence_chain signals without its members' errors, so when an input is a chain or an array, merge the leaves inside it, as dma_fence_unwrap_merge() did. This also avoids one irq_work per container. Inputs without containers keep the single pass over borrowed pointers. Keep all failed inputs instead of the first one, and let a leaf past the first 16 coalesce with the preceding leaf of its context. Link the real merge and collector into the barrier host test, and extend the KUnit case to the late failure. Fixes: 22d1339 ("drm/asahi: g17: replace sorted dma_fence_array merge with inline-drained barrier") Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Pushed a fix for the KUnit failure to your branch (normal commits, no force-push). New head:
Ran (on the merge with
Still owed: at this head, a J714s G17 stress row and a J700 second-generation row, with before/after numbers for jobs with more than 8 dependencies. |
There was a problem hiding this comment.
Verdict: MERGE at 128c2ef
Checked: The exact-head fence-signalling suite passed with the production collector and barrier, including distinct export leaves, a late error, and callback/refcount controls. The hosted asahi KUnit job also passed on this head. Walking the barrier takes a child reference under its fence lock, and a barrier that finishes during the walk retains its negative status. Chain and array inputs contribute their leaves to the merge, preserving the earlier exports’ error dependencies.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 128c2ef87b7b26511f3a5b560c5a0538cb60e08e
Blockers: only the rows: J714s G17 stress and J700 as the second generation at this head, with before/after numbers for jobs with more than 8 dependencies. No code blocker.
Checked: Read the whole diff, not the summary. The callback, deferred and constructor references balance, and children are dropped only after the signal and outside the lock. asahi_g17_barrier_child() takes its reference under the fence lock while the barrier is pending, and reading the status after the walk covers a barrier that completes during it. Chain and array inputs, failed inputs, allocation failure and the 128-entry bounds unwind cleanly. No lock nests and nothing sleeps in the signal path.
Evidence and notes (none blocking)
Ran at this head: test-fence-signalling.py passes; --only asahi-m4 1/1; --only g17- 333/333; W=1 drivers/gpu/drm/asahi/ with CONFIG_KUNIT=y on arm64 builds with no C warnings. On UML with the real dma_fence core (2 CPUs, KASAN) the collector tests pass 3/3, with 37362 collections against concurrent signallers and errors. Hosted KUnit asahi: 575 run, 570 passed, 5 skipped, and published_export_coalesce_key_tracks_epoch_qid_and_invalidation passes. apple-build is green. Hosted host-tests is 1027/1028: apple/pmgr-inherited fails because of files that are identical on main, and #4025 fixes it.
- A merged fence has one production user,
job.rs:726, and goes only to the scheduler; input errors are read from each input. So the barrier walk in the collector andbarrier_set_deadline()run only in tests today. That is more code than the driver needs, but it is correct and keeps the merged fence readable. - The inline drain covers a barrier whose last child is a scope or a scoped output fence. Completion fences (
completion.rs:230) and scheduled fences signal plainly, so those barriers still complete throughbarrier_work(), oneirq_workeach, like the array did. The row should countbarrier_workagainstirq_dma_fence_array_workper merged job. - The barrier arms its callbacks in SUBMIT; the array armed them when the scheduler reached the job. Output fences therefore count as waited on (performance effort) earlier for queued jobs. The before/after numbers should show whether that matters.
barrier_arrived(b, child->error)after a faileddma_fence_add_callback()reads the error without the barrierasahi_g17_fence_status()has.dma_fence_arrayand the scope code do the same, and nothing reads the merged error in production, so this can be tidied with the next change here.
|
We carry this PR in our unified daily kernel across J716c (M5 Max, T6050), J713 (M4 Air, T8132), and J313 (M1 Air, T8103). Replacing the sorted Running cleanly on our unified daily across J716c, J713, and J313 (including Cyberpunk 2077 2.5 T2 at 60.14 FPS on J716c and Vulkan CTS smoke across all three Macs) with zero GPU faults or regressions. |
What: Replace
__dma_fence_unwrap_merge()/dma_fence_arrayinasahi_g17_merge_fences()with a single-pass O(N) stack-buffered merge and a compactasahi_g17_barrierfence that joinssync_scope's per-CPUactive_scopesinline drain pass instead of queueingirq_workon every barrier completion.Tested: J716c (MacBook Pro 16" M5 Max) host build + tests at
22d1339fe02a(make LLVM=1 ARCH=arm64 drivers/gpu/drm/asahi/clean with 0 warnings in touched files;tools/testing/selftests/drivers/gpu/asahi-m4/test-fence-signalling.pypassing including newasahi_g17_merge_fencestests;run-host-tests.py --only asahi-m41/1,--only cross-qid-direct11/11,--only capacity-fault1/1). Equivalent barrier path previously boot- and Vulkan-stress-tested on J716c (7.3.0-40).Risk: two-way · G17 Macs (M4/M5) when a submission has >8 scheduler dependencies (
MERGED_DEPENDENCIES).Not yet: Bare-metal boot and GPU stress run at this exact rebased
maincommit (22d1339fe02a).Design details and test evidence
asahi_g17_scope'sready/workfields intostruct asahi_g17_deferredsoasahi_g17_signal_fence()drains both ready scopes and ready barriers inline on the same CPU (respectingSCOPE_ATOMIC_BATCHand falling back toirq_workonly for foreign fence signalers).asahi_g17_barrier_create()indrivers/gpu/drm/asahi/g17/sync_scope.cusing a single flexible-array allocation, constructor guard,barrier_drop_children()child release after signalling, lock-safe batchedset_deadline, and negative error propagation.sync_input::merge()andasahi_g17_merge_fences()to use stack buffers up to 64 fences (heap-allocating only above 64), skip already-signalled non-error fences, deduplicate identical pointers and same-context fences (keeping the latest seqno) for small active sets (<= 16), preserve already-signalled error fences, and bypass barrier allocation when 0 or 1 fences remain.tools/testing/selftests/drivers/gpu/asahi-m4/test-fence-signalling.pyto test all-signalled stub return, same-context deduplication without barrier allocation, error-fence preservation alone and alongside unsignalled fences, and the >64 heap path.