lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABb+yY0b+UOqLgmVz+T-e_zxYJ=sLcMA3um6q8EVOQpnB=L3Hw@mail.gmail.com>
Date: Sun, 18 Jan 2026 13:53:17 -0600
From: Jassi Brar <jassisinghbrar@...il.com>
To: Tanmay Shah <tanmay.shah@....com>
Cc: andersson@...nel.org, mathieu.poirier@...aro.org, 
	linux-kernel@...r.kernel.org, linux-remoteproc@...r.kernel.org
Subject: Re: [PATCH v3 1/2] mailbox: check mailbox queue is full or not

On Wed, Dec 17, 2025 at 3:27 PM Tanmay Shah <tanmay.shah@....com> wrote:
>
> 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);
>
msg_count is protected by a lock and limited within MBOX_TX_QUEUE_LEN,
so how about simply   chan->cl->msg_slot_ro--;

>         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);
>
Similarly   chan->cl->msg_slot_ro++  ?

>                 }
>         }
>
> @@ -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;
>
maybe call it 'tx_slots_available_ro' ?

Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