Repository navigation
drm/asahi: g16: poll cadence fixes and publication hold causes - #3074
Conversation
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Verdict at Blockers:
Checked: the 4 commits against the base; skipped idle housekeeping is owed and runs at the end of the 1 ms cadence, and a recovery or receipt fault still runs the full pass at once; the hold-cause counters only add accounting; no Apple material in code or commit messages; no chip or board gates; no new parameters; only bounded waits; commits carry human authors and Signed-off-by, no AI attribution; CI does not run on a stacked base and will run once this PR targets |
…ce busy horizons Keep single-queue barrier-free compute streams affine to their active CDM pipe in choose_compute_pipe() and remove pipe_fold_cap from publish_prefix_body() so deep single-queue horizons fold into one workqueue prefix without bouncing between pipes or injecting cross-pipe c2c barriers, while independent queues and cross-VM compute still balance across both CDM pipes. Add busy-state same-queue horizon micro-coalescing (COALESCE_MAX_CMDS = 6, COALESCE_WINDOW_US = 18): only when a single queue already has >= 2 active commands in flight and every pending job belongs to that same queue and VM as a foldable barrier-free compute or non-InitBM render horizon, submit_locked() defers publish_checked() behind an hrtimer (rearm_after()) for up to 18 us so back-to-back SUBMIT ioctls fold into one multi-command flight. Shallow d=1/d=2 pipelines, barriered streams, RT/SCS work, and multi-queue/cross-VM arrivals bypass coalescing immediately with zero added latency, and any flight retirement or deadline expiry flushes the held batch immediately. Signed-off-by: Diljit Singh <[email protected]>
…-ordered async pass pre-scrub Light single-layer render passes (tilemap_bytes <= 64 KiB) do not saturate M4 firmware's TA/scene pipeline at 4 passes, while deep single-queue render bursts (d=64) hit three avoidable CPU/pacing cliffs: 1) TA_WAVE_PASSES=4 caps light render waves and limits render busy micro-coalescing to 2 passes; 2) publish_checked() re-read WC fw_stamp and rescanned pending[..i] for every blocked follower of the head queue; and 3) stage_displaced_pass_scrubs() scanned slots 0..47 instead of starting at pass_cursor, leaving upcoming slots dirty when >8 displaced slots were pending. Precompute RenderCommand::heavy_ta on admission, raise the light single- layer TA wave cap to TA_WAVE_PASSES_LIGHT=8 while keeping conservative TA_WAVE_PASSES=4 whenever any active or pending pass is heavy, adapt ta_wave_ready() hysteresis to cap - 2, and raise SCHEDULER_CREDITS to 64. Hoist ta_pending_passes() once per publish_checked() pass and skip blocked same-queue followers in O(1), and scan stage_displaced_pass_scrubs() cursor-ordered from pass_cursor while preserving pick_pass_in_for's same_dirty > unowned preference. Signed-off-by: Diljit Singh <[email protected]>
Unconditional single-queue 1-pipe compute affinity helped light compute streams fold onto one CDM workqueue, but serialized heavy compute streams (bandwidth/fill/overlap passes >= 200 us per command) onto a single CDM pipe and left multi-queue overlap workloads susceptible to the 18 us busy-coalesce window when another queue already had an active flight. Track a lock-free per-queue EWMA of retired hardware CDM GPU execution duration in microseconds (from the existing single- and multi-command timestamp reads in stat_retire, without extra WC reads) and add a cold-start probe for a sole single-command compute flight exceeding 180 us before its first retirement: - Light single-queue compute (< 200 us) keeps 1-pipe affinity, unbounded same-pipe horizon folding, and busy coalescing. - Heavy compute (>= 200 us EWMA or sole inflight >= 180 us) bypasses busy coalescing, fans out across both CDM pipes, and caps barrier-free folding to keep both pipes balanced. - Busy coalescing also bypasses immediately whenever any active flight belongs to a different queue so multi-queue render and async compute/render overlap see zero micro-coalesce delay. Extend the publication host selftests to cover adaptive heavy detection, EWMA transitions, pipe balancing, and cross-queue/heavy busy-coalesce bypasses. Signed-off-by: Diljit Singh <[email protected]>
publish_checked() marks a ready job that it could not publish for want of TA wave headroom (ta_wave_wait) or pass and flight headroom (slot_wait). A poll pass that sees either flag repolls after repoll_us (8 us by default), so the job publishes as soon as TA progress or a retirement makes room. A SUBMIT that publishes inline and leaves the same state behind did not do this. It rearmed the poll timer with rearm_us(false), which is half the flight duration EWMA clamped to resnap_us, so 100 us for renders longer than 200 us. Unless a stage event arrived first, the job waited that long after the room appeared. This is the case for the later passes of a multi-pass render that does not fit in one TA wave. Treat the two flags in submit_locked() as poll_step() does: rearm soon when the engine is not frozen and a job is still pending. Signed-off-by: Diljit Singh <[email protected]>
poll_step() ran the full idle housekeeping on every pass that started with nothing in flight: Session::check() (an ASC control read, a powered SGX pstate read and a walk of the adopted UAT bindings), Objects::health(), service_power() and a drain of every receive ring, including the nine log sub-rings and ktrace. A pass with work in flight holds the same checks to their cadence, 5 ms while active. Shallow back-to-back submissions reach the idle state after every completion, and idle_resnap() keeps a short poll timer armed across that gap. The timer pass then repeated all of these checks under the device lock, between one completion and the next SUBMIT, which waits on the same lock. Inside the 1 ms idle cadence, drain only the event and statistics rings, which carry completion and recovery notifications, then check for a pending recovery. A recovery or a receipt fault still runs the full pass at once. The skipped housekeeping is owed: run_poll() queues the backup poll for the end of the cadence, and the owed state clears when any full or periodic housekeeping runs. The backup poll may replace a later idle power poll; that pass calls service_power() and arms the power poll again. Signed-off-by: Diljit Singh <[email protected]>
hold[0] counts publication passes that stopped at a ready job behind in-flight work, but it lumps together a job that must wait for an empty engine and one that waits for headroom. The two are released by different events, so the counter cannot say which one a stalled multi-pass render is waiting for. Count each such hold once more by its cause, and print the split as a hold_causes line of aurora-g16/stats: - drain_failed: the VM failed, or a flight is doomed or recovery-suspect; - drain_initbm: a cold InitBM render is in flight; - drain_cross: render and compute of different VMs; - drain_pb: no warm PB/UMA allocator slot of the VM can take the render; - ta_wave: the TA wave window is full; - slot: flight, render pass or compute unit headroom; - dependency: the job's dependency check failed; - other: any other refusal behind in-flight work. The cause is evaluated only when a pass holds. The PB pipelining test that needs_engine_drain() and can_queue_behind_with_ta() each spelled out moves to render_can_pipeline(), which the classification uses too. hold[0] keeps its meaning. Signed-off-by: Diljit Singh <[email protected]>
When publish_checked() stops at a ready job, the poll repolls after repoll_us only if it set slot_wait or ta_wave_wait. A job held for any other reason waits for the next retirement poll. That is an EP 0x20 event, or the poll timer: rearm_us(false) is half the flight-duration EWMA clamped to resnap_us, so 100 us for renders longer than 200 us. An event for a stage that is not terminal is also not allowed to spin the receipt tail. A multi-pass render held this way behind its own earlier passes can therefore be published up to resnap_us after the retirement that frees it, with the GPU idle in between. Mark such holds held_wait when every flight belongs to the held job's VM and the cause is not a failure, a cross-VM overlap or a failed dependency. The job's own VM's retirements are then what releases it. held_wait is treated like the two existing flags: poll_step() repolls at repoll_us and keeps stage events eligible for the receipt tail, submit_locked() rearms soon, and busy coalescing does not hold behind it. publish_checked() clears it with them. A hold behind another VM's work keeps the existing cadence, so a long cross-VM drain does not repoll every few microseconds. Signed-off-by: Diljit Singh <[email protected]>
b84cfd5 to
8495c00
Compare
9f1dc2f to
6c6dac6
Compare
What: Poll and publication cadence for the g16 (M4) backend.
repoll_us, not up toresnap_us.aurora-g16/statssplitshold[0]by cause.repoll_us.Stacked on #3047 (
djdev/g16-perf-wave16).Tested:
9f1dc2f:checkpatch.pl --strict0/0/0 on each commit;git diff --checkclean.Risk: two-way · M4 (J773g / G16G)
Not yet:
Details
Commits
drm/asahi: g16: repoll soon when SUBMIT leaves a paced job waitingsubmit_locked()now treatsslot_wait/ta_wave_wait, with a job pending and the enginenot frozen, as a reason to rearm soon. This is what
poll_step()already does for the samestate.
rearm_us(false), which is100 µs for flights longer than 200 µs.
drm/asahi: g16: keep idle poll passes on the housekeeping cadenceevent and statistics rings and checks for a pending recovery.
Session::check(),Objects::health(),service_power()and the log/ktrace ring drainswait for the cadence.
run_poll()queues the backup poll for the end of thecadence, and any full or periodic housekeeping clears it.
drm/asahi: g16: count publication holds by causehold[0]sites go throughnote_hold(), which also counts one ofdrain_failed,drain_initbm,drain_cross,drain_pb,ta_wave,slot,dependencyandother. Theyare printed as
hold_causes:.needs_engine_drain()andcan_queue_behind_with_ta()eachspelled out moves to
render_can_pipeline().hold[0]keeps its meaning.drm/asahi: g16: repoll soon while a job waits behind its own flightsheld_wait. The causemust not be a failure, a cross-VM overlap or a failed dependency.
held_waitgets the short repoll, keeps stage events eligible for the receipt tail, makesSUBMIT rearm soon, and blocks busy coalescing.
Context fixes on this base
render_can_pipeline()callscan_pipeline_in_mask_blocks(), because the SCS-mode variantcomes later in the stack.
drain_crosstherefore covers cross-VM render/compute overlap only.Flighthas nort_computefield.What the counters showed on M4. In multi-pass render rows (compress.bw array, render.postfx),
99.8–99.98 % of
hold[0]ista_wave, so those rows' remaining idle time is TA-wave pacing. Therelease follows the TA stage's finalize stamp, not the end of the TA work.
Evidence
djdev/g16-perf-wave16atb84cfd5fd9e8.9769d65c3f24repoll soon when SUBMIT leaves a paced job waitingfdf4b2e4da0dkeep idle poll passes on the housekeeping cadence024e16604dbecount publication holds by cause9f1dc2f59d46repoll soon while a job waits behind its own flightstools/testing/selftests/drivers/gpu/asahi-m4/run-host-tests.py: 25 ok, 0 not ok.test-poll-retire.py43/43 (new:submit_locked_repolls_soon_when_its_publication_leaves_a_paced_job,idle_poll_step_runs_full_housekeeping_only_on_its_cadence,held_wait_spins_stage_events_and_repolls_soon_until_a_retirement).test-publication.py83/83 (new:hold_causes_split_hold0_by_the_gate_that_stopped_publication, plusheld_waitchecks in the busy-coalescing test).tools/testing/selftests/drivers/gpu/asahi-g15/run.py: 81 passed, 0 failed, 2 ignored.hold_cause(), and theheld_waitrepoll, tail, own-VM condition, coalescing exclusion and SUBMIT term.