mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Chen-Yu Tsai <wens@kernel.org>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Samuel Holland <samuel@sholland.org>
Subject: [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown
Date: Thu,  3 Dec 2026 08:28:08 +0000	[thread overview]
Message-ID: <3de6323c3365658d81976170b9ea1460d9033f39.1796286447.git.lee@kernel.org> (raw)
In-Reply-To: <cover.1796286447.git.lee@kernel.org>

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

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


  parent reply	other threads:[~2026-12-03  8:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03  8:28 ` [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure Lee Jones
2026-12-03 10:38   ` Konrad Dybcio
2026-12-03  8:28 ` [PATCH 02/10] mailbox: ti-msgmgr: Use unsigned IDs in ti_msgmgr_of_xlate() Lee Jones
2026-12-03  8:28 ` [PATCH 03/10] mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave Lee Jones
2026-12-03 14:32   ` Rahul Pathak
2026-12-03 15:05     ` Lee Jones
2026-12-03  8:28 ` [PATCH 04/10] mailbox: riscv-sbi-mpxy: Validate shmem bounds in message send helpers Lee Jones
2026-12-03  8:28 ` [PATCH 05/10] mailbox: bcm-pdc: Unregister mailbox controller before destroying DMA pools Lee Jones
2026-12-03  8:28 ` [PATCH 06/10] mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR use-after-free Lee Jones
2026-12-03 10:39   ` Konrad Dybcio
2026-12-03  8:28 ` [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Lee Jones
2026-12-03 13:43   ` Chen-Yu Tsai
2026-12-03  8:28 ` Lee Jones [this message]
2026-12-03 13:49   ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Chen-Yu Tsai
2026-12-03  8:28 ` [PATCH 09/10] mailbox: arm_mhu_db: Initialise channel registers before controller registration Lee Jones
2026-12-03  9:40   ` Sudeep Holla
2026-12-03  8:28 ` [PATCH 10/10] mailbox: ti-msgmgr: Return -EIO on queue error in ti_msgmgr_send_data() Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3de6323c3365658d81976170b9ea1460d9033f39.1796286447.git.lee@kernel.org \
    --to=lee@kernel.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=p.zabel@pengutronix.de \
    --cc=samuel@sholland.org \
    --cc=stable@vger.kernel.org \
    --cc=wens@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®