soc: apple: mailbox: keep enable_irq() balanced when a send times out - #599
Open
brentkearney wants to merge 1 commit into
Open
soc: apple: mailbox: keep enable_irq() balanced when a send times out#599brentkearney wants to merge 1 commit into
brentkearney wants to merge 1 commit into
Conversation
…fails apple_mbox_send() enables irq_send_empty and waits for the coprocessor to drain the A2I FIFO. Only the interrupt handler disables that interrupt again, so when the wait does not complete -- the FIFO stays full for APPLE_MBOX_TX_TIMEOUT, or the wait is interrupted by a signal -- the interrupt is left enabled and its disable depth is off by one. The next send that finds the FIFO full then calls enable_irq() on an already-enabled interrupt, which warns and underflows the depth counter: Unbalanced enable for IRQ 57 WARNING: kernel/irq/manage.c:774 at __enable_irq+0x4c/0x80, CPU#0 Call trace: __enable_irq+0x4c/0x80 (P) enable_irq+0x74/0xe4 apple_mbox_send+0xb4/0x1b8 Observed on an M1 Pro (apple,t6000) after SEPOS stopped draining its mailbox: of eight consecutive sends that timed out, the last seven each warned with a full backtrace. Track whether the interrupt is enabled in struct apple_mbox under tx_lock and disable it on the failure paths. The flag also settles the race with the handler running just after the wait expired: whichever side takes tx_lock first performs the single disable, and the stale completion is cleared by the reinit_completion() before the next wait. Signed-off-by: Brent <1550934+brentkearney@users.noreply.github.com>
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Balance the send-empty interrupt enable in
apple_mbox_send(), so a send whose wait times out or takes a signal no longer leaves the interrupt enabled. Fixes #598.Problem
apple_mbox_send()enablesirq_send_emptybefore waiting for the A2I FIFO to drain; onlyapple_mbox_send_empty_irq()disables it again.enable_irq()on an already-enabled interrupt, so__enable_irq()warns and underflows the depth counter. Every further stalled send warns again with a backtrace.sep,dcp,dcpext,aop,isp, andnvme.Changes
tx_irq_enabledtostruct apple_mbox, guarded bytx_lock.disable_irq_nosync().Notes for reviewers
tx_lockfirst performs the single disable.reinit_completion()before the next wait, so no send returns early on a stale completion.tx_lock, so it callsdisable_irq_nosync();disable_irq()can sleep.Testing
Runtime-tested on a MacBook Pro 16-inch 2021 (
apple,j316s/apple,t6000, M1 Pro). The stall must be provoked from a healthy SEP: the message that makes SEPOS stop draining only has that effect early in a boot. Later SEPOS reaches a state where it stops answering but keeps draining, so the FIFO never fills and the timeout path is never taken.7.1.6-1-4-ARCH: eight sends timed out and the last seven each printedUnbalanced enable for IRQ 57with a backtrace throughapple_mbox_send+0xb4/0x1b8. Only the first timed-out send is silent, matching the analysis.7.1.6-1-5-ARCH: eight sends filled the A2I FIFO and the next 56 timed out, with zeroUnbalanced enableWARNs.WARNINGline anywhere in the boot, and taint stayed at 4 (arm64Sbaseline,Wclear).