Skip to content

drm/asahi: g16: standby PB pool, WC scrub/write trims, inline submit, multi-flight render pipelining, and Wave 3 submit/retire wins - #2741

Draft
DjDeveloperr wants to merge 10 commits into
djdev/g16-272from
djdev/g16-perf-272-pr
Draft

DjDeveloperr wants to merge 10 commits into
djdev/g16-272from
djdev/g16-perf-272-pr

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ten-commit G16 (M4 / T8132, 26B123 firmware) GPU performance series stacked on djdev/g16-272 (#2676), with zero new knobs or debugfs/module parameters:

Waves 1–2 (commits 1–6)

  1. Standby PbEpoch pool: decouple standby PB epochs from per-job Prepared so consecutive renders reuse epochs without re-allocating.
  2. Selective same-VM WC scrubs + word-width WC reads: skip full TPC/tilemap scrubs on clean same-VM slot reuse while retaining full scrubs on first use, cross-VM switch, cancel, error, and recovery.
  3. Timed compute pipelining + expanded compute unit ring: pipeline timed compute commands without serializing behind previous timestamps.
  4. Inline ready submit + submitter-CPU completion worker + tighter poll cadence: publish ready work inline on the submit path and direct completion wakeups back to the submitter CPU.
  5. 8 render pass slots + per-slot scene_list + decoupled PB/UMA allocator slots: compact per-pass VA stride to 64 MiB (8 slots) and isolate scene_list per PassSlot (bisect-safe on its own with overlap still off).
  6. Multi-flight same-VM render pipelining + DRM_ASAHI_FEATURE_FRAGMENT_BARRIERS + deeper queues: enable TA(N)/FS(N-1) overlap via explicit hardware barriers, raise FLIGHTS/SCHEDULER_CREDITS to 32 and AHEAD_RECORDS to 128, restrict each logical queue's drm_sched workqueue to the creator cluster (matching g17/job.rs), and add lock-free syncobj_wait_hint().

Wave 3 (commits 7–10, hardware-verified on dcp55)

  1. Drop Shared::state across retire tail delay + early fence signalling: stop EP 0x20 trailing retries immediately once any flight retires (arming short_repoll only when active flights still retired nothing), release Shared::state and wake ready jobs before each 5 µs retry, and defer 1 ms housekeeping until after job::complete_all().
  2. DRM_ASAHI_FEATURE_COMPUTE_NO_QUERY_ACCESS: advertise and honor COMPUTE_NO_QUERY_ACCESS so ordinary compute dispatches pipeline behind timed compute work while query copy/reset shaders wait for host timestamp publication.
  3. Coalesced mailbox doorbells across multi-command publication batches: ring each touched firmware channel once per batch in Firmware::flush_doorbells() (preserving FS-before-TA ordering and fail-stopping on post-visibility doorbell error).
  4. Trim redundant WC writes for ComputeWork and render scene: write only the active ComputeWork spans (0..0x150 and 0x720..0xf08: 2,360 B vs 8,192 B, -71%) on clean same-VM reuse and populate only the active 2 KiB scene prefix (vs 16 KiB, -87.5%) per render pass.

Hardware Verification (dcp55, Mac mini M4 J773g, macOS 27.2 / 26B123, 4K60 HDMI)

Tested on 7.3.0-ARCH-m4drv8 with aurora.ko carrying all 10 commits (Wave 1–3) + Mesa mesa-m4-mega-59b5202e (Borealis + G16G single-sample colour compression). Across the full boot (314,336 GPU jobs; 247,674 across the 24-row gpubench-vk sweep with tpc_clear_bytes=0, grouped=14,376, overlaps=202,661, reused=113,529 / fresh=3): 0 recoveries, 0 hang kills, 0 dmesg GPU errors, health: failed 0 degraded 0.

  • Vulkan CTS (vk-mustpass-short): 87/87 Pass (0 Fail, 0 Crash, 0 Timeout, 0 GPU errors).
  • Cross-VM & concurrent stress: 4-proc compute.light + concurrent 2-proc render.light + compute.heavy (compute_cross_vm=6,264, render_cross_vm=77) PASS, 0 recoveries, 0 errors.
  • Minecraft 1080p Fancy (rd=12, offscreen KWin Wayland, native GL): rc=0, 163.80 FPS (still 154.77 / spin 131.38 / fly 194.91 FPS, mean 6.105 ms, 8,191 frames, 0 GPU errors).

24-Row gpubench-vk vs Native macOS 27.2 (us/sub, lower is better; * = Linux beats/ties native macOS 27.2 — 7/24 rows)

Test / Params d Base W2b W3+Mega macOS 27.2 W3/macOS W3 gpu (µs) mac gpu (µs) Extra
render.light (tri) 1 425.2 320.9 305.3 262.1 1.16x 23.9 12.1
render.light (tri) 2 289.4 226.0 189.5 169.4 1.12x 24.2 9.9
render.light (tri) 4 292.4 167.9 171.6 104.5 1.64x 27.0 15.6
render.light (tri) 8 290.4 151.8 145.9 97.8 1.49x 21.7 16.4
render.light (tri) 16 293.4 149.6 142.5 94.8 1.50x 21.0 16.5
render.heavy (fill, 1080p) 1 836.1 726.7 585.5 554.3 1.06x 270.7 268.1
render.heavy (fill, 1080p) 2 708.2 414.6 312.9 252.5 1.24x 288.4 283.3
render.heavy (fill, 1080p) 4 698.3 414.6 296.6 248.0 1.20x 295.9 775.9
render.heavy (fill, 1080p) 8 700.3 437.1 307.9 248.0 1.24x 319.1 1760.6
render.heavy (fill, 1080p) 16 704.2 437.8 309.4 247.8 1.25x 320.2 3734.6
render.heavy (geom, 1080p) 1 925.9 833.3 728.9 757.6 0.96x * 415.8 432.2 +3.9% vs macOS
render.heavy (geom, 1080p) 4 809.1 390.6 323.4 259.9 1.24x 322.8 435.7
compute.light 1 310.9 227.5 228.1 159.2 1.43x 1.5 1.5
compute.light 4 93.7 84.8 79.7 39.6 2.01x 1.4 1.4
compute.light 8 79.6 67.8 71.3 34.1 2.09x 1.4 1.5
compute.light 16 89.2 63.1 60.6 32.4 1.87x 1.4 1.6
compute.heavy (alu) 1 929.4 844.6 833.3 827.8 1.01x 554.3 549.5 2577.0 vs 2594.2 GF/s
compute.heavy (alu) 4 566.9 556.8 555.6 540.0 1.03x 554.3 1079.4 3865.5 vs 3977.1 GF/s
compute.heavy (bw) 1 3048.8 2907.0 1592.4 1773.0 0.90x * 1260.5 1420.0 84.29 vs 75.70 GB/s (+11.3%)
compute.heavy (bw) 4 2631.6 2659.6 1282.1 1436.8 0.89x * 1279.6 2870.6 104.69 vs 93.42 GB/s (+12.1%)
copy.bw (fill) 1 1116.1 1041.7 905.8 1000.0 0.91x * 589.2 692.2 74.09 vs 67.11 GB/s (+10.4%)
copy.bw (fill) 4 737.5 739.6 620.3 696.4 0.89x * 621.8 1395.4 108.18 vs 96.37 GB/s (+12.3%)
copy.bw (buf2buf) 1 3048.8 2941.2 1592.4 1773.0 0.90x * 1264.2 1424.8 42.14 vs 37.85 GB/s (+11.3%)
copy.bw (buf2buf) 4 2659.6 2604.2 1282.1 1436.8 0.89x * 1283.3 2868.6 52.34 vs 46.71 GB/s (+12.1%)

Host Verification

  • python3 tools/testing/selftests/drivers/gpu/asahi-m4/run-host-tests.py: 24/24 PASS at Commit 5 alone (bisect verification) and at HEAD (all 10 commits).
  • scripts/checkpatch.pl --strict --git origin/djdev/g16-272..HEAD: 0 errors, 0 warnings, 0 checks across all 10 commits.

Keeping as draft pending the fanless M4 MacBook Air (J713) idle/video power + 10-minute sustained thermal row.

Assisted-by: LLM (Gemini:4 Neon)

Previously Cache::prepare() popped a spare PbEpoch (cap 4) or allocated
and UAT-mapped a fresh 80 KiB PbEpoch for every queued render job, only
for almost every render to reuse the slot's existing epoch and discard
the unused epoch on drop once submission depth exceeded 4.

Keep a shared per-VM standby pool in Cache::standby guarded by
SpinLockIrq with the invariant epochs.len() >= reserved for all accepted
unpublished render commands. Cache::prepare() tops up only the deficit
in SUBMIT ioctl context before any fence exists, waiting interruptibly
on a CondVar for standby headroom during bursts instead of failing with
E2BIG (matching Budget::reserve's 10-second administrative bound) and
retrying if a concurrent InitBM pops an epoch before commit.

Steady-state queued renders at any depth allocate zero PbEpochs and
perform zero UAT mappings or window syncs. Fresh InitBM publications
draw from standby under the device lock without allocating, unpublished
rollbacks return the unexposed epoch, and Cache::close() drops surplus
epochs immediately while retaining only reserved epochs until accepted
jobs drain.

Signed-off-by: Diljit Singh <hey@djdev.me>
…C reads

Previously every compute dispatch zeroed 288.8 KiB of write-combined
memory (256 KiB context_store, 16 KiB aux, 16 KiB preempt, unused seq,
and 16 B its) and read back the 160-byte UMA descriptor byte by byte
with read_volatile(). Every render pass zeroed ~530 KiB to >1 MiB of
WC memory (including dead-code ta_scratch/fs_scratch, work/seq images
immediately overwritten by prefix_render(), aux, scene_user, full 48 KiB
preemption buffers, and tpc_dirty) synchronously under Shared::state.

Track per-slot full-scrub necessity in Slots:
- First use, cross-VM switch, cancelled preparation, affected error
  receipts, and firmware recovery (invalidate_scrub) perform the full
  scrub so no client or faulted state can ever leak.
- Clean same-VM compute reuse zeroes only the 16-byte internal timestamp
  pair (its).
- Clean same-VM render reuse zeroes only its (32 B), active heap header
  (4 KiB), tilemap_dirty, and active preemption record headers (2 KiB),
  preserving the tpc_dirty high-water mark until the next full scrub.
- Upgrade FwObject::read() to 64-bit volatile word loads for aligned
  spans, reducing compute descriptor WC bus reads by 8x.

Signed-off-by: Diljit Singh <hey@djdev.me>
…it ring

can_queue_behind() previously refused to pipeline behind any in-flight
compute command carrying timestamp_outputs, forcing depth-4+ timed
compute workloads down to depth-1 serialization. Each compute flight
already owns its own private ComputeSlot (its/work), and retire_oldest()
publishes timestamps in FIFO publication order before signalling the
flight's fence, so timed same-VM compute commands can pipeline freely.

Expand hw::sizes::COMPUTE_UNITS and params::compute_units() from 8/6 to
16 (placing extension units at 0x7080000000..0x70b8000000, clear of the
0x7040000000..0x7080000000 dynamic PB page-list aperture and below
PB_HEAP at 0x70c0000000, using hardware UMA slots 1..=16). With
displacement lifetime tracking, 16 units sustain up to 15 in-flight
compute commands per bursting VM instead of 5.

Signed-off-by: Diljit Singh <hey@djdev.me>
…en poll cadence

Eliminate four layers of host-side latency on the G16 submit/completion
round trip while preserving sleep-transition safety:

1. Direct inline submit from SUBMIT ioctl: when the previous job on the
   logical queue has already started, all input fences are signalled,
   and Shared::state is uncontended (try_lock), Scheduler::push()
   publishes immediately on the submitting CPU before pushing to
   drm_sched (whose subsequent run() observes started == true as a
   no-op while preserving credits, fence ownership, and QUEUE_DESTROY
   drain semantics). Contended or dependency-blocked jobs fall back to
   drm_sched in strict queue order.
2. Submitter-pinned dedicated completion worker: replace WORK_CPU_UNBOUND
   on system_highpri_wq for EP 0x20 / hrtimer wakeups with a per-CPU
   high-priority reclaim OwnedQueue (aurora_g16_events) enqueued on the
   last submitting CPU, keeping WC receipt reads and fence wakeups hot
   on the submitting core; join cleanly in sleep::join_workers().
3. Tighten post-event retirement tail: extend post-EP-0x20 trailing
   5 us polls from 4 (20 us) to 10 (50 us) to absorb firmware's WC
   receipt tail without falling into a 100 us resnap hrtimer sleep, and
   rearm at repoll_us (15 us) if an evented flight is still settling.
4. Split fast completion drain from 1 ms housekeeping and stop hrtimer /
   delayed-work thrash: throttle power-governor updates, host-window
   health checks, full Session::check(), and administrative hang checks
   to 1 ms cadence while keeping transport checks, ring drains, and
   recovery/fault checks immediate; avoid cancelling/reprogramming the
   hrtimer or re-arming the 1-jiffy backup when a sufficient timer is
   already armed. Guard run_poll(), submit_locked(), and
   try_submit_inline() with lock-held sleeping.load(Ordering::Acquire)
   checks so suspend never races inline or polled publication.

Signed-off-by: Diljit Singh <hey@djdev.me>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Big wins on the J773g, and the 0 recoveries over 228k jobs is reassuring. A targeted adversarial read of fd755f1 (not every line of the 2k):

  • Scrub skipping is safe across processes. A slot skips the full scrub only when owner[k].id == vm_id, owner holds an Arc<VmState>, and VM ids come from the SequenceIDs counter (gpu.ids.vm.next()). So a slot's previous owner stays alive while it's recorded, and a new process can never inherit its id and its unscrubbed tilemap/heap. Error, cancel and recovery all force scrub_full. Good.

Things I'd like to see before this leaves draft:

  1. A MacBook Air row. Commit 4 extends the post-event trailing poll from 5 µs to 50 µs with 15 µs repolls, pins the completion worker high-priority on the submitter's CPU, and commit 6 pins each queue's drm_sched workqueue to the creator's cluster. On a fanless, battery-powered M4 Air (J713, same G16) those trade CPU wakeups and P-core residency for latency. All the numbers here are from a mains-powered mini with a fan. Two rows would settle it on the J713: (a) idle desktop and video-playback package power plus CPU wakeups/s, before and after; (b) a sustained 10-minute GPU load, with die temperature and the throttled clock at the end, before and after. If the trailing poll costs measurable idle power, it could be keyed on the queue actually having work in flight.
  2. Creator-cluster pinning. If the creating thread ran on an E-core (common for a compositor's setup thread), every later submit for that queue completes on the E-cluster. How does it behave when the creator's cluster is offlined or the creator migrates? A note on the fallback, or picking the cluster at submit time rather than queue creation, would cover it.
  3. Bisect safety of commit 5. It moves scene_list into the per-pass slot "to prevent TA/FS overlap corruption", but overlap is only enabled in commit 6. If 5 alone already changes the VA stride to 64 MiB with 8 pass slots, a one-line note that 5 is safe with overlap still off would help a future bisect.

Assisted-by: LLM (Claude:Opus 5.5)

…d decouple PB/UMA slots

Compact the per-pass render VA layout from 256 MiB to 64 MiB stride
within 0x7020000000..0x7040000000 (verified by compile-time overlap
assertions), expanding RENDER_SLOTS from 2 to 8, and move scene_list
(0x4000 bytes) from the shared per-allocator Allocator into per-pass
PassSlot (client VA client::SCENE_LIST + i * PASS_STRIDE, 0x7020180000).
Giving each PassSlot its own scene_list matches G15's per-pass storage
and prevents TA(N)/FS(N-1) overlap corruption when render pipelining is
enabled.

This commit is bisect-safe on its own with render overlap still off:
Order::ready() and Firmware::can_queue_behind() still serialize renders
at depth 1 until the following commit, so the compacted 64 MiB pass
stride and per-PassSlot scene_list run cleanly under single-flight
render execution.

Keep base RenderArena at 2 pass slots for single-pass or light VMs and
lazily allocate extension pass slots 2..8 in RenderExtArena on render
bursts (mirroring compute_ext). Box RenderOwners in Slots alongside
ComputeOwners and switch its displacement ledger to pipelined mode
(Lifetime::<8>::new(true)), keeping up to 7 concurrent passes in flight.

Decouple the two device-wide PB/UMA allocator slots (parameter_id 0/1,
hardware UMA slot 33) from PassSlot index 0..8: same-VM renders stay on
their active reusable allocator slot with cumulative uma_submitted
tracking (PoolSet::prepare_in_flight / retired_at), while cross-VM
switches and post-recovery/error renders drain and switch to the
displaced alternate slot. Aborted receipts permanently quarantine the
affected allocator slot and retain its VM and arena leases. Check
Pools::exhausted(), per-VM Pools::exhausted_for(), and
Slots::render_exhausted_within() in publish_checked() so blocked render
VMs cancel immediately with ECANCELED instead of spinning on EAGAIN and
stalling unrelated compute.

Signed-off-by: Diljit Singh <hey@djdev.me>
…nt barriers, and deeper queues

Lift depth-1 render serialization so same-VM renders pipeline across
PassSlot 0..RENDER_SLOTS while sharing the active exposed PB/UMA
allocator slot, and remove remaining host-side queue-depth and
wakeup-placement caps:

- Allow same-engine render orders in Order::ready() to follow the
  queue's published render frontier while keeping cross-engine
  dependencies gated on full completion.
- Extend Firmware::can_queue_behind() to admit healthy same-VM renders
  behind in-flight non-InitBM renders of the same VM (up to
  params::render_flights() = RENDER_SLOTS - 1), while still draining
  across VM switches, cross-engine transitions, InitBM priming renders,
  and error/recovery paths.
- Emit explicit TA/FS hardware barriers in prefix_render() for queued
  renders: fragment-only or barrier-free renders overlap TA(N) with
  FS(N-1) (advertising DRM_ASAHI_FEATURE_FRAGMENT_BARRIERS); full
  render barriers hold TA(N) on FS(N-1) in hardware.
- Remove the render_busy skip in Shared::submit_locked() so queued
  renders publish immediately on submit, and extend queue_passed() and
  retired_snapshot() for in-order passed receipts across Channel::Ta,
  Channel::Fs, shared notifier stamps, and cumulative PoolSet::retired_at()
  UMA completion.
- Bound clean same-VM tilemap scrubbing in Slots::claim_pass_in() to
  tilemap_dirty.min(current_tilemap_bytes) while retaining the high-water
  mark for larger subsequent passes and cross-VM/recovery full scrubs.
- Raise FLIGHTS (16 -> 32), SCHEDULER_CREDITS (16 -> 32), AHEAD_RECORDS
  (64 -> 128), and params::compute_flights() (16 -> 32), give each
  logical queue's drm_sched a creator-cluster-restricted ordered
  reclaimable workqueue, and implement gpu::Gpu::syncobj_wait_hint()
  with a lock-free active-burst uclamp hint (matching G17).

Signed-off-by: Diljit Singh <hey@djdev.me>
…l fences early

Firmware::retire() previously ran up to EVENT_RETIRE_POLLS (10) x 5 us
udelay() loops while holding Shared::state whenever flights remained
non-empty after an EP 0x20 interrupt. At queue depth d > 1, retiring the
oldest flight left subsequent flights in self.engine.flights, causing
every EP 0x20 interrupt to spin for 50 us under Shared::state (bouncing
concurrent try_submit_inline() submissions onto drm_sched) and to arm a
15 us short_repoll hrtimer even though retirement had succeeded.
Periodic 1 ms housekeeping also ran before retiring and signalling
completed fences.

Split polling into a non-sleeping Firmware::poll_step() and
Firmware::retire_once() that report whether any flight retired:

- Stop the EP 0x20 trailing retry loop immediately as soon as any flight
  retires (or flights drain, a receipt fault occurs, or the engine
  freezes/fails), and set short_repoll only when an event with active
  flights still retired nothing after the trailing retries.
- Release Shared::state and complete any ready jobs before each 5 us
  udelay() retry so concurrent inline submissions can acquire the lock
  without contention.
- Retire and publish ready work before periodic 1 ms housekeeping,
  deferring housekeeping until after job::complete_all() wakes userspace
  whenever jobs retired on that pass.

Signed-off-by: Diljit Singh <hey@djdev.me>
Advertise DRM_ASAHI_FEATURE_COMPUTE_NO_QUERY_ACCESS in G16 GET_PARAMS
and accept DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS in compute stream/command
validation.

G16 publishes command timestamp outputs from the CPU during
retire_oldest(). Record on each Flight whether it carries timestamp
outputs and, in Firmware::can_queue_behind(), hold a same-queue compute
command with a compute barrier behind an in-flight timed predecessor
unless DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS is set (clearing
ComputeCommand::query_access). Ordinary compute dispatches that pass
NO_QUERY_ACCESS continue to pipeline freely behind timed compute work,
while query copy/reset compute shaders wait for host timestamp
publication.

Extend test-command-stream.py and test-publication.py with host coverage
for the compute flag and query-access pipelining rules.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr DjDeveloperr changed the title drm/asahi: g16: standby PB pool, selective WC scrubs, inline submit, and multi-flight render pipelining drm/asahi: g16: standby PB pool, WC scrub/write trims, inline submit, multi-flight render pipelining, and Wave 3 submit/retire wins Nov 21, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Thanks for the targeted adversarial read! Updated djdev/g16-perf-272-pr to 4bae96037 (10 commits, still Draft pending the fanless J713 Air row) with the review points addressed and Wave 3 (4 hardware-verified commits from dcp55) appended:

Review Points Addressed

  1. Trailing poll / short_repoll & MacBook Air row: Commit 7 (drop Shared::state across retire tail delay and signal fences early) now stops the EP 0x20 trailing retry loop immediately as soon as any flight retires (or flights drain) and arms short_repoll only when active flights still retired nothing after the trailing retries, releasing Shared::state and waking ready jobs before each 5 µs retry. Keeping this PR in Draft until we collect the requested fanless J713 Air rows (idle/video-playback package power + wakeups/s, and 10-min sustained GPU thermal/clock A/B).
  2. Creator-cluster pinning (g16/job.rs): Added a comment documenting the exact scope and fallback matching g17/job.rs: the restricted ordered workqueue handles only drm_sched run_job/free_job (actual completion signalling runs on Shared::complete_work queued to the per-submit submitter_cpu, not the queue's creation CPU), and apply_workqueue_attrs() on an unbound workqueue automatically falls back to wq_unbound_cpumask if the creator's cluster is offlined (while let _ = submit.restrict(...) fails soft to the default unbound mask on error).
  3. Bisect safety of Commit 5: Verified 24/24 asahi-m4 host tests pass at Commit 5 alone and documented in Commit 5's commit message that Order::ready() and Firmware::can_queue_behind() still serialize renders at depth 1 until Commit 6, so the compacted 64 MiB pass stride and per-PassSlot scene_list are bisect-safe with overlap still off.

Wave 3 dcp55 Hardware Verification (J773g, macOS 27.2 / 26B123, 4K60 HDMI)

  • Stability: 314,336 GPU jobs across the full boot (247,674 across the 24-row gpubench-vk sweep with tpc_clear_bytes=0, grouped=14,376, overlaps=202,661), 0 recoveries, 0 hang kills, 0 dmesg GPU errors.
  • Correctness: 87/87 vk-mustpass-short PASS; 4-proc compute.light + concurrent 2-proc render.light/compute.heavy cross-VM stress (compute_cross_vm=6,264, render_cross_vm=77) PASS.
  • Performance vs native macOS 27.2: Beats native macOS 27.2 on 7/24 gpubench-vk rows (all 6 BW/copy rows by +10.4–12.3%, plus render.heavy geom d=1 728.9 vs 757.6 µs, +3.9%); Minecraft 1080p Fancy native GL 163.80 FPS (rc=0, 0 errors). Full 24-row table is in the updated PR description.
  • Host checks: checkpatch.pl --strict 0/0/0 across all 10 commits; asahi-m4 host tests 24/24 PASS at Commit 5 and at 4bae96037.

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 4bae960. Commits 1-4 are unchanged from fd755f1. 5 and 6 differ only in the commit-message note and the job.rs comment.

Earlier points:

  1. Air power/thermal row: still open, as you said. Commit 7 makes the tail cheaper. It stops on the first retire and drops Shared::state across the 5 µs waits (poll.rs:409-422), and short_repoll now arms only when nothing retired. An event that retires nothing still costs up to 10 x 5 µs of udelay (poll.rs:47, poll.rs:144), and the high-priority submitter-CPU completion worker is unchanged. Also, with the lock dropped, POLL_WORK and FAST_POLL_WORK (mod.rs:268-288) can now both be in that tail at once. So the J713 rows (idle/video package power and wakeups/s; 10-minute sustained temperature and end clock, before and after) are still the thing to see, at this head.
  2. Creator-cluster pinning: the new comment answers it. Completion follows the per-submit CPU, and the restricted unbound workqueue falls back when its cluster goes offline. Fine.
  3. Commit-5 bisect note: done.

New commits:

  • Commit 10 trims the per-dispatch WC writes to 0..0x150 and 0x720..0xf08 of the compute work (fw/work/compute.rs:6-14), and to the first 0x800 bytes of the scene (fw/work.rs:214-217). On the host side I checked every encoder write against these spans for both V25G83 and V26B123 (25 register records, notifier, descriptor, 0xf00 tail, work_ticks, scene results at 0x600 and copy records up to 0x780), and they fit. What the trim newly relies on is that the firmware never writes into the gaps either, because clean same-VM reuse no longer re-zeroes them. A one-off debug readback over the gpubench sweep, showing the gaps still zero after retirement, would back the "only touches" claim. Nit: compute_needs_full_work() still has #[allow(dead_code)] although engine.rs:1547 uses it.
  • Commit 9: the publication-deadline return Err(ETIMEDOUT) inside the publish loop returns before flush_doorbells(). Records already posted earlier in the batch are then never rung. Every caller fail-stops on that error today (poll.rs:131-135, poll.rs:193-196), so nothing breaks. A comment there, or flushing before the return, would keep it from becoming a stranded-record bug if that error ever stops being fatal.
  • Commit 8 looks right to me. The flag is accepted in both validators, and the query_access hold in can_queue_behind() is limited to the same queue's timed predecessors.

Every row so far is from the J773g on 26B123. A functional run (vk-mustpass-short) on a J713 at this head would cover the Air's side of the same G16 code.

Assisted-by: LLM (Claude:Opus 5.5)

…cation batches

When publish_checked() publishes multiple commands in a single pass
(multi-command SUBMITs or queued back-to-back submissions), each command
still posts its own SubmitRecord and advances qstate::WRITE individually
per the M4 firmware contract, but previously called session.ring(channel)
on every iteration.

Defer doorbell ringing into a per-batch channel bitmask and ring each
touched channel once via Firmware::flush_doorbells() after the batch
loop finishes (preserving FS-before-TA ordering for render batches and
fail-stopping on any post-visibility doorbell error). Count commands
that share a coalesced doorbell pass in Engine::stats.grouped.

Add host tests in test-publication.py covering coalesced compute/render
doorbells, deferred-follower flushing, and doorbell error fail-stop.

Signed-off-by: Diljit Singh <hey@djdev.me>
…scene

Every G16 compute dispatch previously copied the full 8 KiB ComputeWork
object (0x2000 bytes) into write-combined firmware memory, even though
encode_compute_for() and the firmware only touch 0x000..0x150 (header
plus up to 25 register records) and 0x720..0xf08 (metadata, ABI fields,
embedded sequence, notifier, UMA descriptor, tail) — leaving 5,832 bytes
(71%) perpetually zero. Similarly, every render pass zeroed and copied
the full 16 KiB scene object (0x4000 bytes) to WC memory even though
only 0x000..0x780 (rounded up to 0x800, 2 KiB) is touched by host or
firmware.

- Track on ComputeOwners whether each unit's latest claim required a
  full scrub (first use, cross-VM switch, cancelled prep, error, or
  firmware recovery). On clean same-VM reuse, prefix_compute() writes
  only the two active spans (0..0x150 and 0x720..0xf08: 2,360 bytes
  instead of 8,192 bytes); full-scrub claims still write all 0x2000
  bytes after preserving any existing UMA descriptor.
- Zero the full 16 KiB PassSlot::scene in PassSlot::scrub(full = true),
  size Scratch::scene to scene::ACTIVE_SIZE (0x800), and allow
  fill_scene() to zero and populate that active 2 KiB prefix, cutting
  14,336 bytes (87.5%) of CPU memset and WC writes per render pass.
- Extend test-resources.py to verify compute_needs_full_work() state
  transitions and PassSlot::scene full-scrub coverage.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Updated djdev/g16-perf-272-pr at 65a87c442d997 for the two code comments on Commits 9–10:

  • Commit 9 (drivers/gpu/drm/asahi/g16/engine.rs): defensively flush pending_rings before return Err(ETIMEDOUT) in publish_checked() with a comment noting self.engine.flights.is_empty() already implies pending_rings == 0 today, preventing stranded records if the error ever stops being fatal.
  • Commit 10 (drivers/gpu/drm/asahi/g16/slots.rs): removed the unused #[allow(dead_code)] on compute_needs_full_work().

Host verification: asahi-m4/run-host-tests.py 24/24 PASS; checkpatch.pl --strict 0/0/0.

Remaining open items tracked for next runs:

  • One-off gap-zero readback verification on J773g across the gpubench-vk sweep for Commit 10.
  • J713 M4 Air power/thermal (idle/video power + wakeups/s + 10-min sustained) and vk-mustpass-short rows at this head (requesting on J713).

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 65a87c4. Commits 1-8 are unchanged from 4bae960.

  • Commit 9: fixed. publish_checked() now flushes pending_rings before return Err(ETIMEDOUT) (g16/engine.rs:929-937), and the comment matches the code: that arm only runs when no flight is in flight.
  • Commit 10: the #[allow(dead_code)] is gone. The gap-zero readback is still owed. The trim relies on the firmware never writing the unwritten spans of the compute work and the scene.
  • Still owed at this head, as you noted: on a J713, idle and video package power with CPU wakeups/s, and a 10-minute sustained GPU load with die temperature and end clock, both before and after; plus a vk-mustpass-short run. The trailing 5 µs repolls on events that retire nothing are what those power numbers would show.

No new issues.

Assisted-by: LLM (Claude:Opus 5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants