Skip to content

soc: apple: mailbox: receive ASCWrap v8 mailboxes by interrupt - #1851

Open
DjDeveloperr wants to merge 4 commits into
mainfrom
djdev/mailbox-v8-irq
Open

DjDeveloperr wants to merge 4 commits into
mainfrom
djdev/mailbox-v8-irq

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What: The T8152 ASCWrap v8 GPU mailboxes receive by their recv-not-empty interrupt, like the other ASC mailboxes, instead of the one-jiffy receive poller. This removes the v8 receive poller, the poll-only default, the storm guard, the sleeping poll of a full TX FIFO and the apple_mailbox.ascwrap_v8_rx_irq parameter (nothing in the tree sets it). A v8 receive interrupt that reads nothing (PSD not powered, or an empty FIFO) returns IRQ_NONE, so the IRQ core disables a line that keeps firing that way: v8 has no mailbox-level acknowledge. Every write of mbox->active stays WRITE_ONCE(), since the nowait paths read it without the lock. The receive interrupt is enabled only when a consumer starts the mailbox; the G18 backend does that only after the PSD services read powered. Main now allows the v8 CPU control by default (ascwrap_v8_cpu_control), so on the default command line the receive interrupt is used whenever the GPU mailboxes run. Comment-only updates in t8152-j873-gpu.dtsi and g18/boot/mod.rs.

Tested: sithglan's J873g (Mac mini M6, T8152) A/B row on 11-24 with 53870b65 cherry-picked onto main 065904c1: PASS. The 75 s EGL/GLES + compute smoke loop and vulkaninfo ran clean, the GFX and GFX1 recv interrupt counts rose (the polled baseline shows 0), with no storm, unbalanced-IRQ or GPU-timeout messages. That row predates 274e2d3d, which merges current main and adds the IRQ_NONE return and the WRITE_ONCE() writes, so a J873g row at this head is requested.

Risk: two-way · T8152 (J873g, J804) GPU mailboxes only. Every changed runtime path is under is_ascwrap_v8; other ASC mailboxes keep their code.

Not yet: J873g row at this head (boot, GPU mailbox recv interrupt counts rise in /proc/interrupts, GPU smoke, no storm, unbalanced-IRQ or GPU-timeout messages).

ASC mailboxes are interrupt driven. The T8152 GPU ASCWrap v8 mailboxes
now receive and send the same way as the other ASC mailboxes do:

 - the recv-not-empty line, the threaded and oneshot GPU receive
   interrupt, is enabled by apple_mbox_start() and disabled by
   apple_mbox_stop();
 - its handler drains the post-office RX FIFO until it is empty, one
   receive budget per pass;
 - a non-atomic sender that finds the TX FIFO full waits for the
   send-empty interrupt and its completion. Both GPU mailbox nodes
   describe that line.

Remove the receive poller, the poll-only default, the storm guard and
the sleeping poll of a full TX FIFO, with the provider state and the
start, stop and removal paths that only served them. Remove the
ascwrap_v8_rx_irq module parameter: interrupts are the only mode, and
nothing in the tree sets it. A leftover
apple_mailbox.ascwrap_v8_rx_irq= is ignored, silently when the driver
is built in and with an "unknown parameter" warning when it is a
module, so a command line that still passes it keeps booting.
The J873 GPU dtsi and the G18 boot notes no longer mention it.

Keep what is not about polling: the wrapper, iop-vbar, post-office and
PSD windows, the ascwrap_v8_cpu_control parameter and the CPU start and
stop it gates, and the PSD check before every post-office receive. When
that check finds the block unpowered, the receive handler reads nothing.

The receive interrupt is enabled only when a consumer starts the
mailbox; the G18 backend does that only after the PSD services are
powered, and only with ascwrap_v8_cpu_control=1.

This has not been run on a T8152 board yet: the receive and send-empty
interrupt assignment of both GPU mailboxes needs a hardware check
before this is relied on.

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

Copy link
Copy Markdown
Contributor

Blockers: 1.

  1. drivers/soc/apple/mailbox.c:773-780 with :842-864: the receive handler now has no path that stops a level line it cannot service. When the PSD check fails, apple_mbox_poll_locked() returns before it reads the FIFO, and apple_mbox_recv_irq() still returns IRQ_HANDLED. The line stays asserted (nothing drained it, and v8 has no mailbox-level ack, has_irq_controls is false), the oneshot thread unmasks it on return, and it fires again at once. Nothing bounds that loop: the storm guard is removed, the 1 ms backoff at :862 only runs when consumed == APPLE_G17_MBOX_RX_BUDGET (here it is negative), and because the handler always says HANDLED the core's spurious-IRQ detector never disables it. The same goes for a recv-not-empty line that turns out to be wired differently on hardware, which this commit has not checked yet. Keep the guarantee the old guard gave without the poller: for ASCWrap v8, return IRQ_NONE from apple_mbox_recv_irq() when nothing was consumed (PSD unpowered or an empty FIFO), so note_interrupt() disables a stuck line, or disable_irq_nosync() the line on the PSD-unpowered path and re-enable it from apple_mbox_start()/apple_mbox_restore().

Nit: :1102 changes WRITE_ONCE(mbox->active, false) to a plain store. On current integration/aurora, apple_mbox_send_nowait()/apple_mbox_recv_nowait() (from 893e51c) read mbox->active without the lock through READ_ONCE, so keep WRITE_ONCE here and in apple_mbox_start() at :990.

Checked: the merge with current integration/aurora is clean and leaves no users of the removed poller symbols; dropping the ascwrap_v8_rx_irq parameter is right; #1844 is merged, so only this commit is under review. CI is green. The PR body ends with "Generated with Claude Code"; it should end with an Assisted-by: LLM (...) line.

HW row: T8152 (J873) on this head, merged on current integration/aurora, default command line apart from the existing ascwrap_v8_cpu_control=1: GPU mailbox recv-not-empty counts in /proc/interrupts rise with GPU traffic and stay flat when idle; a GPU smoke test passes; a stop/start of the mailboxes (GPU idle/resume) is clean; no "nobody cared", unbalanced enable/disable or GPU timeout lines; 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

#1844 is merged, so the PR is now only its last commit. 110861f still has the v8 receive poller, the storm guard and the ascwrap_v8_rx_irq parameter. The commit applies cleanly on 110861f. @DjDeveloperr, two things are still open: the blocker from the review (bound a stuck receive line on ASCWrap v8, for example by returning IRQ_NONE when nothing was consumed, and keep WRITE_ONCE on mbox->active), and the T8152 hardware row. #2489 and #2196 also change mailbox.c, so whichever lands later may need a small rebase.

Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches; CHECK_DTBS over every Apple DTB: no new warnings against the tip.

@sithglan

Copy link
Copy Markdown
Contributor

J873g (Mac mini M6, T8152, G18G B1, firmware J873G18G26B123) A/B row: PASS.

  • Baseline: aurora-silicon/linux main 065904c137fa (7.3.0-aurora-j873-main+, poll-only receive default; #1844 788441e0 already merged in main).
  • Trial: 065904c137fa + cherry-pick of 53870b65201b (soc: apple: mailbox: receive ASCWrap v8 mailboxes by interrupt, clean 0-conflict apply, 7.3.0-aurora-j873-pr1851+), guarded one-shot aura-try (aura main 1.0.0b17-gf52d8324), same .config and cmdline (apple_mailbox.ascwrap_v8_cpu_control=1, no ascwrap_v8_rx_irq).
  • Userspace: Debian testing (SELinux disabled), Mesa aurora-wip 876b22c82bd (26.3.0~aurora.wip.z20261124.876b22c82bd-1).
  • Smoke: 75 s headless EGL/GLES 3.1 loop (smoke1851) running a 1920x1080 RGBA8 FBO draw + 4096-element SSBO compute shader dispatch (glDispatchCompute(64, 1, 1)) + glFinish() every iteration with periodic pixel & SSBO readback verification, followed by vulkaninfo --summary (Apple M6 G18G B1, Borealis Vulkan 1.4.363).
Arm Smoke (75 s) 582600000.mailbox-recv (GFX, IRQ 57) 582600000.mailbox-send (IRQ 58) 582e00000.mailbox-recv (GFX1, IRQ 59) 582e00000.mailbox-send (IRQ 60) G18_JOB_LATENCY max (job / submit)
Baseline (065904c137fa, polled) 85,573 iters, 427/427 checks, 0 mismatches, glError=0x0 0 -> 0 -> 0 -> 0 0 -> 0 0 -> 0 -> 0 -> 0 0 -> 0 5355 us / 117590 us
Trial (+ 53870b65201b, IRQ) 84,244 iters, 421/421 checks, 0 mismatches, glError=0x0 6,926 -> 10,526 (15 s idle) -> 179,285 (smoke, +168,759) -> 182,885 (15 s idle) 0 -> 0 229,434 -> 344,392 (15 s idle) -> 891,716 (smoke, +547,324) -> 1,006,697 (15 s idle) 0 -> 0 4203 us / 34966 us

Checks & notes:

  • apple-mailbox init on trial logs GFX and GFX1 ASCWrap v8 provider ...; CPU control allowed (no poll-only fallback).
  • Zero mailbox storm messages, zero unbalanced IRQ enable/disable warnings, zero spurious / "nobody cared" messages, zero GPU timeouts or recoveries, 0 failed systemd units.
  • Idle IRQ note: neither receive line is stuck or spurious — idle interrupts match actual G18_MSG (ep=0x20 type=0x0042) firmware messages 1:1:
    • 582600000.mailbox-recv (GFX): 240.0 IRQs/s idle (+3,600 per 15 s, +1,200 per 5 s), matching G18_MSG role=GFX (ordinal 4096 -> 8192 in 17.07 s = 240.0 msg/s), rising to ~2,250 IRQs/s during GPU smoke.
    • 582e00000.mailbox-recv (GFX1): ~7,665 IRQs/s idle (+114,958 / +114,981 per 15 s, +38,098 per 5 s), matching G18_MSG role=GFX1 (ordinal 131072 -> 262144 in 17.07 s = 7,678 msg/s, 524288 -> 1048576 in 68.21 s = 7,686 msg/s), vs ~2,000 msg/s when paced by the baseline poller. CPU usage remained low (~0.5% on rtkit-580000000.gpu kworker, loadavg 0.43).
  • Trial trypr1851 cleaned up; M6 restored to default 7.3.0-aurora-j873-main+ (0 failed units).

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 30, 2026 20:46
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 30, 2026 20:46
@github-actions github-actions Bot added area:bringup Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merge readiness at d1f89b3a: not ready yet

Check Detail
CI at head no failing: host-tests
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head no no line with the head SHA d1f89b3a, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · T8152 (J873g, J804) GPU mailboxes only. Every changed runtime path is under isascwrapv8; other ASC mailboxes keep their code.

Areas: area:bringup, area:gpu, area:platform

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

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

@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: REQUEST CHANGES at 53870b65

Blockers:

  1. Unbounded level-IRQ storm hazard on ASCWrap v8 (drivers/soc/apple/mailbox.c). With the v8 receive poller and storm guard removed, apple_mbox_recv_irq() still returns IRQ_HANDLED even when apple_mbox_poll_locked() returns early on an unpowered PSD or drains zero messages. Because ASCWrap v8 has has_irq_controls = false (no mailbox-level ack/mask), the oneshot thread immediately unmasks the asserted level line and spins indefinitely while preventing the IRQ core's spurious-IRQ detector (note_interrupt()) from disabling it. Return IRQ_NONE when nothing is consumed on ASCWrap v8 (or disable the line on the unpowered-PSD path and re-enable on start/restore).
  2. Data race on mbox->active in apple_mbox_stop_locked() and apple_mbox_quiesce(). Both paths replace WRITE_ONCE(mbox->active, false) with a plain mbox->active = false store, even though apple_mbox_send_nowait() and apple_mbox_recv_nowait() read mbox->active locklessly via READ_ONCE(). Keep WRITE_ONCE() on all writes to mbox->active.

Checked:

  • Full 3-file diff (t8152-j873-gpu.dtsi, drivers/gpu/drm/asahi/g18/boot/mod.rs, drivers/soc/apple/mailbox.c, +23/-262), MERGEABLE against main, 11 CI checks passed.
  • J873g (T8152 G18G B1) A/B hardware smoke row from 2026-11-24 passed (84,244 iterations, 421/421 checks, IRQ counts rising cleanly under load).
Evidence
  • Both blockers were previously flagged on 2026-11-21 and 2026-11-23 and remain unaddressed at head 53870b65.
  • Note: after fixing the two code blockers, please re-run a quick J873g verification at the new head SHA.

…ds nothing

ASCWrap v8 has no mailbox-level acknowledge. With the receive poller
and its storm guard gone, a recv-not-empty line that fires while the
PSD is not powered, or with an empty FIFO, fires again as soon as the
handler returns IRQ_HANDLED, and nothing ever stops it. Return IRQ_NONE
for a v8 receive interrupt that read nothing, so the IRQ core's
spurious-interrupt check disables a line that keeps firing that way.

Keep WRITE_ONCE() on every write of mbox->active: the nowait send and
receive paths read it without the lock.

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

Copy link
Copy Markdown
Contributor Author

Both review points are fixed at 274e2d3d, which also merges current main. A v8 receive interrupt that reads nothing (PSD not powered, or an empty FIFO) now returns IRQ_NONE, so the IRQ core disables a line that keeps firing. Every write of mbox->active uses WRITE_ONCE() again. The J873g row needs a rerun at this head.

@github-actions github-actions Bot added blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 2, 2026
main flipped the ASCWrap v8 CPU control default to allow; this branch
drops the v8 receive poller and its parameter. The provider message
keeps main's "allowed (default)" wording without the receive part.

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

DjDeveloperr commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged main 06fceca into the branch at d1f89b3a with a normal push. One conflict, in the ASCWrap v8 provider dev_info() in mailbox.c. Main had flipped ascwrap_v8_cpu_control to default to allowed, and this branch drops the receive parameter, so the line keeps main's "allowed (default)" / "refused" wording without the receive part. The g18/boot/mod.rs comment change and the DT change merged cleanly. Nothing else on main uses ascwrap_v8_rx_irq.

Check: the merged mailbox.c, against main's include/linux/soc/apple/mailbox.h, compiles for arm64 (clang, the tree's own flags plus the W=1 warning set) with 0 warnings and 0 errors, the same as main's mailbox.c.

Still needed before merge: an independent review of 274e2d3d's IRQ_NONE change and this merge, and the J873g row again at this head.

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Dec 2, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verdict: MERGE at d1f89b3a, after the hardware row below.
Blockers: none. Both earlier points are fixed.
Checked: a v8 receive interrupt that reads nothing (PSD not powered, empty FIFO, no receiver) now returns IRQ_NONE from the hard handler (drivers/soc/apple/mailbox.c:927), so the IRQ core's spurious-interrupt check disables a line that keeps firing. Every write of mbox->active is WRITE_ONCE(). With v8 on the common path, start, stop, quiesce and hold/release keep the receive IRQ's enable and disable balanced (it is requested IRQF_NO_AUTOEN). Mailboxes other than v8 behave as before. No Apple material, no gates, and a parameter goes away rather than a new one. The merge resolves its one conflict, the v8 provider dev_info(), by keeping main's "allowed (default)" wording without the receive part. That is right.

Still owed before merge: the J873g row at this head: boot, receive counts rise under GPU load and stay flat at idle, a GPU smoke test, and no "nobody cared", unbalanced-IRQ or GPU-timeout lines. The 11-24 row predates the IRQ_NONE change. CI is still queued.

I updated the body for main's new ascwrap_v8_cpu_control default. I also took the head SHA off the "still needed" line of my earlier comment, because the readiness check had read it as a row. No J873g row has run at this head yet.

Evidence
  • d1f89b3a matches a clean git merge-tree --write-tree of its parents everywhere except mailbox.c, the one conflicted file. The earlier merge 19f653b0 matches a clean merge exactly.
  • Read the full diff against main, plus apple_mbox_recv_irq(), apple_mbox_poll_locked(), apple_mbox_start(), apple_mbox_stop_locked(), apple_mbox_quiesce() and the probe's IRQ requests at this head. The v8 handler is not threaded (rx_threaded is G17 only), so note_interrupt() sees its return value directly.
  • Only apple,t8152-gfx-ascwrap-v8 sets is_ascwrap_v8, so the runtime change reaches only the T8152 GPU mailboxes.
  • Nit for a follow-up: t8152-j873-gpu.dtsi:26 still says CPU control is refused unless ascwrap_v8_cpu_control=1, but main has flipped that default.

@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) labels Dec 2, 2026

@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 d1f89b3

Checked: The ASCWrap v8 handler now reports an unhandled interrupt when it reads no messages, including when the power check prevents a receive. The active-state writes use WRITE_ONCE() and the lockless users read with READ_ONCE(). Start, stop and quiesce use the shared receive-IRQ lifecycle. The DT and G18 boot changes are comments only. The earlier two review findings are resolved.

Checked: I ran the existing Centauri host test on the exact PR head and its target base 06fceca4. The fixture and all three input files are byte-identical. Both runs report the same missing dev_warn_ratelimited and cen_rx_consume declarations. Current main f52ba21d includes the Centauri fixture fix and passes all three production checks. Hosted log Landed fixture fix

Follow-ups: The DT comment above the GPU mailbox nodes still describes v8 CPU control as opt-in. The driver defaults to allowing it. The earlier J873g row covers the earlier head, with current-head verification tracked in readiness.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The ASCWrap v8 receive handler reports an empty or inaccessible FIFO as unhandled, allowing the IRQ core to stop a stuck line. The merge preserves the current CPU-control default and leaves the other mailbox paths alone. The J873g interrupt-mode row at this head is still pending.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026

This branch has not been deployed

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

Labels

area:bringup Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m5 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-hw-row No hardware row at the PR head (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants