[PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown

From: Lee Jones

Date: Thu Dec 03 2026 - 03:28:54 EST


sun6i_msgbox_shutdown() disables the channel receive interrupt and
immediately flushes the receive FIFO and returns to mbox_free_channel()
without waiting for an already-executing sun6i_msgbox_irq() on another
CPU. Both contexts can concurrently read MSG_DATA_REG(n) and underflow
the FIFO, and the ISR can invoke mbox_chan_received_data() after the
client is torn down.

Call synchronize_irq(mbox->irq) after disabling the channel receive
interrupt and before flushing the FIFO.

Fixes: 25831c44b0b7 ("mailbox: sun6i-msgbox: Add a new mailbox driver")
Closes: https://sashiko.dev/#/bug/linux-bdac10dc-aab3-41b2-a13a-eb012e1fd2f9
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---

Cc: Chen-Yu Tsai <wens@xxxxxxxxxx>
Cc: Jassi Brar <jassisinghbrar@xxxxxxxxx>
Cc: Jernej Skrabec <jernej.skrabec@xxxxxxxxx>
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-sunxi@xxxxxxxxxxxxxxx
Cc: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Cc: Samuel Holland <samuel@xxxxxxxxxxxx>

drivers/mailbox/sun6i-msgbox.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/mailbox/sun6i-msgbox.c b/drivers/mailbox/sun6i-msgbox.c
index 4c5669035420..0d941b2bda6a 100644
--- a/drivers/mailbox/sun6i-msgbox.c
+++ b/drivers/mailbox/sun6i-msgbox.c
@@ -148,6 +148,9 @@ static void sun6i_msgbox_shutdown(struct mbox_chan *chan)
mbox->regs + LOCAL_IRQ_EN_REG);
spin_unlock(&mbox->lock);

+ /* Wait for any in-flight ISR to finish before flushing. */
+ synchronize_irq(mbox->irq);
+
/* Attempt to flush the FIFO until the IRQ is cleared. */
do {
while (sun6i_msgbox_peek_data(chan))
--
2.56.1.911.g883d8bcb20-goog