Repository navigation
drm/asahi: g17: allow compute_direct() on mixed render/compute contexts - #3429
DjDeveloperr wants to merge 3 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 <[email protected]>
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 <[email protected]>
|
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 <[email protected]>
|
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. |
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: