Skip to content

drm/asahi: g17: replace sorted dma_fence_array merge with inline-drained barrier - #3324

Open
oreater wants to merge 7 commits into
aurora-silicon:mainfrom
oreater:pr/g17-inline-dep-barrier
Open

oreater wants to merge 7 commits into
aurora-silicon:mainfrom
oreater:pr/g17-inline-dep-barrier

Conversation

@oreater

@oreater oreater commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

What: Replace __dma_fence_unwrap_merge() / dma_fence_array in asahi_g17_merge_fences() with a single-pass O(N) stack-buffered merge and a compact asahi_g17_barrier fence that joins sync_scope's per-CPU active_scopes inline drain pass instead of queueing irq_work on 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.py passing including new asahi_g17_merge_fences tests; run-host-tests.py --only asahi-m4 1/1, --only cross-qid-direct 11/11, --only capacity-fault 1/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 main commit (22d1339fe02a).

Design details and test evidence
  • Generalizes asahi_g17_scope's ready / work fields into struct asahi_g17_deferred so asahi_g17_signal_fence() drains both ready scopes and ready barriers inline on the same CPU (respecting SCOPE_ATOMIC_BATCH and falling back to irq_work only for foreign fence signalers).
  • Adds asahi_g17_barrier_create() in drivers/gpu/drm/asahi/g17/sync_scope.c using a single flexible-array allocation, constructor guard, barrier_drop_children() child release after signalling, lock-safe batched set_deadline, and negative error propagation.
  • Updates sync_input::merge() and asahi_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.
  • Extends tools/testing/selftests/drivers/gpu/asahi-m4/test-fence-signalling.py to test all-signalled stub return, same-context deduplication without barrier allocation, error-fence preservation alone and alongside unsignalled fences, and the >64 heap path.

…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>
@oreater
oreater marked this pull request as ready for review November 26, 2026 22:34
@oreater
oreater requested review from a team and DjDeveloperr as code owners November 26, 2026 22:34
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 128c2ef8: not ready yet

Check Detail
CI at head no failing: host-tests
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 128c2ef8, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · G17 Macs (M4/M5) when a submission has >8 scheduler dependencies (MERGEDDEPENDENCIES).

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@RyanTheTide

Copy link
Copy Markdown
Contributor

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 erikwb 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.

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.

@erikwb

erikwb commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

J716c (16-inch M5 Max) at 22d1339fe02a: boots, and Vulkan synchronization, memory and compute CTS show no regression against the same kernel without this PR.

Evidence

Built into batched kernel 7.3.0-ewb350+ (main 9d7918bc6316 plus open #3389 #3411 #3415 #3390 #3392 #3330 #3443 #3153 #3324 #3325 #3406 #3429), which contains this head unchanged. Control 7.3.0-ewb355+ is the same tree with the #3324 merge reverted. Borealis aurora-wip 437b0b52151, deqp-runner with 4 jobs. One-shot trial boots on the default command line plus watchdog.open_timeout=120 (a recovery watchdog for test boots only).

CTS with #3324 (ewb350) without (ewb355)
synchronization mixed list (5354 cases), run 1 4423 pass, 17 fail, 149 flaky 4426 pass, 163 flaky
same list, run 2 4337 pass, 252 flaky 4398 pass, 39 fail, 152 flaky
synchronization2.op.multi_queue.timeline_semaphore alone (4269) 4266 pass, 3 skip 4266 pass, 3 skip
memory.mapping (4466) 4466 pass not run
compute sample (1250) 490 pass, 760 skip not run
kernel errors during the runs none from the GPU driver; one burst of apple_pmp 284500000.pmp: RTKit: refused auxiliary buffer request at about 30 min uptime none

Every fail and flaky case on both kernels is in synchronization2.op.multi_queue.timeline_semaphore while it runs beside the rest of the synchronization list; run on its own the family passes on both.

… 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>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks @oreater. I pushed 06a530f on top of your commit (test-only, no driver change) to answer the App finding. test-fence-signalling.py now builds the unchanged production g17/sync_scope.c against a single-CPU dma_fence/llist/irq_work model (ASan/UBSan on) and runs the real asahi_g17_barrier_create() path. Cases: children already signalled at registration, the last child signalled in the asahi_g17_signal_fence() drain and by a foreign signaler (irq_work fallback), negative child status, a barrier waiting on a barrier, and more ready barriers than SCOPE_ATOMIC_BATCH. Each case checks one completion, balanced child refs and the barrier release.
Tests: the whole script passes. Removing the callback's put, the inline drain, error propagation, the child release or the constructor guard each makes it fail.
Still open: App re-review at the new head, CI approval, the before/after numbers for the >8-dependency case (including the chain-leaf deferred-work question from the other review), and exact-head J716c stress + M4 rows.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) ci-failing A check failed at the PR head (bot) labels Nov 30, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 DjDeveloperr 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.

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_fence has no member named status;
  • g17/sync_input.c:186: implicit declaration of dma_fence_get_status().
    This is the hosted host-tests failure (asahi-m4 → not ok 4 - test-fence-signalling.py). Fix: merge main in (merge commit, no force push) and give the harness's mock dma_fence the status field and a dma_fence_get_status() that the merged asahi_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, through irq_work, holding a reference.
  • barrier_signaled() reads pending with acquire after the error cmpxchg, 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.

@github-actions github-actions Bot added the changes-requested A reviewer requested changes (bot) label Dec 2, 2026
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>
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 2, 2026
@DjDeveloperr

DjDeveloperr commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Pushed fixes for today's change request to your branch (maintainer edits). These are normal commits on top of 06a530fe1cfb, with no force-push.

  • 604d39c20cf4 merges main (1b95b711bbc2). It merged with no textual conflicts.
  • 909a84cb1126 handles main's switch from dma_fence_get_status() to its lock-free asahi_g17_fence_status(). asahi_g17_merge_fences() now uses that helper too, which returns the same 0/1/-errno. Your merge cases use main's signaled/error mock fields, and the barrier harness gets the locked-signal helpers that main's signal_with_error() calls.
  • cff3e23649ce updates main's g17-output-fence-tests model to declare struct asahi_g17_deferred in place of the old scope node, because signal_draining_scopes() now completes deferred nodes. The hosted run at 909a84cb caught this one.

Checked on pc at cff3e23649ce:

  • test-fence-signalling.py passes, and the full asahi-m4 host suite passes 26/26.
  • run-host-tests.py --only g17- passes 329/329.
  • W=1 g17/sync_input.o sync_scope.o builds with no warnings.

Still blocking, and this one is a design call for you. Hosted KUnit asahi at 909a84cb fails asahi_g17_aggregate_promise → published_export_coalesce_key_tracks_epoch_qid_and_invalidation (g17/fence.rs:765, leaves.len() == 3 is false). Main now relies on collect_coalesced(merge(...)) returning every distinct-context leaf, so that Backend::input_sources() keeps the error dependency of each earlier export. A merged dma_fence_array can be unwrapped. The new barrier hides its children, so input_sources() would lose those error sources. That is the chain-unwrap question from the review. Either let collect_coalesced() walk a barrier's children, or unwrap containers before asahi_g17_barrier_create(). This needs your choice, so I've left it.

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.

@DjDeveloperr
DjDeveloperr dismissed their stale review December 2, 2026 20:17

Fixed in 909a84c (merge with main plus the harness and fence-status fix); see the comment above.

@github-actions github-actions Bot removed the changes-requested A reviewer requested changes (bot) label Dec 2, 2026
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>
@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 2, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Failing asahi KUnit job

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>
@DjDeveloperr

DjDeveloperr commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Pushed a fix for the KUnit failure to your branch (normal commits, no force-push). New head: 128c2ef87b7b.

  • 6e608f2f38dd merges main (cebaa8a69fea), no conflicts.
  • 128c2ef87b7b: the collector now walks a barrier's children, as it does 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, so its status is read after the walk: clean means every child signalled cleanly, failed means the barrier is reported as the failed leaf.
  • For that to hold, the barrier must see each leaf's error, and a dma_fence_chain signals without its members' errors. So chain and array inputs are merged by their leaves, which also answers the chain-unwrap question (no irq_work per container). Inputs without containers keep your single pass. All failed inputs are kept, not only the first.

Ran (on the merge with 5fe340acef00; nothing under drivers/gpu/drm/asahi, drivers/dma-buf or the tests below changed since, except two unrelated tools/asahi scripts):

  • test-fence-signalling.py passes. It now links the real merge and collector into the barrier test. 13 mutations of the barrier, merge and collector all fail it (one by looping until a 60 s timeout).
  • Container host tests: --only asahi-m4 1/1, --only g17- 333/333.
  • W=1 drivers/gpu/drm/asahi/ with CONFIG_KUNIT=y: no warnings in the touched C; the extended KUnit case compiles. It runs in the hosted job at this head.
  • Local KUnit on UML with the real dma_fence core (2 CPUs, KASAN): the steps of the failing case give 1 leaf instead of 3 at cff3e236 and pass here. 6000 rounds of collecting against concurrent signallers and errors pass. 4/4 mutations fail it.
  • UML timing of merge plus arming, interrupts off, 120 inputs: main 25.3 µs, cff3e236 11.8 µs, this head 12.0 µs. With interrupts on, UML's slow irq-restore dominates, so only hardware numbers count.
  • checkpatch --strict: clean apart from not finding the Fixes: commit outside the PR branch.

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.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 3, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 3, 2026

@DjDeveloperr DjDeveloperr 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.

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.

  1. 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 and barrier_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.
  2. 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 through barrier_work(), one irq_work each, like the array did. The row should count barrier_work against irq_dma_fence_array_work per merged job.
  3. 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.
  4. barrier_arrived(b, child->error) after a failed dma_fence_add_callback() reads the error without the barrier asahi_g17_fence_status() has. dma_fence_array and the scope code do the same, and nothing reads the merged error in production, so this can be tidied with the next change here.

@RyanTheTide RyanTheTide closed this Dec 3, 2026
@RyanTheTide RyanTheTide reopened this Dec 3, 2026
@erikwb

erikwb commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

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 dma_fence_array merge with an inline-drained barrier cuts per-submit host allocation and sorting overhead in the G17 submission path on busy Vulkan render/compute workloads.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants