From 10f9f183888991e884a5873bbc2a1a5ce3627b21 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 15 Jul 2026 11:32:13 +0100 Subject: [PATCH 1/2] mailbox: rp1: Don't poll for TX completion The RP1 mailbox + firmware interface is currently synchronous, with only one outstanding message at a time and the same buffer used for the reply. It is therefore of no use to know when the transmit has completed, only that the reply is ready. This is TXDONE_BY_ACK mode, which is automatically selected if neither txdone_irq nor txdone_poll are provided. This change increases performance and reduces hrtimer usage significantly, but it requires the mailbox client to call mbox_client_txdone after each transmission. Signed-off-by: Phil Elwell --- drivers/mailbox/rp1-mailbox.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/mailbox/rp1-mailbox.c b/drivers/mailbox/rp1-mailbox.c index 0e8af098b62b2..a9a86a9ec89b9 100644 --- a/drivers/mailbox/rp1-mailbox.c +++ b/drivers/mailbox/rp1-mailbox.c @@ -101,22 +101,10 @@ static void rp1_shutdown(struct mbox_chan *chan) writel(event, mbox->regs + SYSCFG_HOST_EVENT_IRQ_EN + HW_CLR_BITS); } -static bool rp1_last_tx_done(struct mbox_chan *chan) -{ - struct rp1_mbox *mbox = rp1_chan_mbox(chan); - unsigned int event = rp1_chan_event(chan); - unsigned int evs; - - evs = readl(mbox->regs + SYSCFG_HOST_EVENT_IRQ); - - return !(evs & event); -} - static const struct mbox_chan_ops rp1_mbox_chan_ops = { .send_data = rp1_send_data, .startup = rp1_startup, .shutdown = rp1_shutdown, - .last_tx_done = rp1_last_tx_done }; static struct mbox_chan *rp1_mbox_xlate(struct mbox_controller *mbox, @@ -168,8 +156,6 @@ static int rp1_mbox_probe(struct platform_device *pdev) if (!chans) return -ENOMEM; - mbox->controller.txdone_poll = true; - mbox->controller.txpoll_period = 5; mbox->controller.ops = &rp1_mbox_chan_ops; mbox->controller.of_xlate = &rp1_mbox_xlate; mbox->controller.dev = dev; From 48306a1bd3f84042e0c664e95728114aab8ee9d1 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 15 Jul 2026 11:40:33 +0100 Subject: [PATCH 2/2] firmware: rp1-fw: Call mbox_client_txdone after TX Now that TX polling has been disabled and the mailbox is running in TXDONE_BY_ACK mode, call mbox_client_txdone after each transmission to tell the mailbox framework that the transmission has completed. Signed-off-by: Phil Elwell --- drivers/firmware/rp1-fw.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/firmware/rp1-fw.c b/drivers/firmware/rp1-fw.c index be33ac6ed2186..96d80d21f9e63 100644 --- a/drivers/firmware/rp1-fw.c +++ b/drivers/firmware/rp1-fw.c @@ -80,6 +80,13 @@ int rp1_firmware_message(struct rp1_firmware *fw, uint16_t op, reinit_completion(&fw->c); ret = mbox_send_message(fw->chan, NULL); if (ret >= 0) { + /* + * The doorbell write in rp1_send_data() is already complete by + * the time mbox_send_message() returns, so tell the mailbox + * core immediately rather than have it poll for tx-done. + */ + mbox_client_txdone(fw->chan, 0); + if (wait_for_completion_timeout(&fw->c, HZ)) ret = 0; else