U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jamie Gibbons <jamie.gibbons@microchip.com>
To: <u-boot@lists.denx.de>
Cc: Conor Dooley <conor.dooley@microchip.com>,
	Valentina Fernandez Alanis
	<valentina.fernandezalanis@microchip.com>,
	Tom Rini <trini@konsulko.com>,
	"Leo Yu-Chi Liang" <ycliang@andestech.com>,
	Sughosh Ganu <sughosh.ganu@arm.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Martin Herren <sputnik@on-the-web.ch>,
	Michal Simek <michal.simek@amd.com>,
	<jamie.gibbons@microchip.com>
Subject: [PATCH v2 6/6] mailbox: mpfs: add bounded wait for BUSY to clear before sending request
Date: Wed, 22 Jul 2026 16:45:49 +0100	[thread overview]
Message-ID: <20260722154602.3373184-7-jamie.gibbons@microchip.com> (raw)
In-Reply-To: <20260722154602.3373184-1-jamie.gibbons@microchip.com>

The MPFS mailbox driver currently checks the BUSY bit at the start of
mpfs_mbox_send() and immediately returns -EBUSY if the controller is
busy.

On MPFS, BUSY may be transiently asserted during early boot even though
no other U-Boot service is actively executing. In Linux, returning
-EBUSY here is retryable via the mailbox framework and scheduler, but in
U-Boot this results in a hard failure.

Replace the immediate BUSY check with a bounded wait using
regmap_read_poll_timeout(), waiting for the controller to become idle
before issuing a new request. This preserves the intent of the BUSY
check while avoiding spurious early-boot failures in U-Boot’s
synchronous, polled execution model.

The timeout is conservative and based on observed MPFS behaviour, where
BUSY clears within a few milliseconds.

Signed-off-by: Jamie Gibbons <jamie.gibbons@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
 drivers/mailbox/mpfs-mbox.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/mpfs-mbox.c b/drivers/mailbox/mpfs-mbox.c
index 165d9d89630..8b7a2719330 100644
--- a/drivers/mailbox/mpfs-mbox.c
+++ b/drivers/mailbox/mpfs-mbox.c
@@ -65,8 +65,11 @@ static int mpfs_mbox_send(struct mbox_chan *chan, const void *data)
 
 	u32 *word_buf = (u32 *)msg->cmd_data;
 
-	if (mpfs_mbox_busy(chan))
-		return -EBUSY;
+	ret = regmap_read_poll_timeout(mbox->control_scb, SERVICES_SR_OFFSET,
+				       value, !(value & SERVICE_SR_BUSY_MASK),
+				       1, 20);
+	if (ret)
+		return ret;
 
 	for (idx = 0; idx < (msg->cmd_data_size / BYTES_4); idx++)
 		writel(word_buf[idx], mbox->mbox_base + msg->mbox_offset + idx * BYTES_4);
-- 
2.43.0


  parent reply	other threads:[~2026-07-23  0:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 15:45 [PATCH v2 0/6] MPFS: add hardware RNG support and fix RNG consumers Jamie Gibbons
2026-07-22 15:45 ` [PATCH v2 1/6] misc: mpfs_syscontroller: add mailbox RX helper for service responses Jamie Gibbons
2026-07-22 15:45 ` [PATCH v2 2/6] misc: mpfs_syscontroller: bind RNG sub-device Jamie Gibbons
2026-07-22 15:45 ` [PATCH v2 3/6] rng: add Microchip PolarFire SoC hardware RNG driver Jamie Gibbons
2026-07-27  7:14   ` Leo Liang via U-Boot
2026-07-27  8:12     ` Jamie.Gibbons--- via U-Boot
2026-07-28  7:59       ` Leo Liang via U-Boot
2026-07-22 15:45 ` [PATCH v2 4/6] configs: microchip_mpfs_generic: enable MPFS RNG support Jamie Gibbons
2026-07-27  7:14   ` Leo Liang via U-Boot
2026-07-22 15:45 ` [PATCH v2 5/6] mailbox: mpfs-mbox: replace unbounded BUSY polling with bounded waits Jamie Gibbons
2026-07-22 15:45 ` Jamie Gibbons [this message]
2026-07-28  8:12 ` [PATCH v2 0/6] MPFS: add hardware RNG support and fix RNG consumers Leo Liang via U-Boot

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=20260722154602.3373184-7-jamie.gibbons@microchip.com \
    --to=jamie.gibbons@microchip.com \
    --cc=conor.dooley@microchip.com \
    --cc=michal.simek@amd.com \
    --cc=sputnik@on-the-web.ch \
    --cc=sughosh.ganu@arm.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=valentina.fernandezalanis@microchip.com \
    --cc=xypron.glpk@gmx.de \
    --cc=ycliang@andestech.com \
    /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