From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796286511; b=Xfmq6XRKhRoLolhRf97afvznkYs1V8I2ER9hh2NgmbLxRefu9Kk3u2YyRSo4rPnLLJDy oOrlKYc74obWboGs7D3ph7djq+fv/wdidEIB1hU/FzWHu7NAGIlkFaNqZfE1LpiJpuKcF VKy0jczxH7lxm6E/R9e0uiiF0VtzytmqOqf7Y5Obnr1z7JflNigc44DlK+7R23c/BPeEp tFgRLD7Up+ZhhIHCKH0BTKk3ZKm8xPrYFZDtTSlno8zsH5une66jMngF4FBqEwwLhbzEu fVdQR3tIHOuhb4pp0LVzld2E6WYmEz06fiTsyuXAv87+If+gXzDBgCM+I4SqEIBQdcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796286511; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=AMtrj1s+Ea9N0NJyGrmikOVvUHqulkVuJ8Lth7CY/OQ=; b=rQAs10x7db3uzBZ2PiVps2rwbw51xeuksYJbfLlVyQw3T6tGimzMzfZ/O5fsGdIUggz/ N7VVfZh7uoZyNHk8Vw8z9hQZ4BEq42rSa1ZMFPKzeOV3SyHp7srkV9YbuXsVOK12Ulm9K odr6IhF4XxmemJW48L4jpfVB0TT/Q4tW8tFVy2JzD9VI34B88U1pTO+PNu5blkEVTq4DR HehTdCZ+HxdKGQABI76jDWJOdaNDKsJGalT8lS4R/HvFekt9d1jDP/1lqq6a8NbqVvCbg PyVoeNxd54TqUxYDVzeKYDtfdsP+VIIxf3XSpQOL7vFp8pkMsq8qUxlpg8iIV4si8BA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YbKLF8w+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59275606A33A; Thu, 3 Dec 2026 08:28:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YbKLF8w+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C36D1F0089F; Thu, 3 Dec 2026 08:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796286511; bh=AMtrj1s+Ea9N0NJyGrmikOVvUHqulkVuJ8Lth7CY/OQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YbKLF8w+EIL3DT0z+MS+4dITMNCzzObrdjfrhHAPLR04ocmz/3HkWhB8rjr8siVTV 0Kxj913cmva02RIenTDg6i5mLUdarvYE6ZkxU8uCWFHBNcfRKsZMCfQ7YYplQ+nxs6 mVJWF7oke1dti0ok5eeljIr1fPepcdFn+YLv+uaeTUG3Lgd53kxykFdowP5T1WdbWl p3YjuBWoYQn5KRqsTDzJNThWcxCWdBaSxZt8As5DMIO4/UFH6ujPhCEDgceqS6DO6m e14kle9Wj1xmRw+Gu72PneIm99UytfVMhdOX3Jarkfl/I+VunsIWvpzyY5nD5A1l2M hBGuKGQ/+7zcw== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Chen-Yu Tsai , Jassi Brar , Jernej Skrabec , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Philipp Zabel , Samuel Holland Subject: [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Date: Thu, 3 Dec 2026 08:28:08 +0000 Message-ID: <3de6323c3365658d81976170b9ea1460d9033f39.1796286447.git.lee@kernel.org> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Cc: Chen-Yu Tsai Cc: Jassi Brar Cc: Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org Cc: linux-sunxi@lists.linux.dev Cc: Philipp Zabel Cc: Samuel Holland 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