* [PATCH] mailbox: Only reset txdone_method to POLL if controller supports polling
@ 2026-11-04 0:42 Douglas Anderson
2026-11-04 14:24 ` Peng Fan
2026-11-04 15:30 ` Sudeep Holla
0 siblings, 2 replies; 3+ messages in thread
From: Douglas Anderson @ 2026-11-04 0:42 UTC (permalink / raw)
To: Jassi Brar; +Cc: Douglas Anderson, Sudeep Holla, linux-kernel
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().
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mailbox: Only reset txdone_method to POLL if controller supports polling
2026-11-04 0:42 [PATCH] mailbox: Only reset txdone_method to POLL if controller supports polling Douglas Anderson
@ 2026-11-04 14:24 ` Peng Fan
2026-11-04 15:30 ` Sudeep Holla
1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2026-11-04 14:24 UTC (permalink / raw)
To: Douglas Anderson; +Cc: Jassi Brar, Sudeep Holla, linux-kernel
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().
>
>Fixes: 33cd7123ac0b ("mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone")
>Signed-off-by: Douglas Anderson <dianders@chromium.org>
>---
LGTM:
Reviewed-by: Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mailbox: Only reset txdone_method to POLL if controller supports polling
2026-11-04 0:42 [PATCH] mailbox: Only reset txdone_method to POLL if controller supports polling Douglas Anderson
2026-11-04 14:24 ` Peng Fan
@ 2026-11-04 15:30 ` Sudeep Holla
1 sibling, 0 replies; 3+ messages in thread
From: Sudeep Holla @ 2026-11-04 15:30 UTC (permalink / raw)
To: Douglas Anderson; +Cc: Jassi Brar, linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-04 15:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 0:42 [PATCH] mailbox: Only reset txdone_method to POLL if controller supports polling Douglas Anderson
2026-11-04 14:24 ` Peng Fan
2026-11-04 15:30 ` Sudeep Holla
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®