Repository navigation
drm/asahi: g16: adaptive compute pipe affinity, busy-horizon coalescing, and adaptive TA wave scheduling - #3047
Conversation
98df0af to
b84cfd5
Compare
… and work rings Match the render pass-slot command-record layout on Apple G16 by moving per-unit compute microsequences and barrier records, together with the four compute/render firmware work rings, into device-lifetime Class::FwCoherent mappings owned outside per-VM arenas. Each hardware compute unit index (0..COMPUTE_UNITS) is device-global and claimed by one flight at a time. Previously every VM's ComputeSlot allocated its own uncached seq and barrier pages, while prefix_compute hardcoded ComputeRefs::seq to the embedded sequence inside the uncached compute work image (work + 0x900) and wrote 1248 bytes of write-combined body per clean same-VM submit. The work image already names its microsequence by address (+0x760) and size (+0x768), and encode_compute_rt already emits every microsequence self-reference relative to ComputeRefs::seq. Share device-lifetime UnitCmds (seq and barrier) per hardware compute slot via resources::ComputeCmds (indexed by hw_slot so SCS sets map to the exact hardware ledger slot they claim), point ComputeRefs::seq to s.seq.va, write the 768-byte microsequence into cacheable s.seq, and shrink clean same-VM WC work writes to work[0x720..0x900]. Likewise allocate the two compute and two render work rings (host-written VA arrays, never host-read) from a ManuallyDrop device-lifetime Factory::persistent_objects_probe allocator after sealing session allocations; because Graphs::finish() runs during platform probe() before drm_dev_register(), the probe-only allocator prepares its backing against the bound platform device while non-probe private allocations keep requiring registration_guard(). Keep ComputeSlot::work in Class::Shared so host retirement reads of DESCRIPTOR_COMPLETED and 26B123 work_ticks stay strictly coherent without relying on ASC-to-AP cache clean ordering. Signed-off-by: Diljit Singh <[email protected]>
Compute retirement checks DESCRIPTOR_COMPLETED (0xe54) and DESCRIPTOR_COUNTER (0xe4c) via FwObject::r64(). Both packed fields are 4-byte aligned (offset % 8 == 4), which previously bypassed the 8-byte fast path and fell through to FwObject::read()'s byte loop, issuing 16 single-byte write-combined loads and 4 read barriers per call (32 byte loads and 8 barriers per retired compute command). Add a 4-byte-aligned fast path in FwObject::r64() that reads matched aligned 32-bit word pairs separated by rmb(), preserving the exact tear-free double-snapshot and EAGAIN retry semantics while cutting each 4-byte-aligned receipt check to 4 aligned 32-bit loads. In Firmware::compute_ticks_with(), also read ABI-defined work_ticks before falling back to unit.its. On 26B123, firmware leaves unit.its zeroed and records compute GPU ticks in work_ticks, so probing work_ticks first avoids two always-zero WC r64 reads and two read barriers per compute command while preserving the ITS fallback and 25G83 behavior. Signed-off-by: Diljit Singh <[email protected]>
|
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: this PR's own 3 commits against its base; the reworked |
…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]>
b84cfd5 to
8495c00
Compare
What: G16 (M4) scheduling, stacked on #3043: adaptive compute pipe affinity and busy-horizon coalescing, an adaptive TA wave window with an O(1) pending scan, and cursor-ordered async pass pre-scrub.
Tested: M4 Mac mini (J773g, G16G B0, 26B123) with the full stacked series on an earlier build, not this head: gpubench 440/440, 4,670/4,670 supported CTS cases, 0 faults, 0 recoveries. Host tests 64/64 and 82/82.
Risk: two-way · M4 (J773g, J713)
Not yet: a row at the current head; CI, which runs once the base lands and this PR targets
main.Details (original description)
Summary
Optimizes Apple M4 (
G16G) command scheduling, pass pre-scrubbing, and compute pipe placement without regressing multi-queue or heavy-workload latency:Verification
tools/testing/selftests/drivers/gpu/asahi-m4/test-resources.py— 64 passed, 0 failed.tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py— 82 passed, 0 failed.scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks across all 3 commits.G16G B0,26B123) silicon:gpubenchsuite: 440/440 PASS across 4.00M GPU jobs (0faults,0recoveries,0bad CRCs) —vk-rt98/98 (1.127×vs Metal 4),vk-full202/202 (1.094×; Wave-21.001×),gl-native70/70 (1.100×),gl-zink70/70 (1.078×).3/3 render.light procs d=16: 0 faults, 0 recoveries, 0 bad CRCs.0failures,0faults,0recoveries).