Repository navigation
drm/asahi: g17: allow compute_direct() on mixed render/compute contexts - #3429
DjDeveloperr wants to merge 5 commits into
Conversation
Backend::compute_direct() currently bails out unconditionally whenever self.context.render_seen() is true, forcing 100% of compute commands on mixed render/compute contexts (such as games) onto the device-mutex slow path where compute descriptor encoding, cache maintenance, and doorbell rings hold self.shared.state.lock(). Under contention with periodic event worker passes or concurrent render_direct() loans, compute submissions serialize behind the device mutex. Track an RAII atomic count of active (published and unretired) render entries on Context (incremented when Pair::publish() pushes an Active entry and decremented in Active::drop()). Remove the unconditional render_seen() bailout from compute_direct() and resolve any active render prefix as follows: - When wait_through[0] is none or Context::render_active() is zero, skip self.shared.state.lock() completely. - When renders are active, acquire self.shared.state.lock() only long enough to resolve firmware.queues.render_prefix() (checking lease.is_current(), !firmware.recovery.pending(), and !firmware.queues.render.replay_parked()), merge the resulting frontier into direct_frontier, and release the device mutex before locking the compute cell and publishing. Add compiled host contract tests and mutations in tools/asahi/g17-direct-compute-render-prefix-tests.py. Signed-off-by: DjDeveloperr <hey@djdev.me>
Keep Context::render_active non-zero while renders are parked in Pair::replay after GPU recovery by wrapping parked packets in a ParkedReplay RAII guard constructed before popping Active. This prevents compute_direct() from observing render_active() == 0 and skipping the replay_parked()/render_prefix() check once publication reopens. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J700 (MacBook Neo, Apple A18 Pro
|
satchlj
left a comment
There was a problem hiding this comment.
Reviewed 65830e554016 (both commits: 0a72e578d4e6 + 65830e554016).
Code audit:
Context::render_activeusesAcquire/AcqRel, is incremented inPair::publish()before pushingActive, decremented inActive::drop(), and preserved seamlessly acrossactive -> replay -> republish/fail/dropviaParkedReplay::new()beforeself.active.pop()(sorender_active()never dips to 0 while a parked replay exists).- In
Backend::compute_direct(), whenrender_seen() && wait_through[0].is_some() && render_active() != 0,firmware.queues.render_prefix()runs underself.shared.state.lock(), covering bothentry.pairandentry.borrowed_dependencies(fromrender_direct()loans) and callingnote_firmware_consumer()on live render entries under the lock soreplay_abandoned()cannot subsequently park them out from under the compute kick. - Because
resolve_direct_sources()only resolves compute QIDs, mergingrender_frontierviadirect_frontier.insert(0, *dep)cannot collide on QID with compute source dependencies. - Minor non-blocking note: under
self.shared.state.lock()incompute_direct(), checkingsuper::recovery::Memory::recovery_state(&firmware.init)alongsidefirmware.recovery.pending()(matching the fallback path incompute_packet()) would also catch a firmware recovery initiated between the earlier unlocked check and acquiringstate.lock().
Tested on Apple M5 Max (J775c, G17C B1) at exact head 65830e554016:
python3 tools/asahi/run-host-tests.py --only g17-direct-compute-render-prefix-tests: 6/6 passed (base contract + all 5 mutations).
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Resolve the Pair::publish() conflict in g17/queue/render.rs: keep both the render_active increment from this branch and main's packet.note_ordinal(published), which are independent. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
|
I merged current |
There was a problem hiding this comment.
The merge keeps publication ordinal accounting and acquires the render-active count immediately before the Active entry takes ownership. Active and ParkedReplay both release the count on drop. Please reconcile the PR description with the remaining render_seen predicate and keep hosted and integrated runtime evidence as merge gates.
|
@DjDeveloperr code-owner notice: the review app approved this forward-merged head. I'll merge it under the 6-point rule once CI is green at this head, no earlier than 1 h from now. Say hold here if you object. |
main dropped compute_direct()'s G17P bail-out on input sources (they now resolve through native waits), and this branch dropped the unconditional render_seen() bail-out, so neither remains. The direct path keeps main's four-part source resolution, with the frontier mutable for this branch's render prefix. The bail-on-render-seen mutation of g17-direct-compute-render-prefix-tests now targets the merged condition and asserts that it applied. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merged Main's new Still owed before merge: an approval from someone other than us (RyanTheTide is eligible again now), and SLC-on rows at this head on J714s and J700. G17P sources now take the direct path too, so the J700 row matters here. |
The render pair now parks replays as ParkedReplay, which holds the context's render_active count, rather than as a bare Arc<Packet>. The g17-render-owed-stamp-tests harness still declared the replay tracker with the old type, so the extracted replay_contains() and park path no longer built and every case of the test failed. Declare the tracker as Tracker<ParkedReplay>, extract ParkedReplay and its impls from render.rs, and give the mock Context the render-active counters. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
The red Pushed On pc, Still needed before merge: an independent review at this head and exact-head rows on J714s (M5 Pro) and J700 (Neo). The J700 row in this thread is at Full host suite, |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed the whole PR at 0663be9696f1, merged cleanly into main 3bee58a9c408. Main has moved to b47fc630 since, but none of its new commits touch this PR's files.
- The count. The only place an
Activeis built isPair::publish(), right afterinc_render_active(). Every way it goes away (retire, cancel, quarantine, teardown, a failed push) decrements throughDrop.ParkedReplaytakes its count before theActiveis popped.replay_render_front()publishes the newActivebeforefinish_replay()drops theParkedReplay. So the count never reaches 0 while a render of the context is active or parked. - Skipping the lock at 0 is safe.
render_prefix()only collectsActiveentries and the loan snapshots of them. A compute's render predecessors are already published when it runs, becauseEnqueueOrderingmakes it wait on their scheduled fence. With no active or parked render, the prefix has nothing to add. With one, the locked block resolves the same prefix ascompute_packet(). - Harness fix
0663be96. It's test-only, and none of the test's assertions changed. It only lets the fixture compile the new types: the tracker type, the extractedParkedReplayitems, and no-opinc/dec_render_active()on the mockContext. This harness never read the count. The render-prefix harness is the one that checks it. Every mutation still asserts its target appears exactly once, so a pass means each one applied and was caught. - Checked on pc at the merge:
W=1LLVM arm64 asahi module: no new warnings against main.run-host-tests.py --only g17-in the CI container: 339/339 (main is 333/333, plus this PR's 6).- checkpatch
--strict:0663be96is clean.0a72e578only hasFILE_PATH_CHANGESfor the new tools test, which is fine.65830e55has one unwrapped commit-message line, a nit not worth a history rewrite.
- Non-blocking: as satchlj noted, the locked block could also check
recovery_state(&firmware.init), ascompute_packet()does.
Verdict: MERGE at 0663be9
Before merge: hosted CI green at this head, exact-head rows on J714s and J700, and an approval from someone other than the author. The J700 row in this thread is at 65830e55, before two main merges, and G17P input sources now take the direct path too.
|
We carry this PR in our unified daily kernel across J716c (M5 Max, T6050), J713 (M4 Air, T8132), and J313 (M1 Air, T8103). Allowing 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. |
RyanTheTide
left a comment
There was a problem hiding this comment.
The revised harness extracts the production ParkedReplay type and holds render_active across the same lifetime as the queue. This fixes the owed-stamp fixture’s stale type without changing production behavior from the earlier reviewed revision. The earlier hardware rows cover the direct compute change.
What:
Let
Backend::compute_direct()publish compute commands on mixed render/compute contexts without holding the device mutex across descriptor encoding, cache maintenance and the doorbell.context.rs,queue/render.rs:Context::render_active(AtomicU32) counts live render entries. It goes up just beforePair::publish()pushes anActiveentry and down inDrop for Active, which covers retirement, cancellation, quarantine and teardown.Pair::replayafter a GPU recovery keep the count up through aParkedReplayguard built beforeActiveis popped, socompute_direct()never sees zero and skips thereplay_parked()/render_prefix()check once publication reopens.runtime.rs: the unconditionalrender_seen()bailout is gone.check_firmware_producers()runs first. The device lock is skipped whenwait_through[0]is empty or no render is active; otherwise it is held only to checklease.is_current(), no pending recovery and no parked replay, and to resolverender_prefix(), then dropped beforetarget_cellis locked and the command published.tools/asahi/g17-direct-compute-render-prefix-tests.py(5 contract mutations, including dropping the count on park). Stack:Backend::compute_direct3,408 B,render_prefix_at768 B.Tested:
7.3.0-m5-s10cand= main 9e38a27 + this branch (65830e5) + perf/g17-publication-direct-lazy (8442bb0), driver code carried unchanged (only the host-test list intools/asahi/run-host-tests.pyneeded a merge),origin/mainDTB, Mesa kit inst-A. VK CTS 674/681 passed, 7 not supported, 0 failed (occlusion_query copy 152/159, concurrent_queries 2/2, multiview queries 16/16, pipeline timestamp basic_graphics 80/80, synchronization smoke 12/12, synchronization2*read_image_compute*412/412); gpubench-vkcompute.cull_mdiCRC 07f6c861 valid (d1 1041.7 us, d2 886.5 us per submit); chainbench_diag clean; GPU online, 0 crashed, 0 quarantined, no GPU faults or WARNs.7.3.0-m5-pr67that carries the first commit 0a72e57 unchanged (same patch-id), stacked with drm/asahi: g17: expand single-pair M5 render depth to 64 #3411 and drm/asahi: g17: batch report-ring drains and skip redundant render re-observe #3428,origin/mainDTB: VK CTS 594/594 passed, 0 failed; gpubench-vkcompute.cull_mdiCRC valid; GTA V Enhanced 3024x1964 Very High TAA: GPU busy 97.658% -> 97.765%, P4 57.92 -> 58.03 FPS; 0 GPU faults, WARNs or errors.g17-*passed;checkpatch.pl --strict0 errors, 0 warnings, 0 checks.Risk: two-way · G17 Macs (M5 Pro, Neo)
Not yet: