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

Lee Jones lee at kernel.org
Thu Dec 3 00:28:08 PST 2026


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 at vger.kernel.org
Signed-off-by: Lee Jones <lee at kernel.org>
---

Cc: Chen-Yu Tsai <wens at kernel.org>
Cc: Jassi Brar <jassisinghbrar at gmail.com>
Cc: Jernej Skrabec <jernej.skrabec at gmail.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-sunxi at lists.linux.dev
Cc: Philipp Zabel <p.zabel at pengutronix.de>
Cc: Samuel Holland <samuel at sholland.org>

 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




More information about the linux-arm-kernel mailing list