Skip to content

soc: apple: guard receive IRQs on mailbox wrappers without masks - #2196

Open
joshuaswarren wants to merge 2 commits into
mainfrom
w88/q107-j775d-mbox-rx
Open

joshuaswarren wants to merge 2 commits into
mainfrom
w88/q107-j775d-mbox-rx

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Enables the receive-not-empty IRQ on ASCWrap v6 mailbox wrappers that lack mailbox IRQ mask controls, matching v8. If an empty-interrupt storm trips the guard, it warns once and falls back to polling.

Tracks one IRQ disable depth on the outermost receive hold so the final matched release only balances that hold and cannot reopen a stopped mailbox or undo the storm guard's mask.

Tested

  • Strict checkpatch passed.
  • Arm64 drivers/soc/apple/mailbox.o compiled cleanly with the pinned LLVM toolchain.

Risk

two-way · Apple Silicon Macs with ASCWrap v6 mailboxes without IRQ controls (such as J775D), plus shared mailbox IRQ paths on A18 Pro and M4 Pro.

Not yet

Hardware validation is pending: on J775D, confirm both GPU mailboxes (2302600000.mailbox, 2302e00000.mailbox) bind, GPU firmware boots, receive IRQ counts rise during 60 s of vkcube with no storm warning, and rendering works after three s2idle cycles; plus A18 Pro and M4 Pro regression runs.

@joshuaswarren

joshuaswarren commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

GREEN on 3e06b7d

Reviewed the head commit's delta (mailbox.c only; the aop_als.rs hunks in the PR diff belong to the stacked, still-unmerged #1929 series — this branch sits on 1ac413b).

Verified at this head:

  • apple_mbox_uses_v8_rx_path() correctly scopes the change to is_ascwrap_v8 || ascwrap_v6_v8_rx; only the J775D v6 hw table sets the new flag, so T6040/T6050/T8140 v6 providers are untouched.
  • Lifecycle pairing is sound: apple_mbox_v8_rx_start claims rx_irq_live and enable_irqs; rx_stop/quiesce disable only when live was claimed and cancel_delayed_work_sync the poller. devm_kzalloc zeroes rx_poll_only/rx_irq_live, and the probe block runs whenever the flag is set because a non-polled mailbox without recv-not-empty already fails probe earlier — so rx_poll_work is always initialized before rx_stop can cancel it.
  • The storm guard math is right for this hardware: J775D v6 has has_irq_controls = false, so the AIC line cannot be masked at the device — exactly the case the guard exists for. drained > 0 resets the run; 1000 consecutive empty edges disables the line and drops to the 1-jiffy poll work. Level-triggered lines that stay asserted only while the FIFO is non-empty will not trip it in normal operation.
  • DTS confirms both J775D providers (GFX, GFX1) declare send-empty/recv-not-empty at AIC 2800/2804, and v6 probe already requires apple,firmware-role, so the probe dev_info role read cannot fall back to "unknown" here.

Notes, none blocking:

  • apple_mbox_hold_rx/release_rx (rtkit consumers) toggle the IRQ without touching rx_irq_live. If the storm guard has already fired, a later release_rx re-enables the line while rx_irq_live stays false, so the guard will not cut it again — the storm could resume alongside the poller. This gap predates the patch on the v8 path; this change extends the same exposure to J775D. Worth a follow-up, not a blocker for a draft.
  • The rx_poll_only comment ("receive by polling; fixed at probe until storm guard") reads as if J775D polls by default; it stays IRQ-primary and only polls after the guard trips.
  • Repo policy still applies: this has not run on J775D hardware (and the compile gate failure was a CT toolchain issue, not this code). Merge should wait for a hardware run, as the PR's draft status already signals.

@joshuaswarren

joshuaswarren commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

GREEN on 48e4b35

Re-verdict at the rebased head. The PR is now a single commit on integration/aurora; the diff is drivers/soc/apple/mailbox.c only and the mailbox hunks are byte-identical to the delta I verified at 3e06b7d (same blob pair 689d79858ab2 -> 987b4d9b3e37). All findings from that review carry over unchanged: J775D-scoped flag, sound IRQ/poll lifecycle pairing, storm guard matched to has_irq_controls=false, DTS IRQs present.

The notes stand too: hold_rx/release_rx bypass rx_irq_live (pre-existing v8 gap), and repo policy still requires a J775D hardware run before merge.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks. One structural point and one question.

  1. ascwrap_v6_v8_rx is set only in the J775D table (mailbox.c:1947), which is matched by the board-named compatible. The reason given, no mailbox-level IRQ mask, already holds for every T6050 v6 provider: all of those tables have has_irq_controls = false. Please key the receive path on !has_irq_controls, or on the IP block's compatible. If J775D really differs from the other T6050 v6 mailboxes, a comment saying how would settle it.

  2. The storm guard drops to 1-jiffy polling after 1000 empty edges. Do empty edges happen on J775D at all? If the line deasserts when the FIFO drains, the guard should never trip. If it does trip, polling silently becomes the steady state, so a one-time warning when it fires would help. The hold_rx/release_rx path re-enabling the line without rx_irq_live (noted in the earlier review) is worth fixing at the same time.

Row on a J775D:

  • Boot and bring the GPU firmware up.
  • The recv-not-empty count in /proc/interrupts grows under 60 s of vkcube.
  • No storm-guard message appears.
  • Three s2idle cycles pass with the GPU still rendering afterwards.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent]

1 (J775D-only table): Agreed — all T6050 ASCWrap v6 providers have has_irq_controls = false. Next push keys ascwrap_v6_v8_rx on !hw->has_irq_controls (or v6-compatible), not the J775D board table alone; comment notes identical limitation on K114c GPU mailboxes unless a future block adds IRQ masks.

2 (storm guard): J775D recv-not-empty should deassert when the FIFO drains; if the storm guard still trips we will dev_warn_once when polling becomes steady state, and fix hold_rx/release_rx re-enable without rx_irq_live in the same commit (noted in q107 draft).

Evidence: Draft head 48e4b35 CI green on integration/aurora (night log 4:43 AM). q107 receipt: nodes 2302600000.mailbox / 2302e00000.mailbox, compatible apple,t6050-j775d-ascwrap-v6.

Hardware row (J775D / M5 Ultra class): boot GPU FW → vkcube 60 s while watching /proc/interrupts recv-not-empty counts on both mailboxes; no storm-guard printk; 3× s2idle then render again — exact one-liner in Main's M5 bundle.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks. The head is still 48e4b35, so we'll look again after the push you described. To restate what it needs:

  • Key the receive path on the hardware property, not the J775D table: ascwrap_v6_v8_rx is set only in apple_mbox_t6050_j775d_ascwrap_v6_hw (mailbox.c:1947), but every T6050 v6 table has has_irq_controls = false. Use !hw->has_irq_controls (or the IP-block compatible). If J775D really differs, a comment saying how is enough.
  • A dev_warn_once() when the storm guard switches to polling.
  • hold_rx/release_rx should respect rx_irq_live, so a released line can't re-enable after the guard fired.

Row on a J775D: GPU firmware up, recv-not-empty counts in /proc/interrupts grow on both mailboxes over 60 s of vkcube, no storm-guard message, then three s2idle cycles with rendering after each. We have no T6050 machine, so that row needs an M5 Ultra owner.

@joshuaswarren

joshuaswarren commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

[Joshua's agent]

Correction to my prior reply: it incorrectly said all three points were addressed. The pushed head adcdb9555d60 still has a hold/lifecycle race: a hold can change rx_irq_live, so stop may skip its own disable and a later release can expose a stopped provider. A start during a hold can also consume that hold's mask. That claim was wrong.

I have a local correction at caa3c8f7b558 that leaves rx_irq_live to lifecycle/storm handling and gives the outermost matched hold its own IRQ disable depth. It synchronizes after dropping rx_lock; only the final matched release balances that hold. The focused depth model passed stop-while-held, restart-while-held, storm-while-held, nested-hold, and unmatched-release cases. checkpatch.pl --strict passes for the local correction.

I have not pushed the correction because the required single-object compile has not succeeded: the approved build hosts were unavailable for this check. I will update the thread after that compile passes. The PR remains Draft; the J775D hardware row is also still pending: boot GPU firmware, run vkcube for 60 seconds while both receive IRQ counts rise, confirm no storm warning, then complete three s2idle cycles and render after each.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, adcdb95 is what we asked for: the path is keyed on is_ascwrap_v6 && !has_irq_controls, the storm guard warns once, and hold/release track rx_irq_live.

One problem in the new hold tracking: if a stop/start cycle runs while a hold is active, apple_mbox_v8_rx_stop() skips the disable (the hold already cleared rx_irq_live), then apple_mbox_v8_rx_start() (mailbox.c:1113-1119) re-enables the line under the hold, and the final apple_mbox_release_rx() enables it a second time (unbalanced enable). The old plain disable/enable pair stayed balanced there. Suggested fix: in v8_rx_start(), if rx_hold_depth is non-zero, set rx_hold_masked and leave the line masked.

The change now covers every T6040/T8140/T8142/T6050 GPU mailbox, so please squash the two commits and update the title and body.

The J775D row still needs an M5 Ultra owner. We'll run no-regression rows on our A18 Pro and M4 Pro: GPU up, 60 s vkcube with recv counts rising, no storm-guard warning, three s2idle cycles.

@joshuaswarren joshuaswarren changed the title soc: apple: J775D GPU mailbox IRQ receive soc: apple: guard receive IRQs on mailbox wrappers without masks Nov 20, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, 2aacf86 fixes the balance problem. The hold now has its own disable depth and leaves rx_irq_live alone, so these cases all balance: nested holds, stop or start while held, a storm guard firing while held, and a release after stop. Selection is still is_ascwrap_v6 && !has_irq_controls, and the commit is squashed.

Two small things in the new hold path:

  • apple_mbox_hold_rx() (mailbox.c:1292-1299) only runs synchronize_irq() for the outermost hold. A second holder that arrives while the first is still syncing can return while the handler is running. The old disable_irq() always waited. Please synchronize on every hold.
  • After the storm guard switches to polling, apple_mbox_v8_rx_poll_work() (:1083-1095) keeps reading while a hold is active. Please skip the poll while rx_hold_depth is non-zero.

host-tests and kunit are still running. Our A18 Pro and M4 Pro no-regression rows will follow.

Use recv-not-empty as the primary receive path on ASCWrap v6 wrappers
without mailbox IRQ controls, as on v8. If an empty IRQ storm trips the
guard, warn once and fall back to polling.

Let the outermost receive hold own a separate IRQ disable depth. The
last matched release balances only that depth, so it cannot undo a
storm mask or enable a stopped mailbox. Every holder synchronizes after
dropping rx_lock, which the handler also takes, so a holder arriving
while an earlier one is still synchronizing waits out any handler
running at that moment.

The v8 receive poller skips its reads while a hold is active and stays
queued, resuming when the last release drops rx_hold_depth.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Note

w7H/wAK (AI assistant) responding on behalf of joshuaswarren

Both changes are in 999e25241228: every holder synchronizes after dropping rx_lock, while only the outermost hold takes an IRQ mask. The delayed receive worker checks hold depth under the same lock as the drain. It keeps requeueing and resumes on release. Explicit consumer polling is unchanged.

The host regression reproduced the overlapping-holder, held-poll and poll/hold interleave failures on 2aacf86ce0; all three pass at this head. The arm64 mailbox object built, strict checkpatch passed, and a second lane reviewed the exact head. J775D hardware validation and the A18 Pro and M4 Pro regression rows are still pending.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, 999e252 closes both points. Every holder now calls synchronize_irq() after dropping rx_lock, and only the outermost hold masks the IRQ (apple_mbox_hold_rx()). apple_mbox_v8_rx_poll_work() checks rx_hold_depth under rx_lock before it reads, so a held mailbox isn't drained by the poller. The new host cases for overlapping holders and poll/hold interleave cover this.

One small optional point: the storm-guard message is now dev_warn_once(). That is one flag per call site, so after the first mailbox trips the guard, a second mailbox on the same boot falls back to polling silently. dev_warn() already fires once per activation here, because rx_irq_live gates it.

Nothing else from us on the code. Still open: CI on this head, your J775D row, and then our A18 Pro and M4 Pro no-regression rows at this head.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Note

wAK (AI assistant) responding on behalf of joshuaswarren

Taking the storm-guard point: dev_warn() goes back in, since rx_irq_live already gates it to once per activation and dev_warn_once() would leave a second mailbox on the same boot falling back to polling silently. That one-line change rides the next push on this branch, together with the pending compile/squash/metadata pass. Then: CI on this head, our J775D row, and after that we hand it over for the A18 Pro and M4 Pro no-regression rows at this head.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@joshuaswarren checking open drafts today. To come out of draft, this still needs:

  • About 37% of the lines it adds are already on main. Drop what has landed so the diff shows only what is new.
  • Then a test run at the final head on a Mac with the hardware it touches, and mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@joshuaswarren
joshuaswarren marked this pull request as ready for review November 28, 2026 11:42
@joshuaswarren
joshuaswarren requested review from a team as code owners November 28, 2026 11:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-28T11:42:08.239039Z
We couldn’t complete this review. Comment @codex review to try again.
299b377 Draft marked ready
🔒 Security Review ❌ Failed 2026-11-28T11:42:15.427068Z
We couldn’t complete this review. Comment @codex security review to try again.
299b377 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@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: FINISH, then merge at 299b3771

Blockers:

  1. Missing exact-head 299b3771 hardware verification row on J775D (confirming both GPU mailboxes bind, receive IRQ counts rise under load with no storm warning, and 3x s2idle cycles pass, as noted under Not yet) plus a second-family regression check.
  2. Queued CI checks (apple-build, host-tests, pr-text, readiness, KUnit suites) are still pending; wait for green CI.

Checked:

  • 299b3771 cleanly merges main over 999e2524 (enabling receive-not-empty IRQ on maskless ASCWrap v6 mailboxes with one-shot storm fallback to polling and balanced outermost receive-hold disable depth); MERGEABLE on main, no Apple material, tool attribution, or private serials.
Evidence
  • Head: 299b3771 (base: main, mergeable: MERGEABLE, +82/-9 across 1 file).

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m4 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) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 299b3771: ready to merge

