From: Michael Tretter <m.tretter@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>,
Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH v2 07/10] arm: socfgpa: iossm: extract poll_bist_mem_init_status
Date: Thu, 09 Apr 2026 15:52:47 +0200 [thread overview]
Message-ID: <20260409-socfpga-iossm-v1-v2-7-09effab91bc1@pengutronix.de> (raw)
In-Reply-To: <20260409-socfpga-iossm-v1-v2-0-09effab91bc1@pengutronix.de>
Extract the final polling for the finish of the memory initialization to
make the code more readable by reducing the nesting.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
Changes in v2:
- none
---
arch/arm/mach-socfpga/iossm_mailbox.c | 66 +++++++++++++++++++++--------------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/arch/arm/mach-socfpga/iossm_mailbox.c b/arch/arm/mach-socfpga/iossm_mailbox.c
index 2c598a6c192a..67000d2cf300 100644
--- a/arch/arm/mach-socfpga/iossm_mailbox.c
+++ b/arch/arm/mach-socfpga/iossm_mailbox.c
@@ -491,19 +491,53 @@ int io96b_ecc_enable_status(struct io96b_info *io96b_ctrl)
return 0;
}
+static int io96b_poll_bist_mem_init_status(struct io96b_info *io96b_ctrl,
+ int instance, int interface)
+{
+ phys_addr_t io96b_csr_addr = io96b_ctrl->io96b[instance].io96b_csr_addr;
+ struct io96b_mb_ctrl *mb_ctrl = &io96b_ctrl->io96b[instance].mb_ctrl;
+ int timeout = 1 * USEC_PER_SEC;
+ bool bist_success = false;
+ int bist_error = 0;
+ struct io96b_mb_resp usr_resp;
+ u32 mem_init_status;
+
+ /* Polling for the initiated memory initialization BIST status */
+ while (!bist_success) {
+ io96b_mb_req_no_param(io96b_csr_addr,
+ mb_ctrl->ip_type[interface],
+ mb_ctrl->ip_instance_id[interface],
+ CMD_TRIG_CONTROLLER_OP,
+ BIST_MEM_INIT_STATUS, &usr_resp);
+ mem_init_status = IOSSM_CMD_RESPONSE_DATA_SHORT(usr_resp.cmd_resp_status);
+
+ bist_success = FIELD_GET(BIT(0), mem_init_status);
+ bist_error = FIELD_GET(GENMASK(2, 1), mem_init_status);
+
+ if (!bist_success && (timeout-- < 0)) {
+ pr_err("%s: Timeout initialize memory on IO96B_%d (Error 0x%x)\n",
+ __func__, instance, bist_error);
+ return -ETIMEDOUT;
+ }
+
+ __udelay(1);
+ }
+
+ return 0;
+}
+
int io96b_bist_mem_init_start(struct io96b_info *io96b_ctrl)
{
struct io96b_mb_resp usr_resp;
int i, j;
- bool bist_start, bist_success;
- int timeout = 1000000;
+ bool bist_start;
u32 mem_init_status_intf;
+ int ret = 0;
/* Full memory initialization BIST performed on all memory interface(s) */
for (i = 0; i < io96b_ctrl->num_instance; i++) {
for (j = 0; j < io96b_ctrl->io96b[i].mb_ctrl.num_mem_interface; j++) {
bist_start = false;
- bist_success = false;
/* Start memory initialization BIST on full memory address */
io96b_mb_req(io96b_ctrl->io96b[i].io96b_csr_addr,
@@ -523,29 +557,9 @@ int io96b_bist_mem_init_start(struct io96b_info *io96b_ctrl)
return -ENOEXEC;
}
- /* Polling for the initiated memory initialization BIST status */
- while (!bist_success) {
- io96b_mb_req_no_param(io96b_ctrl->io96b[i].io96b_csr_addr,
- io96b_ctrl->io96b[i].mb_ctrl.ip_type[j],
- io96b_ctrl->io96b[i].mb_ctrl.ip_instance_id[j],
- CMD_TRIG_CONTROLLER_OP,
- BIST_MEM_INIT_STATUS, &usr_resp);
- mem_init_status_intf = IOSSM_CMD_RESPONSE_DATA_SHORT(usr_resp.cmd_resp_status)
-
- bist_success = mem_init_status_intf & BIT(0);
-
- if (!bist_success && (timeout-- < 0)) {
- pr_err("%s: Timeout initialize memory on IO96B_%d\n",
- __func__, i);
- pr_err("%s: BIST_MEM_INIT_STATUS Error code 0x%x\n",
- __func__, (IOSSM_CMD_RESPONSE_DATA_SHORT
- (usr_resp.cmd_resp_status) &
- GENMASK(2, 1)) > 0x1);
- return -ETIMEDOUT;
- }
-
- __udelay(1);
- }
+ ret = io96b_poll_bist_mem_init_status(io96b_ctrl, i, j);
+ if (ret)
+ return ret;
}
pr_debug("%s: Memory initialized successfully on IO96B_%d\n", __func__, i);
--
2.47.3
next prev parent reply other threads:[~2026-04-09 13:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 13:52 [PATCH v2 00/10] arm: socfpga: iossm: add support for mailbox v1 Michael Tretter
2026-04-09 13:52 ` [PATCH v2 01/10] arm: socfpga: iossm: remove uninitialized variable Michael Tretter
2026-04-09 13:52 ` [PATCH v2 02/10] arm: socfpga: iossm: add version check Michael Tretter
2026-04-10 8:18 ` Ahmad Fatoum
2026-04-10 13:24 ` Michael Tretter
2026-04-09 13:52 ` [PATCH v2 03/10] arm: socfpga: iossm: use local mb_ctrl variable Michael Tretter
2026-04-09 13:52 ` [PATCH v2 04/10] arm: socfpga: iossm: store size in bytes Michael Tretter
2026-04-10 8:13 ` Ahmad Fatoum
2026-04-10 8:31 ` Michael Tretter
2026-04-10 8:37 ` Ahmad Fatoum
2026-04-10 12:06 ` Michael Tretter
2026-04-13 7:27 ` Sascha Hauer
2026-04-09 13:52 ` [PATCH v2 05/10] arm: socfpga: iossm: refactor io96b_mb_init Michael Tretter
2026-04-09 13:52 ` [PATCH v2 06/10] arm: socfpga: iossm: refactor return value handling Michael Tretter
2026-04-09 13:52 ` Michael Tretter [this message]
2026-04-09 13:52 ` [PATCH v2 08/10] arm: socfgpa: iossm: extract initialization of one interface Michael Tretter
2026-04-15 6:12 ` Sascha Hauer
2026-04-15 8:29 ` Michael Tretter
2026-04-15 10:31 ` Sascha Hauer
2026-04-15 10:56 ` [PATCH] fixup! " Michael Tretter
2026-04-15 11:48 ` Sascha Hauer
2026-04-09 13:52 ` [PATCH v2 09/10] arm: socfpga: iossm: add memory initialization with inline ecc Michael Tretter
2026-04-09 13:52 ` [PATCH v2 10/10] arm: socfpga: iossm: add support for mailbox v1 Michael Tretter
2026-04-10 8:19 ` [PATCH v2 00/10] " Ahmad Fatoum
2026-04-13 7:26 ` 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=20260409-socfpga-iossm-v1-v2-7-09effab91bc1@pengutronix.de \
--to=m.tretter@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
--cc=s.trumtrar@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