The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v5] mailbox: Make mbox_send_message() return error code when tx fails
@ 2026-05-08  9:02 Joonwon Kang
  2026-05-09  1:08 ` Jassi Brar
  0 siblings, 1 reply; 3+ messages in thread
From: Joonwon Kang @ 2026-05-08  9:02 UTC (permalink / raw)
  To: jassisinghbrar, sudeep.holla
  Cc: dianders, akpm, linux-kernel, stable, joonwonkang

When the mailbox controller failed transmitting message, the error code
was only passed to the client's tx done handler and not to
mbox_send_message() in blocking mode. For this reason, the function could
return a false success. This commit resolves the issue by introducing the
tx status and checking it before mbox_send_message() returns.

This commit works with the premise that the multi-threads' access to a
channel in blocking mode is serialized by clients, not by the mailbox
APIs, since the current mbox_send_message() in blocking mode does not
support multi-threads.

Cc: stable@vger.kernel.org
Signed-off-by: Joonwon Kang <joonwonkang@google.com>
Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
---
v5: Add note to the commit message that the current mailbox APIs in
    blocking mode do not support multi-threads.
v4: Detach it from the previous commit that supports multi-thread in
    blocking mode and rebase it on the latest for-next branch.
v3: No major patch since v1.

 drivers/mailbox/mailbox.c          | 6 +++++-
 include/linux/mailbox_controller.h | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index b00f7a32e866..066702e5a46f 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -98,8 +98,10 @@ static void tx_tick(struct mbox_chan *chan, int r)
 	if (chan->cl->tx_done)
 		chan->cl->tx_done(chan->cl, mssg, r);
 
-	if (r != -ETIME && chan->cl->tx_block)
+	if (r != -ETIME && chan->cl->tx_block) {
+		chan->tx_status = r;
 		complete(&chan->tx_complete);
+	}
 }
 
 static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer)
@@ -295,6 +297,8 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
 		if (ret == 0) {
 			t = -ETIME;
 			tx_tick(chan, t);
+		} else if (chan->tx_status < 0) {
+			t = chan->tx_status;
 		}
 	}
 
diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h
index dc93287a2a01..26a238a6f941 100644
--- a/include/linux/mailbox_controller.h
+++ b/include/linux/mailbox_controller.h
@@ -120,6 +120,7 @@ struct mbox_controller {
  * @txdone_method:	Way to detect TXDone chosen by the API
  * @cl:			Pointer to the current owner of this channel
  * @tx_complete:	Transmission completion
+ * @tx_status:		Transmission status
  * @active_req:		Currently active request hook
  * @msg_count:		No. of mssg currently queued
  * @msg_free:		Index of next available mssg slot
@@ -132,6 +133,7 @@ struct mbox_chan {
 	unsigned txdone_method;
 	struct mbox_client *cl;
 	struct completion tx_complete;
+	int tx_status;
 	void *active_req;
 	unsigned msg_count, msg_free;
 	void *msg_data[MBOX_TX_QUEUE_LEN];
-- 
2.54.0.563.g4f69b47b94-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v5] mailbox: Make mbox_send_message() return error code when tx fails
  2026-05-08  9:02 [PATCH v5] mailbox: Make mbox_send_message() return error code when tx fails Joonwon Kang
@ 2026-05-09  1:08 ` Jassi Brar
  2026-05-10  5:37   ` Joonwon Kang
  0 siblings, 1 reply; 3+ messages in thread
From: Jassi Brar @ 2026-05-09  1:08 UTC (permalink / raw)
  To: Joonwon Kang; +Cc: sudeep.holla, dianders, akpm, linux-kernel, stable

On Fri, May 8, 2026 at 4:02 AM Joonwon Kang <joonwonkang@google.com> wrote:
>
> When the mailbox controller failed transmitting message, the error code
> was only passed to the client's tx done handler and not to
> mbox_send_message() in blocking mode. For this reason, the function could
> return a false success. This commit resolves the issue by introducing the
> tx status and checking it before mbox_send_message() returns.
>
> This commit works with the premise that the multi-threads' access to a
> channel in blocking mode is serialized by clients, not by the mailbox
> APIs, since the current mbox_send_message() in blocking mode does not
> support multi-threads.
>
> Cc: stable@vger.kernel.org
>
Not sure if this should go into stable. It is not a bug fix. See
stable-kernel-rules

Thanks,
Jassi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v5] mailbox: Make mbox_send_message() return error code when tx fails
  2026-05-09  1:08 ` Jassi Brar
@ 2026-05-10  5:37   ` Joonwon Kang
  0 siblings, 0 replies; 3+ messages in thread
From: Joonwon Kang @ 2026-05-10  5:37 UTC (permalink / raw)
  To: jassisinghbrar
  Cc: akpm, dianders, joonwonkang, linux-kernel, stable, sudeep.holla

> On Fri, May 8, 2026 at 4:02 AM Joonwon Kang <joonwonkang@google.com> wrote:
> >
> > When the mailbox controller failed transmitting message, the error code
> > was only passed to the client's tx done handler and not to
> > mbox_send_message() in blocking mode. For this reason, the function could
> > return a false success. This commit resolves the issue by introducing the
> > tx status and checking it before mbox_send_message() returns.
> >
> > This commit works with the premise that the multi-threads' access to a
> > channel in blocking mode is serialized by clients, not by the mailbox
> > APIs, since the current mbox_send_message() in blocking mode does not
> > support multi-threads.
> >
> > Cc: stable@vger.kernel.org
> >
> Not sure if this should go into stable. It is not a bug fix. See
> stable-kernel-rules

Alright, let me remove the Cc tag. Will try merging it to a stable branch
when needed later on.

Thanks,
Joonwon Kang

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-10  5:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08  9:02 [PATCH v5] mailbox: Make mbox_send_message() return error code when tx fails Joonwon Kang
2026-05-09  1:08 ` Jassi Brar
2026-05-10  5:37   ` Joonwon Kang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox