From: Michael Tretter <m.tretter@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH 1/4] arm: socfpga: mailbox_s10: make retry logic more visible
Date: Wed, 11 Mar 2026 12:06:39 +0100 [thread overview]
Message-ID: <20260311-agilex5-qspi-v1-1-be8a8e1318e1@pengutronix.de> (raw)
In-Reply-To: <20260311-agilex5-qspi-v1-0-be8a8e1318e1@pengutronix.de>
The driver tries to open the QSPI a second time after closing the device
if the first open failed. The second try is open coded and repeats code
from the first try.
Refactor the code to have a single open and make the error handling more
obvious.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
arch/arm/mach-socfpga/mailbox_s10.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c
index 9211d643e3b6..f9ff6663dc38 100644
--- a/arch/arm/mach-socfpga/mailbox_s10.c
+++ b/arch/arm/mach-socfpga/mailbox_s10.c
@@ -301,20 +301,18 @@ int socfpga_mailbox_s10_qspi_open(void)
u32 resp_buf_len;
u32 reg;
u32 clk_khz;
+ int try = 0;
+retry:
ret = mbox_send_cmd(MBOX_ID_BAREBOX, MBOX_QSPI_OPEN, MBOX_CMD_DIRECT,
0, NULL, 0, 0, NULL);
- if (ret) {
- /* retry again by closing and reopen the QSPI again */
- ret = socfpga_mailbox_s10_qspi_close();
- if (ret)
- return ret;
-
- ret = mbox_send_cmd(MBOX_ID_BAREBOX, MBOX_QSPI_OPEN,
- MBOX_CMD_DIRECT, 0, NULL, 0, 0, NULL);
- if (ret)
- return ret;
+ if (ret != MBOX_RESP_STATOK && try++ < 2) {
+ /* retry after closing the QSPI */
+ socfpga_mailbox_s10_qspi_close();
+ goto retry;
}
+ if (ret)
+ return ret;
/* HPS will directly control the QSPI controller, no longer mailbox */
resp_buf_len = 1;
--
2.47.3
next prev parent reply other threads:[~2026-03-11 11:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 11:06 [PATCH 0/4] arm: socfpga: mailbox_s10: cleanup and error handling Michael Tretter
2026-03-11 11:06 ` Michael Tretter [this message]
2026-03-11 11:06 ` [PATCH 2/4] arm: socfpga: mailbox_s10: cleanup send command Michael Tretter
2026-03-11 11:06 ` [PATCH 3/4] arm: socfpga: mailbox_s10: add error messages for QSPI Michael Tretter
2026-03-11 11:06 ` [PATCH 4/4] arm: socfpga: mailbox_s10: handle error 0x8f explicitly Michael Tretter
2026-03-13 14:39 ` [PATCH 0/4] arm: socfpga: mailbox_s10: cleanup and error handling Sascha Hauer
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=20260311-agilex5-qspi-v1-1-be8a8e1318e1@pengutronix.de \
--to=m.tretter@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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