[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251217212728.1540043-2-tanmay.shah@amd.com>
Date: Wed, 17 Dec 2025 13:27:27 -0800
From: Tanmay Shah <tanmay.shah@....com>
To: <jassisinghbrar@...il.com>, <andersson@...nel.org>,
<mathieu.poirier@...aro.org>
CC: <linux-kernel@...r.kernel.org>, <linux-remoteproc@...r.kernel.org>,
"Tanmay Shah" <tanmay.shah@....com>
Subject: [PATCH v3 1/2] mailbox: check mailbox queue is full or not
Sometimes clients need to know if mailbox queue is full or not before
posting new message via mailbox. If mailbox queue is full clients can
choose not to post new message. This doesn't mean current queue length
should be increased, but clients may want to wait till previous Tx is
done. Introduce variable per channel to track available msg slots.
Clients can check this variable and decide not to send new message if
it is 0. This will help avoid false positive warning from mailbox
framework "Try increasing MBOX_TX_QUEUE_LEN".
Signed-off-by: Tanmay Shah <tanmay.shah@....com>
---
drivers/mailbox/mailbox.c | 3 +++
include/linux/mailbox_client.h | 2 ++
2 files changed, 5 insertions(+)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 2acc6ec229a4..b7ae5c173143 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -36,6 +36,7 @@ static int add_to_rbuf(struct mbox_chan *chan, void *mssg)
idx = chan->msg_free;
chan->msg_data[idx] = mssg;
chan->msg_count++;
+ chan->cl->msg_slot_ro = (MBOX_TX_QUEUE_LEN - chan->msg_count);
if (idx == MBOX_TX_QUEUE_LEN - 1)
chan->msg_free = 0;
@@ -71,6 +72,7 @@ static void msg_submit(struct mbox_chan *chan)
if (!err) {
chan->active_req = data;
chan->msg_count--;
+ chan->cl->msg_slot_ro = (MBOX_TX_QUEUE_LEN - chan->msg_count);
}
}
@@ -321,6 +323,7 @@ static int __mbox_bind_client(struct mbox_chan *chan, struct mbox_client *cl)
chan->msg_count = 0;
chan->active_req = NULL;
chan->cl = cl;
+ chan->cl->msg_slot_ro = MBOX_TX_QUEUE_LEN;
init_completion(&chan->tx_complete);
if (chan->txdone_method == TXDONE_BY_POLL && cl->knows_txdone)
diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h
index c6eea9afb943..a073fb0c03d1 100644
--- a/include/linux/mailbox_client.h
+++ b/include/linux/mailbox_client.h
@@ -17,6 +17,7 @@ struct mbox_chan;
* @dev: The client device
* @tx_block: If the mbox_send_message should block until data is
* transmitted.
+ * @msg_slot_ro: msg slots remaining for this client's channel.
* @tx_tout: Max block period in ms before TX is assumed failure
* @knows_txdone: If the client could run the TX state machine. Usually
* if the client receives some ACK packet for transmission.
@@ -29,6 +30,7 @@ struct mbox_chan;
struct mbox_client {
struct device *dev;
bool tx_block;
+ unsigned int msg_slot_ro;
unsigned long tx_tout;
bool knows_txdone;
--
2.34.1
Powered by blists - more mailing lists