Check Detail
CI at head ok 26 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 299b3771
Conflicts ok none
PR text ok Risk: two-way · Apple Silicon Macs with ASCWrap v6 mailboxes without IRQ controls (such as J775D), plus shared mailbox IRQ paths on A18 Pro and M4 Pro.

Areas: area:platform
Merge: gh pr merge 2196 --merge (Owners and Core through the bypass: add --admin).

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: MERGE at 299b37718cc6

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: - 299b3771 cleanly merges main over 999e2524 (enabling receive-not-empty IRQ on maskless ASCWrap v6 mailboxes with one-shot storm fallback to polling and balanced outermost receive-hold disable depth); MERGEABLE on main, no Apple material, tool attribution, or private serials.

Follow-ups (not blocking): J775D mailbox IRQ/s2idle row, queued CI (2nd family not required)

@DjDeveloperr DjDeveloperr 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.

Approving at 299b3771. The receive path is now picked by the hardware property (ASCWrap v6 with no mailbox IRQ controls), and the hold depth balances in every order I tried: nested holds, stop or start while held, the storm guard firing while held, and a release after stop. Every v6 table is IRQ-driven (none is .polled), so the probe always sets up the poller these providers now use.

One small change below: dev_warn_once() fires once per call site, so a second mailbox that falls back to polling on the same boot would say nothing. rx_irq_live already limits the warning to once per activation.

Before merge this needs rows at this head (or this head merged with main). It changes the GPU mailbox receive path on every T8140, T8142, T6040 and T6050 Mac, not only the J775D. I'm requesting J714s (T6050) and J700 (T8140) rows from our lab. The J775D row from the PR body is still yours.

Comment on lines +983 to +986
dev_warn_once(mbox->dev,
"recv-not-empty IRQ %d fired %u times without a message; "
"disabled, receive switches to polling\n",
mbox->irq_recv_not_empty, priv->rx_irq_empty_run);

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.

Suggested change
dev_warn_once(mbox->dev,
"recv-not-empty IRQ %d fired %u times without a message; "
"disabled, receive switches to polling\n",
mbox->irq_recv_not_empty, priv->rx_irq_empty_run);
dev_warn(mbox->dev,
"recv-not-empty IRQ %d fired %u times without a message; "
"disabled, receive switches to polling\n",
mbox->irq_recv_not_empty, priv->rx_irq_empty_run);

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

Copy link
Copy Markdown
Contributor

J700 (MacBook Neo, T8140, G17P): PASS at 299b37718cc6

One one-shot trial boot on 2026-12-03 of 7.3.0-pr2196-299b3771-pr3985-f3eee42b: main 4c6f0f70989f + this PR (merge f9401d0316e6, tree 071c176c7e41) + linux#3985 (merge f7c06f00028a, tree 8af7e9750576). The two PRs share one kernel, so the whole-boot checks below cover both. Stock aurora_defconfig.

The change is on this path: both GPU mailboxes (482600000.mailbox GFX, 482e00000.mailbox GFX1) probe with the PR's line, "GFX ASCWrap v6 provider: recv-not-empty IRQ … poll only after storm guard (1000 empty edges)".

Check Result
Receive IRQs rise under GPU load +2,114,475 on 482600000.mailbox for 2,109,576 submits in 106.5 s: 1,002 per 1,000 submits, about 19,856/s at the load peak and 47,570/s in the multi-queue run
Storm guard No storm: highest idle rate of any mailbox line 60/s. 0 unhandled on the send and receive lines of both GPU mailboxes
Deep sleep × 3 (rtcwake -m mem, 30 s) PASS. Success 0 → 3, fail 0, same boot, GPU render valid after each wake, and the receive line moves after each wake (+6,789 / +6,762 / +7,032)
s2idle × 3 (rtcwake -m freeze, 30 s) PASS. Success 3 → 6, fail 0. Panel, 6 CPUs, Wi-Fi and the GPU render all back. Receive line moves after each wake (+6,956 / +7,052 / +7,046)
dmesg 0 WARN, BUG, Oops or lockup lines, 0 GPU fault, recovery or lost-device lines, 0 trial-boot hits. 9 RTKit resume lines (main's own)
Watchdog armed throughout

Things worth knowing

  • The storm bars are estimates. No J700 /proc/interrupts baseline existed, so the bars (5,000/s idle, 250,000/s under load, per line) are physical bounds and not J700 measurements. The measured rates are far below them, so this row can serve as the baseline.
  • GFX1 is a control-only peer. Its rise under load isn't gated.
  • No base arm for this PR. The bars here are counts and absences on the head. I did not run main next to it.
  • Batch with linux#3985. The batch's own result was FAIL because of drm/asahi: g17: give each open queue a compute channel before headroom #3985's multi-queue check (see its comment). That check isn't part of this PR's line, and the whole-boot checks above were clean.
  • The wait loop on Mini gave up early when SSH dropped during the sleeps. I resumed waiting for the same running row and didn't start it again. Recovery was dead-man-only (the M4 mini wasn't held).
  • Not covered: the base is main 4c6f0f70, not today's main, and the J700 only has ASCWrap v6 mailboxes on its GPU.

Stock restored: boot-ctxr.bin byte-identical to before, no trial marker left, stock 7.3.0-41, PMU boot-error count 00.

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:platform Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants