From: Tanmay Shah <tanmay.shah@amd.com>
To: <jassisinghbrar@gmail.com>, <andersson@kernel.org>,
<mathieu.poirier@linaro.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-remoteproc@vger.kernel.org>,
"Tanmay Shah" <tanmay.shah@amd.com>
Subject: [PATCH v3 1/2] mailbox: check mailbox queue is full or not
Date: Wed, 17 Dec 2025 13:27:27 -0800 [thread overview]
Message-ID: <20251217212728.1540043-2-tanmay.shah@amd.com> (raw)
In-Reply-To: <20251217212728.1540043-1-tanmay.shah@amd.com>
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@amd.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
next prev parent reply other threads:[~2025-12-17 21:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 21:27 [PATCH v3 0/2] mailbox queue length check Tanmay Shah
2025-12-17 21:27 ` Tanmay Shah [this message]
2026-01-18 19:53 ` [PATCH v3 1/2] mailbox: check mailbox queue is full or not Jassi Brar
2026-01-30 18:13 ` Shah, Tanmay
2025-12-17 21:27 ` [PATCH v3 2/2] remoteproc: xlnx: do not kick if mbox queue is full Tanmay Shah
2026-01-05 21:21 ` Mathieu Poirier
2026-01-30 18:14 ` Shah, Tanmay
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=20251217212728.1540043-2-tanmay.shah@amd.com \
--to=tanmay.shah@amd.com \
--cc=andersson@kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.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®