Repository navigation
soc: apple: mailbox: drain G17 receive interrupts in hard IRQ - #2980
Conversation
There was a problem hiding this comment.
Pre-PR Checklist Review (§1–§6) — Changes Needed
Reviewed head: 5555740b417a3586588310d54de3a5e730ae05ce
Live CI: 7/7 checks SUCCESS (host-tests, source, rust-build, kunit, DWC3/ATC builtin-no-atc, DWC3/ATC modular-no-atc, DWC3/ATC builtin-modular-atc; mergeable CLEAN)
Cross-PR conflicts (#2981, #2967, #2968, #2969): None — no other open PR modifies drivers/soc/apple/mailbox.c or drivers/soc/apple/mailbox-g17-test.h.
Blocker — ASCWrap v8 (apple,t8152-gfx-ascwrap-v8) Storm Guard Silently Bypassed
In drivers/soc/apple/mailbox.c:
apple_mbox_probe_ascwrap_v8()(lines 1451–1458) setsmbox->ascwrap_v6.roletoAPPLE_MBOX_ASCWRAP_V6_ROLE_GFXorAPPLE_MBOX_ASCWRAP_V6_ROLE_GFX1.apple_mbox_is_g17()(lines 540–544) checks onlyrole == APPLE_MBOX_ASCWRAP_V6_ROLE_GFX || role == APPLE_MBOX_ASCWRAP_V6_ROLE_GFX1, so it returnstruefor every ASCWrap v8 mailbox as well.apple_mbox_probe()(lines 1654–1660) therefore registersapple_mbox_g17_recv_irq/apple_mbox_g17_recv_threadfor ASCWrap v8 instead ofapple_mbox_recv_irq.- Unlike
apple_mbox_recv_irq()(lines 982–983),apple_mbox_g17_recv_irq()never callsapple_mbox_v8_rx_irq_guard(mbox, consumed).
Impact:
- The
if (mbox->hw->is_ascwrap_v8) apple_mbox_v8_rx_irq_guard(mbox, consumed);check inapple_mbox_recv_irq()is now completely unreachable dead code. - If
ascwrap_v8_rx_irq=1is enabled on T8152 (G18), an unpowered PSD (apple_mbox_poll_locked()returns-EHOSTDOWN) or a stuck/miswired level-triggered IRQ will spin infinitely in hard IRQ context instead of disabling the line afterAPPLE_ASCWRAP_V8_RX_STORM_LIMITempty hits and falling back to polling — hard-locking the CPU.
Required fix: Either invoke if (mbox->hw->is_ascwrap_v8) apple_mbox_v8_rx_irq_guard(mbox, consumed); under rx_lock in apple_mbox_g17_recv_irq() (all of disable_irq_nosync, dev_err, and queue_delayed_work are hard-IRQ safe) and remove the unreachable branch from apple_mbox_recv_irq(), or exclude mbox->hw->is_ascwrap_v8 from the hard-IRQ split (e.g., gate on apple_mbox_is_g17(mbox) && !mbox->hw->is_ascwrap_v8 if v8 is intended to stay on apple_mbox_recv_irq), and cover the v8 storm-guard path in KUnit.
Hard-IRQ Safety, Locking, Teardown & Non-G17 Audit
- Hard-IRQ safety (Pass on all
ROLE_GFX/ROLE_GFX1consumers):apple_rtkit_rx()(drivers/soc/apple/rtkit.c:1648-1725) uses onlyktime_get_ns(),dma_rmb(), atomic flag/FIFO operations,GFP_ATOMICallocation, andqueue_work().- Every
recv_message_early()callback reachable viaROLE_GFX/ROLE_GFX1is hard-IRQ safe:- G17 (
drivers/gpu/drm/asahi/g17/mod.rs:450):complete_all()+queue_event_records()(RoleStateborrows anArc<Shared>keeping refcount >= 2 soShared::dropcannot run in hard IRQ). - M5 live boot (
drivers/gpu/drm/asahi/m5/live_boot.rs:35):AtomicBool::store(). - G16S / T6040 & T6041 (
drivers/gpu/drm/asahi/g16/boot.rs:201):mod_delayed_work_on()on leakedArc<Shared>. - G18 / T8152 (
drivers/gpu/drm/asahi/g18/boot/mod.rs:988):AtomicBool::store().
- G17 (
- Locking / lockdep (Pass):
mbox->rx_lockusesspin_lock_irqsaveeverywhere (including hard IRQ, which also keeps the KUnit process-context call safe); no lock ordering inversions withtx_lockorlifecycle_lock. - Flood / livelock bound (Pass for ASCWrap v6): Hard IRQ drains at most
APPLE_G17_MBOX_RX_BUDGET(64) messages before returningIRQ_WAKE_THREAD, keeping the level IRQ masked viaIRQF_ONESHOTacross the 1–2 msusleep_range()inapple_mbox_g17_recv_thread(). - Teardown & suspend (Pass):
apple_mbox_stop_locked(),apple_mbox_quiesce(), andapple_mbox_suspend_noirq()(apple_mbox_hold_rx()) all usedisable_irq()/synchronize_irq(), synchronizing both hard IRQ and thread handlers. - Non-G17 Apple mailboxes (Pass): ASC v4, M3, T8140 ASC/AOP, T8152 SMC/AOP, DCP, SEP, etc. remain on
apple_mbox_recv_irq()with unchanged runtime behavior. - Buildability (
=m/=y& KUnit) (Pass):IS_REACHABLE(CONFIG_KUNIT)handles all tristate combinations cleanly;scripts/checkpatch.pl --strictis clean (0 errors/warnings/checks).
Checklist Findings (§1–§6)
- §1 (No model gating / multi-Mac coverage) — Gaps:
apple_mbox_is_g17()also matches T6040/T6041 (M4 Pro/Max,apple,t6040-ascwrap-v6), T8140 (G17P), T8142 (M5 base), and T8152 (G18,apple,t8152-gfx-ascwrap-v8), not just M5/G17 ASCWrap v6. Commit message should reflect the true scope, and runs (or explicit test requests) are needed on the other affected Macs. - §2 (Production-ready, no hacks) — Pass.
- §3 (Safety) — Fail: Blocked by the ASCWrap v8 storm-guard bypass above.
- §4 (Clean-room & attribution) — Pass: Human author/committer (
Diljit Singh <[email protected]>), humanSigned-off-by:only, zero AI trailers in commit,Assisted-by:present in PR body. - §5 (Evidence) — Gaps:
- Missing mandatory regression tuple (
0 SELinux denials, 0 failed units, 0 new kernel errors). - Clarify baseline A's exact kernel/commit for the
99.8 -> 92.6 us/70.9 -> 61.1 usA/B (and whether it isolated#2980alone), plus confirm402/403Vulkan CTS and193/200occlusion-query CTS match baseline A unchanged. - Note live non-G17 mailbox regression coverage on the booted Mac (SMC/DCP/SEP/AOP/NVMe alongside the
sep-suspendhost test).
- Missing mandatory regression tuple (
- §6 (Naming) — Pass.
- Minor doc nit: Comments in
include/linux/soc/apple/mailbox.h:128-130anddrivers/soc/apple/mailbox.c:915-917still say the threaded receive handler runs on every message; after this changeapple_mbox_apply_rx_util_min()only runs when the flood-throttle thread wakes.
Verdict: Changes Needed — fix the ASCWrap v8 storm-guard bypass and complete the §1/§5 items before MERGETRAIN-LINUX4.
Live
|
ASCWrap v6 GPU mailboxes (APPLE_MBOX_ASCWRAP_V6_ROLE_GFX and APPLE_MBOX_ASCWRAP_V6_ROLE_GFX1 across T6040/T6041, T8140, T8142, and T6050) previously registered their recv-not-empty interrupt as a pure threaded IRQ, paying an extra IRQ-thread wakeup on every GPU completion before apple_rtkit_rx() could enqueue the driver's event work item. All ASCWrap v6 GFX/GFX1 receive handlers already execute under spin_lock_irqsave(&mbox->rx_lock, flags) inside apple_mbox_poll_locked() and are strictly hard-IRQ safe: apple_rtkit_rx() performs only atomic FIFO/flag checks, GFP_ATOMIC work allocation, queue_work(), and non-sleeping recv_message_early() callbacks (AtomicBool stores, complete_all(), mod_delayed_work_on(), and workqueue enqueue), deferring all sleeping RTKit callbacks to process context on rtk->wq. Exclude ASCWrap v8 (apple,t8152-gfx-ascwrap-v8, hw->is_ascwrap_v8) from apple_mbox_is_g17() so v8 stays on apple_mbox_recv_irq() with its apple_mbox_v8_rx_irq_guard() storm guard intact. Split the ASCWrap v6 G17 receive path into a hard-IRQ handler (apple_mbox_g17_recv_irq) that drains apple_mbox_poll_locked() directly and returns IRQ_HANDLED on normal completions, waking the oneshot thread (apple_mbox_g17_recv_thread) via IRQ_WAKE_THREAD only when the per-IRQ budget (APPLE_G17_MBOX_RX_BUDGET) is saturated so the flood throttle sleep and thread-context uclamp adjustment stay off hard IRQ. Add KUnit test coverage verifying both hard-IRQ dispatch outcomes and that ASCWrap v8 GFX/GFX1 mailboxes remain excluded from apple_mbox_is_g17(). Signed-off-by: Diljit Singh <[email protected]>
5555740 to
4fa08b4
Compare
|
Updated to R2 ( Code & KUnit changes
Multi-SoC scope & hardware verification
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
No blocking code findings. Not ready to merge yet: two hardware rows are missing (listed below). Reviewed head 4fa08b4655.
What I checked:
- Hard-IRQ safety: everything
apple_mbox_g17_recv_irq()reaches already ran with IRQs off underrx_lock. The GPU early-receive callbacks (G17RoleOps, G16rtkit_recv_earlyon M4 Pro/Max, and M5 live boot) only store atomics, callcomplete_all()or queue work.apple_rtkit_rx()is unchanged in this path on currentmain. - Flood handling is intact. Hard IRQ drains at most 64 messages, then returns
IRQ_WAKE_THREAD, and the line stays masked byIRQF_ONESHOTthrough the 1-2 ms sleep. Stop, quiesce and suspend usedisable_irq()/synchronize_irq(), which cover both handlers. - The earlier v8 item is resolved. v8 GFX/GFX1 no longer reaches the hard-IRQ split, the storm guard still runs in
apple_mbox_recv_irq()(drivers/soc/apple/mailbox.c:984), and KUnit covers the exclusion. - Attribution: the commit carries only the human author and Signed-off-by, and the PR body is clean. I removed attribution lines from two comments and from the earlier review.
- CI: 8/8 checks green. The branch merges cleanly into
main8bd46584.
Missing before merge:
- A row at this head. The M5 Pro row (
cdirect5-safe) was built from5555740b. R2 changed built code (apple_mbox_is_g17()), so that row doesn't carry over. T6050 runs the same path as before, so a short rerun on J714s at4fa08b4655is enough. - One row on another Mac with this mailbox. This code is shared by every ASCWrap v6 GPU mailbox (M4 Pro/Max, Neo, M5 and M5 Pro). A run at this head on a Neo (T8140) or an M4 Pro/Max (T6040/T6041) covers it: a GPU CTS subset with 0 faults, 0 warnings and 0 failed units.
Non-blocking: excluding v8 inside apple_mbox_is_g17() changes more than the IRQ handler for T8152 GFX mailboxes:
- the receive budget goes from 64 to unlimited (
mailbox.c:869); - the atomic send timeout goes from 1 ms to 500 ms (
mailbox.c:775); set_rx_util_min()stops being supported (mailbox.c:939).
None of this is reachable in-tree today: the T8152 GPU mailbox nodes are status = "disabled", G18 only sends non-atomic, and v8 receive polls by default. A follow-up could apply the v8 check only to the IRQ registration (mailbox.c:1655) and leave the rest of v8 as it was.
|
Verdict: MERGE at EvidenceRead full diff of `drivers/soc/apple/mailbox.c`, `drivers/soc/apple/mailbox-g17-test.h`, and `include/linux/soc/apple/mailbox.h`. Verified `apple_mbox_g17_recv_irq()` returns `IRQ_WAKE_THREAD` only at `APPLE_G17_MBOX_RX_BUDGET` saturation and `apple_mbox_g17_recv_thread()` applies `rx_util_min` before sleeping. |
Hardware Row — M5 Pro (
|
|
Neo (J700, T8140 / G17P B1) PASS at 4fa08b4 (combined kit 7.3.0-aurora-prneo1a+, default cmdline, Stage 2 b17): GPU mailbox IRQ 78 (482600000.mailbox-recv) rose 167 -> 119390 across all 6 CPUs with 0 storms/spurious IRQs; gpubench-vk 8/8 OK, gl-smoke 32/32 + gpubench-gl 2/2 OK, dEQP-VK short CTS 30/30 PASS, s2idle 1/1 (10 s) + post-sleep GPU PASS, 0 GPU faults/timeouts, 0 failed units, Enforcing + 0 AVC, 0 new GPU/mailbox kernel errors; restored to saved fleet89. |
Commit 4fa08b4 ("soc: apple: mailbox: drain G17 receive interrupts in hard IRQ") moved the ASCWrap v6 GPU receive path out of the oneshot IRQ thread: normal completions are now drained in hard IRQ, and the thread runs only when the receive budget saturates. The thread was doing more than adding a wakeup. It is an RT task, so while it runs schedutil raises its CPU cluster to the top frequency, and the G17 driver steers that through apple_mbox_set_rx_util_min(): Port::rx_update() keeps the RT default for host-bound streams and lowers it only while the GPU is the bottleneck. Since 4fa08b4 the completion of every light submission runs without that boost, from whichever CPU takes the interrupt. On the MacBook Neo (J700, A18 Pro) gpubench-vk compute.light regressed with that commit alone. Built on its own parent with only its merge reverted, 6 reps each: row with reverted 7.3.0-41 compute.light queue/d2 (us) 52.3 35.3 35.5 submit CPU (us) 12.0 9.6 9.7 latency (us) 110 64 64 reps that lose the overlap 6/6 0/6 0/6 compute.light queue/d1 (us) 106.0 102.1 102.3 render.light queue/d1 (us) 137.8 122.1 127.0 Bisected on J700 from 7.3.0-41 (6f618bc, rebuilt with the same toolchain and config as every other point) to 7c9d9ad: the regression first appears in 3989d21..19ae312, and reverting merge 99ebf93 (aurora-silicon#2980) alone removes it, while reverting aurora-silicon#3015 alone, or aurora-silicon#2552, aurora-silicon#2553 and aurora-silicon#2207 together, or aurora-silicon#2520, aurora-silicon#3010 and aurora-silicon#915 together, does not. Restore the threaded receive handler for ASCWrap v6 G17 mailboxes. Keep that commit's exclusion of ASCWrap v8 (T8152) from apple_mbox_is_g17(), so the T8152 GPU mailbox stays on apple_mbox_recv_irq() with its storm guard as it is now, and keep a KUnit case for that exclusion. With "drm/asahi: g17: keep G17P work nodes and compute descriptors firmware-cached" on origin/main 16da002, a one-shot J700 boot gives compute.light d2 34.5 us (submit CPU 9.5 us, 0/9 reps losing the overlap), d1 104.1 us, render.light d1 124.9 us; the multi_queue CTS family 4266/0 three times, compute CRCs 5/5, Geekbench 6 Vulkan 8/8, and no GPU fault, WARN or AVC. Signed-off-by: Diljit Singh <[email protected]>
What: ASCWrap v6 GPU mailboxes (
APPLE_MBOX_ASCWRAP_V6_ROLE_GFXand..._GFX1) registered their recv-not-empty interrupt as a pure threaded IRQ, adding an IRQ-thread wakeup to every GPU completion beforeapple_rtkit_rx()could queue the driver's event work. The receive path is now drained in hard IRQ (apple_mbox_g17_recv_irq()), waking the oneshot thread only whenAPPLE_G17_MBOX_RX_BUDGETis saturated; ASCWrap v8 (apple,t8152-gfx-ascwrap-v8) stays onapple_mbox_recv_irq()with its storm guard.Tested: J714s M5 Pro (G17S B1), Aurora 7.3.0 M5 integration test kernel (build 4) with
apple_mbox_g17_recv_irqlive in/proc/kallsyms: 0 faults/warnings over 402/403 Vulkan CTS, 193/200 occlusion-query CTS and 128/128 OpenGL rows; host completion latency 99.8 → 92.6 us, shallow render submission 70.9 → 61.1 us. Host testsmailbox2/2,sep-suspend22/22 pass.Risk: two-way · Macs with an ASCWrap v6 GPU mailbox: M4 Pro/Max (T6040/T6041), Neo (T8140), M5 (T8142) and M5 Pro (T6050); ASCWrap v8 (T8152) is excluded.
Not yet: a hardware row at the current head; M4 Pro/Max, Neo and M5 (T8142) not run.
Details
All ASCWrap v6 GFX/GFX1 receive handlers already run under
spin_lock_irqsave(&mbox->rx_lock, flags)inapple_mbox_poll_locked()and are strictly hard-IRQ safe:apple_rtkit_rx()performs only atomic FIFO/flag checks,GFP_ATOMICwork allocation,queue_work(), and non-sleepingrecv_message_early()callbacks (AtomicBool stores,complete_all(),mod_delayed_work_on(), and workqueue enqueue), deferring sleeping RTKit callbacks tortk->wq.This change splits the G17 receive path into:
apple_mbox_g17_recv_irq()(hard IRQ): drainsapple_mbox_poll_locked()and returnsIRQ_HANDLEDon normal completions.apple_mbox_g17_recv_thread()(oneshot thread): woken viaIRQ_WAKE_THREADonly whenAPPLE_G17_MBOX_RX_BUDGETis saturated, so the flood-throttle sleep and thread-context uclamp adjustment stay off hard IRQ.hw->is_ascwrap_v8) is excluded fromapple_mbox_is_g17(), so v8 keepsapple_mbox_v8_rx_irq_guard().apple_g17_rx_hardirq_dispatch_testKUnit test covering bothIRQ_HANDLEDandIRQ_WAKE_THREADdispatch paths, and that ASCWrap v8 GFX/GFX1 mailboxes stay excluded.Evidence
scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.mailbox(2/2),sep-suspend(22/22) PASS.G17S B1), built into Aurora 7.3.0 M5 integration test kernel build 4,apple_mbox_g17_recv_irqverified active in/proc/kallsyms: 0 faults/warnings across 402/403 Vulkan CTS (synchronization.smoke,synchronization.op.single_queue.barrier,synchronization.op.multi_queue,compute.pipeline.basic), 193/200 occlusion-query CTS, and 128/128 OpenGL rows; host completion latency improved from 99.8 us to 92.6 us and shallow render submission from 70.9 us to 61.1 us.