Repository navigation
soc: apple: mailbox: take GPU firmware messages in the hard interrupt - #2489
RyanTheTide wants to merge 1 commit into
Conversation
Since commit 9827b6b ("drm/asahi: bound repeated timeout recovery and G17 mailbox stalls") the GPU mailbox (ASCWrap v6 GFX/GFX1 role) receives through a oneshot threaded interrupt with no primary handler. Every GPU completion therefore costs two scheduler hops before its fence signals: hard IRQ -> wake irq/N receive thread (SCHED_FIFO) -> context switch -> drain FIFO -> RTKit early hook queues the GPU event work -> wake the event kworker -> context switch -> signal fences The thread buys nothing on the common path. The consumer is RTKit's receive callback, which for GPU event messages only queues the event work, and it already runs atomically (the thread calls it under rx_lock with interrupts off). Every other ASC mailbox drains its FIFO in the hard interrupt. Add a primary handler for the GPU receive interrupt that drains up to APPLE_G17_MBOX_RX_BUDGET messages and returns IRQ_HANDLED, so the event work is queued straight from the interrupt and the receive thread's wakeup leaves the completion path. A pass that drains the whole budget is a flood: the handler returns IRQ_WAKE_THREAD, the line stays masked (IRQF_ONESHOT) and the thread continues with its existing pause after each full budget, so that commit's flood bound is kept. ASCWrap v8 keeps the threaded path and its storm guard. The receive thread's minimum-utilization clamp (rx_util_min) now applies only to floods. Measured on a MacBook Pro M4 Pro (T6040, J616s), one boot, the old and new receive paths interleaved, 5 runs each, depth-1 GPU round trips (gpubench, submitting thread on a P core): fill 720p 198.6 -> 181.6 us per frame (-8.6 %) compute.light 111.8 -> 92.2 us (-17.5 %) macOS on the same machine: 170.0 and 90.9 us. Add a KUnit case: a flooding FIFO drains exactly one budget in the hard interrupt and is handed to the thread. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Blockers: 1.
HW row: head build, plus a PROVE_LOCKING boot, on J616s and Neo J700 (and J713 if its GPU mailbox has the v6 GFX role): gpubench depth-1 fill/compute.light interleaved against the threaded path (N>=5), a GPU flood/recovery row, 0 lockdep reports, 0 GPU faults/timeouts, 0 AVC, 0 failed units. Assisted-by: LLM (Claude:Opus 5.5) |
|
Review note: the receive budget and the hard/threaded split here are applied to the G17 role only. The other roles still request a hard handler and drain the I2A FIFO without a budget ( |
Problem
On the M4 Pro (J616s, T6040) a depth-1 GPU round trip is 18 % slower than macOS on the same machine (fill 720p 198.6 vs 170.0 us, compute.light 111.8 vs 90.9 us). Every GPU completion takes two scheduler hops before its fence signals: the GPU mailbox receive interrupt has no primary handler (oneshot thread only), so the hard IRQ wakes the receive thread, which drains the FIFO, which queues the event work. Every other ASC mailbox drains its FIFO in the hard interrupt.
Change
Add a primary handler for the GPU (ASCWrap v6 GFX/GFX1 role) receive interrupt that drains up to the existing
APPLE_G17_MBOX_RX_BUDGETand returnsIRQ_HANDLED. A pass that drains the whole budget is treated as a flood and handed to the existing thread, so the flood bound from 9827b6b is kept. ASCWrap v8 keeps the threaded path. Selection is the mailbox's hardware role (from the DT/ADT ASCWrap description), no chip or board list, no parameter.Testing
J616s, one boot, old and new receive paths interleaved, 5 runs each, gpubench depth 1, submitting thread on a P core:
compute.light reaches macOS parity (1.01x); fill goes from 1.17x to 1.07x. Boot clean (0 kernel errors, 0 failed units, Enforcing), no GPU faults or timeouts during the rows. Build:
drivers/soc/apple/mailbox.owith the fleet config, W=1, no warnings; checkpatch clean (one--no-treecommit-id lookup). KUnit: a flooding FIFO drains exactly one budget in the hard interrupt and is handed to the thread.Still to run
Reviewer and lane detail
traces/perf/20261120-perf-j616s/README.md(A/B section), rawab-0956/(gpubench JSON per run).rx_util_minclamp now only applies to floods, so CPU0's cluster no longer gets the RT-thread frequency bump on every completion; the numbers above include that effect.work/swarm/lanes/PERF-J616S.md.