From: Sudeep Holla <sudeep.holla@kernel.org>
To: Douglas Anderson <dianders@chromium.org>
Cc: Jassi Brar <jassisinghbrar@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mailbox: Only reset txdone_method to POLL if controller supports polling
Date: Wed, 4 Nov 2026 15:30:58 +0000 [thread overview]
Message-ID: <20261104-amazing-azure-malamute-a82ab3@sudeepholla> (raw)
In-Reply-To: <20261103164235.1.Ica21c7a396cf407fca02b7c0fb3a16150feaab90@changeid>
On Tue, Nov 03, 2026 at 04:42:36PM -0800, Douglas Anderson wrote:
> In mbox_controller_register(), a mailbox controller's default
> txdone_method is initialized to MBOX_TXDONE_BY_IRQ if mbox->txdone_irq
> is set, MBOX_TXDONE_BY_POLL if mbox->txdone_poll is set, or
> MBOX_TXDONE_BY_ACK if neither is set. Only controllers with
> mbox->txdone_poll set initialize mbox->poll_hrt and require
> mbox->ops->last_tx_done to be implemented.
>
> When a client with cl->knows_txdone = true binds to a channel whose
> controller uses MBOX_TXDONE_BY_POLL, __mbox_bind_client() overrides
> chan->txdone_method to MBOX_TXDONE_BY_ACK. Commit 33cd7123ac0b
> ("mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone")
> attempted to restore chan->txdone_method to MBOX_TXDONE_BY_POLL when
> the channel is released, but did so unconditionally whenever
> chan->txdone_method == MBOX_TXDONE_BY_ACK:
>
> if (chan->txdone_method == MBOX_TXDONE_BY_ACK)
> chan->txdone_method = MBOX_TXDONE_BY_POLL;
>
> For controllers whose native txdone_method is MBOX_TXDONE_BY_ACK
> (!txdone_irq && !txdone_poll), releasing a channel (or failing in the
> controller's startup() callback) corrupts chan->txdone_method to
> MBOX_TXDONE_BY_POLL even though the controller does not support
> polling and has not initialized poll_hrt or ops->last_tx_done.
>
> Check chan->mbox->txdone_poll before resetting chan->txdone_method to
> MBOX_TXDONE_BY_POLL in mbox_clean_and_put_channel().
>
Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
> Fixes: 33cd7123ac0b ("mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> Found by code inspection and only compile-tested.
>
> drivers/mailbox/mailbox.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index efacd24a085d..cfc49cfb057c 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -343,7 +343,7 @@ static void mbox_clean_and_put_channel(struct mbox_chan *chan)
> scoped_guard(spinlock_irqsave, &chan->lock) {
> chan->cl = NULL;
> chan->active_req = MBOX_NO_MSG;
> - if (chan->txdone_method == MBOX_TXDONE_BY_ACK)
> + if (chan->txdone_method == MBOX_TXDONE_BY_ACK && chan->mbox->txdone_poll)
> chan->txdone_method = MBOX_TXDONE_BY_POLL;
> }
>
> --
> 2.56.0.385.gac671c819a-goog
>
--
Regards,
Sudeep
prev parent reply other threads:[~2026-11-04 15:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 0:42 Douglas Anderson
2026-11-04 14:24 ` Peng Fan
2026-11-04 15:30 ` Sudeep Holla [this message]
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=20261104-amazing-azure-malamute-a82ab3@sudeepholla \
--to=sudeep.holla@kernel.org \
--cc=dianders@chromium.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-kernel@vger.kernel.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®