Repository navigation
drm/asahi: g17: avoid publication contagion and host drains on timestamp overlap - #3139
Conversation
…amp overlap Commit 086a909 ("drm/asahi: overlap cross-engine commands with timestamped producers on G17") exposed ordered host publications on every overlapping timestamp-free command and forced timestamp-writing renders and NO_QUERY_ACCESS computes to wait on the host for any covered publication. Two effects serialized pipelined workloads that emit per-frame timestamps: 1. A timestamp-free Publication never cleared its pending state after all predecessors published cleanly, so every later command in the frame chained behind it and kept fences.publication populated even long after the original timestamped command completed. Any subsequent query-accessing compute or timestamp-writing render then added host completion waits on the entire frontier and drained both engines to zero in flight. 2. Timestamp-writing renders and NO_QUERY_ACCESS computes perform all host-ordered timestamp writes inside Publication::publish() once a chained render's firmware fragment-end timestamp window is disabled, so stalling them on the host behind covered publications was unnecessary. Fix both while preserving ordered timestamp publication and deferred producer error propagation: - Track has_outputs and an atomic pending flag on Publication. When a timestamp-free Publication's predecessors all publish Ok(()), clear pending and immediately release any downstream Publication successors without waiting for its own GPU retirement. Publications that fail before settling (or carry outputs) keep pending set so deferred errors continue to propagate; a settled timestamp-free publication whose own GPU work fails later relies on retirement-time producer checks and VM failure state, matching commands without a publication. - Add Destinations::disable_window() and disable the firmware fragment-end timestamp window on any render chained behind pending host predecessors, so its timestamps are written strictly on the host in publication order. - Restrict host completion waits in EnqueueOrdering::build() to query-accessing compute commands, while still adding already-signalled error fences (status < 0) on both same-engine paths when a covered entry failed between frontier pruning and ordering. Renders and NO_QUERY_ACCESS computes overlap pending publications in firmware and chain ordered publication. - Check Publication::is_pending() in has_pending_publication() and input_sources() so settled timestamp-free commands do not block cross-queue firmware barriers. - Extend asahi_g17_timestamp_window, asahi_g17_publication_order, and asahi_g17_cross_engine_timestamps KUnit tests to cover window disabling, clean upstream settlement, settled-then-failed propagation, chained timestamped overlap in both directions, and query-access host waits. Signed-off-by: Erik Bourget <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 8677cbde1ddc
Blockers: none
Checked: Full G17 publication settlement, firmware timestamp window disablement, cross-engine and same-engine ordering logic, KUnit tests, J716c verification evidence, and live CI status.
Evidence
drivers/gpu/drm/asahi/g17/completion.rs: replacesDestinations::renderwithallow_windowand invokesdisable_window()inCompletion::new()wheneverhost_predecessorsis true, keepinghandedfalse so renders chained behind pending host predecessors cannot race deferred writes or bypass inherited errors via the firmware fragment-end timestamp window.drivers/gpu/drm/asahi/g17/completion/publication.rs: trackshas_outputs, atomicpending(Release/Acquire), andupstream_releasedunderstate. Clearspendingon successfulpublish()or when a timestamp-free (!has_outputs) publication has all predecessors complete cleanly (remaining == 0, nopredecessor_error), releasing downstream successors without signalling its own fence early; failed publications remainpendingso deferred errors still propagate, and late successors after a subsequent own-GPU failure still observestate.published.drivers/gpu/drm/asahi/g17/queue/mod.rs: filtershas_pending_publication(),input_sources(), andEnqueueOrdering::build()bypending_publication(), narrows host completion waits toEngine::Compute && query_access(retaining already-signalledstatus < 0same-engine error fences that failed afterprune_frontier()), and chains ordered publication for renders andNO_QUERY_ACCESScomputes.- Live CI at
8677cbde1ddc: 19/19 checks passed (0 active, 0 failed), includingreadinessand KUnitasahitests, with exact-head J716c M5 Max hardware verification and Vulkan CTSquery_pool/synchronization*pass rows in the PR description.
|
8677cbd J616s (MacBook Pro 16" M4 Pro, T6040,
|
What: Stop timestamp-free G17
Publicationchains from staying permanently pending after their timestamped ancestors publish cleanly, and let timestamp-writing renders (with their firmware fragment-end timestamp window disabled when chained) andNO_QUERY_ACCESScomputes overlap pending publications in firmware instead of draining both engines to zero on the host.Tested: J716c M5 Max (
ewb-m5) on identical runtime code (7.3.0-ewb311+vs cleanmain42d693c46cb97.3.0-ewb308+, same.config): Cyberpunk 2077 T2 2560x1600 with Borealis rose from45.46to49.90 FPS(+9.78%, compute utilization81% -> 96%) on driver8f88e781and45.00to49.24 FPS(+9.42%,80% -> 96%) on driverb044001f; Vulkan CTSquery_pool.*andsynchronization*passed27,984cases with0failures and0GPU errors or recoveries (aurora-peripherals.servicefailed as on baseline). At head8677cbde1ddc: arm64 QEMU KUnitasahi_*388passed /3skipped /0failed, G17 host tests93/93passed,checkpatch.pl0errors /0warnings.Risk: two-way door · G17 queues (M4, M4 Pro, M4 Max, M5, M5 Pro, M5 Max, M5 Ultra)
Not yet: M4 / M4 Pro / M4 Max / M5 Pro / M5 Ultra hardware runs (no local G17 hardware beyond J716c;
ewb-m4J713 uses G16G).Details
Commit
086a909dc8c6(drm/asahi: overlap cross-engine commands with timestamped producers on G17) exposedPublicationon every overlapping timestamp-free command (job.rs) and forced host completion waits for timestamp-writing renders andNO_QUERY_ACCESScomputes behind any covered publication.On workloads that emit per-frame render timestamps (such as Cyberpunk 2077 under vkd3d-proton and Borealis), ftrace (
asahi_g17_*) showed two serializing effects that drained both engines toinflight_R=0, inflight_C=0over 100 times per second:Publicationchains: A timestamp-freePublicationnever cleared its pending state after all predecessors publishedOk(()). Every subsequent overlapping command in the frame chained behind it and keptfences.publicationpopulated long after the original timestamped command completed, disablingfirmware_source/input_sources()cross-queue barriers and turning every subsequentquery_accesscompute or timestamped render into a full-frontier host drain.Destinations::disable_window()), both renders andNO_QUERY_ACCESScomputes perform all timestamp writes on the host inside orderedPublication::publish(). Only query-accessing compute commands (query_access == true, e.g. query resets/copies that touch query memory on the GPU) need host completion waits.Changes:
drivers/gpu/drm/asahi/g17/completion/publication.rs: trackhas_outputsand an atomicpendingflag onPublication. When a timestamp-freePublication's predecessors all publishOk(())before its own GPU retirement, clearpending(Release) and immediately release downstreamPublicationsuccessors under the samestatelock. Publications that fail before settling (or carry outputs) keeppendingset so deferred errors continue to propagate; a settled timestamp-free publication whose own GPU work fails later relies on retirement-time producer checks and VM failure state, matching commands without a publication.drivers/gpu/drm/asahi/g17/completion.rs: addDestinations::disable_window()and invoke it inCompletion::new()wheneverhost_predecessorsis true, keepinghandedfalse so all timestamps are written on the host in publication order.drivers/gpu/drm/asahi/g17/queue/mod.rs: filterhas_pending_publication(),input_sources(), andEnqueueOrdering::build()byPublication::is_pending(), restrict host completion waits to query-accessing compute commands (plus already-signalledstatus < 0same-engine entries that failed afterprune_frontier()), and chain ordered publication for renders andNO_QUERY_ACCESScomputes.Evidence
Cyberpunk 2077 T2 (2560x1600, J716c M5 Max
ewb-m5, same.config, default kernel command line, fans max,performancegovernor)main42d693c46cb9(7.3.0-ewb308+)8f88e7817.3.0-ewb311+, run 1)8f88e7817.3.0-ewb311+, run 2)8f88e781main42d693c46cb9(7.3.0-ewb308+)b044001f7.3.0-ewb311+, run 1)b044001f7.3.0-ewb311+, run 2)b044001fVulkan CTS on J716c M5 Max (
7.3.0-ewb311+, Borealisb044001f)dEQP-VK.query_pool.*: 18,230 Pass / 40 NotSupported / 0 FaildEQP-VK.synchronization.smoke.*: 11 Pass / 0 FaildEQP-VK.synchronization.op.single_queue.binary_semaphore.*: 1,422 Pass / 1 NotSupported / 0 FaildEQP-VK.synchronization.op.single_queue.fence.*: 1,422 Pass / 1 NotSupported / 0 FaildEQP-VK.synchronization.op.multi_queue.binary_semaphore.*: 4,266 Pass / 3 NotSupported / 0 FaildEQP-VK.synchronization2.op.single_queue.binary_semaphore.*: 2,633 Pass / 1 NotSupported / 0 FailUnit tests & style at head
8677cbde1ddcasahi_*): 391 ran, 388 passed, 3 skipped, 0 failed (includingasahi_g17_timestamp_window,asahi_g17_publication_order, andasahi_g17_cross_engine_timestamps)tools/asahi/run-host-tests.py --only g17: 93/93 passedscripts/checkpatch.pl --no-tree -g HEAD: 0 errors, 0 warnings