Skip to content

soc: apple: mailbox: receive G17 completions in the RT thread again - #3187

Merged
RyanTheTide merged 4 commits into
mainfrom
fix/g17-mailbox-threaded-rx
Dec 1, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
fix/g17-mailbox-threaded-rx

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: Receive ASCWrap v6 G17 GPU completions in the oneshot RT IRQ thread again, as before #2980 (4fa08b46555a, "drain G17 receive interrupts in hard IRQ").

Tested: J700 (A18 Pro, G17P), system Mesa 26.3.0-30.

row at 19ae3124 19ae3124 − #2980 7.3.0-41
compute.light queue d2 (µs) 52.3 35.3 35.5
d2 submit CPU (µs) 12.0–12.9 8.7–9.7 9.5–10.0
d2 latency (µs) / reps that lose the overlap 110 / 6 of 6 64 / 0 of 6 64 / 0 of 6
compute.light queue d1 (µs) 106.0 102.1 102.3
render.light queue d1 (µs) 137.8 122.1 127.0

Risk: two-way door · every Mac whose GPU mailbox is ASCWrap v6 (T6040/T6041, T8140, T8142, T6050); T8152 unchanged.

Not yet:

  • M5 (J714s) row: GPU mailbox IRQ/smoke check (boot, gpubench-vk smoke, 0 mailbox or GPU errors) plus compute.light d1/d2. M5 runs this ASCWrap v6 path too, but its port does not attach the receive clamp.
  • M4 (J773g or J616s) row Done: J773g PASS at e8bb42119bac (soc: apple: mailbox: receive G17 completions in the RT thread again #3187 (comment)).
  • KUnit: the KUnit file was not compiled or run here; the Neo config has no CONFIG_KUNIT.

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 (#2980) alone removes it, while reverting #3015 alone,
or #2552, #2553 and #2207 together, or #2520, #3010 and #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]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 26, 2026 03:30
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at fb0def97: not ready yet

Check Detail
CI at head no failing: apple-build, host-tests, kunit, source, KUnit ane-boot, rust-build
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at f4ffe76e; the changed files are byte-identical at fb0def97
Conflicts ok none
PR text ok Risk: two-way · every Mac whose GPU mailbox is ASCWrap v6 (T6040/T6041, T8140, T8142, T6050); T8152 unchanged.

Areas: area:platform

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J773g (M4 Mac mini, G16G) no-regression row at e8bb42119bac: PASS, with no change on G16.

How it was run: two guarded one-shots on the default cmdline.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at e8bb42119bac100f0171821401b893f6b663f910 once hardware evidence is complete.

Blockers: No code blocker found. Keep this unarmed until the J714s ASCWrap v6 row and exact-head equivalence for the stacked Neo evidence are posted.

Checked: The same immutable role predicate selects the threaded registration and the clamp/sleep branches. Clamp application precedes the receive spinlock; the budget sleep follows unlock while the oneshot line is still masked. The ASCWrap v8 role still bypasses both operations and reaches its existing guard. Read the KUnit v8 exclusion cases, the green head checks, and the exact-head J773g row. The change is mailbox-role based, with no board gating, DT bindings, private material, or attribution added.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 28, 2026
Forward-merge main. apple_mbox_probe() conflicted with 551faaf ("key
the receive-thread clamp on a threaded handler"): main records
mbox->rx_threaded and registers its hard-IRQ drain plus thread pair,
this branch registers apple_mbox_recv_irq() as the only, threaded
handler. Keep rx_threaded from main and register this branch's single
threaded handler when it is set; main's g17 hard-IRQ pair is already
gone with this branch. The receive handler applies the clamp when
rx_threaded is set, which is what apple_mbox_set_rx_util_min() keys on.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Forward-merged main into this branch (merge commit f4ffe76, no force push). apple_mbox_probe() conflicted with 551faaf (rx_threaded). The merge keeps mbox->rx_threaded = apple_mbox_is_g17(mbox) from main and, when it is set, registers your single threaded apple_mbox_recv_irq (NULL hard handler, IRQF_ONESHOT). Main's g17 recv_irq/recv_thread pair stays removed as in your commit. The clamp call in apple_mbox_recv_irq() now checks rx_threaded (the same set as is_g17 after probe), so it matches apple_mbox_set_rx_util_min().
Tests: KUnit apple_mbox_g17_stall on arm64 QEMU (APPLE_MAILBOX + UCLAMP_TASK) passed 4/4, including rx_util_min and v8_excluded.
Still needed for the App's condition: a J714s GPU mailbox IRQ smoke + compute.light d1/d2 and one J700 compute.light d2 at this merge head, then CI and App re-review. Thanks @DjDeveloperr.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at f4ffe76

Checked: The merge keeps rx_threaded aligned with the oneshot IRQ registration. The utilization clamp is reached only on the threaded path, and the saturation delay remains outside rx_lock. Keep the J714s ASCWrap v6 and Neo-equivalence receipts plus CI.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) ci-failing A check failed at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 29, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

f4ffe76 J700 (MacBook Neo, T8140, G17P B1) PASS: combined guarded one-shot 7.3.0-aurora-peer1+ on main 498d53fd (mailbox.c/mailbox.h byte-identical to f4ffe76e0a5e, default cmdline, saved Stage 2 unchanged); G17 mailbox RT IRQ threads active (SCHED_FIFO prio 50: irq/78-482600000.mailbox-recv, irq/80-482e00000.mailbox-recv), gpubench-vk compute.light d1 108.04 us (base 107.48 us) / d2 57.14 us (base 53.87 us), 0 GPU/IRQ faults, s2idle 1/1 (rtc0), Enforcing, 0 AVC, 0 failed units; restored saved 7.3.0-aurora-edge.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 29, 2026
@malik-na

Copy link
Copy Markdown
Member

Reviewed at f4ffe76 (the merge of main into this branch).

I found no correctness problem. The merge only touches the probe/receive wiring, and it keeps the same change as before: ASCWrap v6 GFX/GFX1 get the oneshot threaded receive handler back, and the hard-IRQ handler stays for every other mailbox. The clamp call now checks rx_threaded, the flood sleep checks apple_mbox_is_g17(). Both come from the same value, set once in apple_mbox_probe(), so they select the same mailboxes.

One note, not blocking:

drivers/soc/apple/mailbox-g17-test.h (apple_g17_v8_excluded_test)

The new test can't tell this fix from the regression. It only calls apple_mbox_is_g17(), and that is the same on main and here. apple_g17_rx_util_min_test calls apple_mbox_apply_rx_util_min() directly, so it also passes if apple_mbox_recv_irq() stops applying the clamp. A case that sets up a GFX mailbox with rx_threaded = true and an empty FIFO, calls sched_set_fifo(current) and apple_mbox_set_rx_util_min(&mbox, 256), then calls apple_mbox_recv_irq(0, &mbox) and expects rx_util_min_applied == 256, would fail on main and pass here.

The suite does run in CI, through macsmc.kunitconfig, but without CONFIG_UCLAMP_TASK, so apple_g17_rx_util_min_test is skipped there. The only new test CI actually runs is v8_excluded.

@RyanTheTide

Copy link
Copy Markdown
Contributor

I merged current main into this branch (fb0def97, normal push, no rebase, your commits unchanged). The last CI failures came from main itself on 11-29: the apple-scaler-recovery and g17-compute-owed-stamp fixtures, plus the apple-dcp harness break fixed in #3672. Re-running a job would reuse the old merge commit, so a fresh merge was the only way to clear them. Both merges were conflict-free. Host tests pass on the merged tree. The PR's own code is unchanged from f4ffe76e, so the existing hardware rows still cover it. Next: CI at this head and the review app's verdict.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 30, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

@DjDeveloperr code-owner notice: the review app approved this head, which only merges main in, and the existing rows on two families cover the code. I'll merge it under the 6-point rule once CI is green here, no earlier than 1 h from now. Say hold if you object.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at fb0def97f016 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at fb0def9 that the readiness check found (PR body or comment). CI: linux train L3 = main 429e7e1 + 28 approved PRs (candidate 45c2fa4b): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit dcp-fabric/dcp-topology/dcp-display/macsmc/spi-hid-apple/mt7932/asahi/sep pass; ave failed to build only because of #3153 (unused static helper under -Werror; #3153 held out) and passes with #3153 reverted from the candidate; host tests apple-dcp and apple-scaler-recovery pass. The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit ebd4c9a into main Dec 1, 2026
31 of 60 checks passed
@RyanTheTide
RyanTheTide deleted the fix/g17-mailbox-threaded-rx branch December 1, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants