mail archive of the barebox mailing list
 help / color / mirror / Atom feed
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 3/6] arm: socfpga: iossm: remove duplicate read of response status
Date: Thu, 16 Apr 2026 17:25:48 +0200	[thread overview]
Message-ID: <20260416-socfpga-agilex5-iossm-cleanup-v1-3-ca9aae003c84@pengutronix.de> (raw)
In-Reply-To: <20260416-socfpga-agilex5-iossm-cleanup-v1-0-ca9aae003c84@pengutronix.de>

The IOSSM_CMD_RESPONSE_STATUS doesn't change after the mailbox command
has returned. Reading the register again isn't necessary.

While clearing the IOSSM_STATUS_COMMAND_RESPONSE_READY bit changes the
response status, this bit may be set in the returned response.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 arch/arm/mach-socfpga/iossm_mailbox.c | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-socfpga/iossm_mailbox.c b/arch/arm/mach-socfpga/iossm_mailbox.c
index 7ec79dec4534..24d1404be1a1 100644
--- a/arch/arm/mach-socfpga/iossm_mailbox.c
+++ b/arch/arm/mach-socfpga/iossm_mailbox.c
@@ -83,7 +83,7 @@ int io96b_mb_req(phys_addr_t io96b_csr_addr, u32 ip_type, u32 instance_id,
 		 struct io96b_mb_resp *resp)
 {
 	int ret;
-	u32 cmd_req, cmd_resp;
+	u32 cmd_req;
 
 	/* Initialized zeros for responses*/
 	memset(resp, 0x0, sizeof(*resp));
@@ -125,17 +125,14 @@ int io96b_mb_req(phys_addr_t io96b_csr_addr, u32 ip_type, u32 instance_id,
 				 resp->cmd_resp_status,
 				 resp->cmd_resp_status & IOSSM_STATUS_COMMAND_RESPONSE_READY,
 				 10 * USEC_PER_SEC);
-	if (ret) {
-		pr_err("%s: CMD_RESPONSE ERROR:\n", __func__);
-		cmd_resp = readl(io96b_csr_addr + IOSSM_CMD_RESPONSE_STATUS_OFFSET);
-		pr_err("%s: STATUS_GENERAL_ERROR: 0x%x\n", __func__, (cmd_resp >> 1) & 0xF);
-		pr_err("%s: STATUS_CMD_RESPONSE_ERROR: 0x%x\n", __func__, (cmd_resp >> 5) & 0x7);
-	}
+	if (ret)
+		pr_warn("%s: CMD_RESPONSE_STATUS ERROR: 0x%lx 0x%lx\n", __func__,
+			FIELD_GET(GENMASK(4, 1), resp->cmd_resp_status),
+			FIELD_GET(GENMASK(7, 5), resp->cmd_resp_status));
 
-	/* read CMD_RESPONSE_STATUS*/
-	resp->cmd_resp_status = readl(io96b_csr_addr + IOSSM_CMD_RESPONSE_STATUS_OFFSET);
-	pr_debug("%s: CMD_RESPONSE_STATUS 0x%llx: 0x%x\n", __func__, io96b_csr_addr +
-		IOSSM_CMD_RESPONSE_STATUS_OFFSET, resp->cmd_resp_status);
+	pr_debug("%s: CMD_RESPONSE_STATUS 0x%p: 0x%x\n", __func__,
+		 io96b_csr_addr + IOSSM_CMD_RESPONSE_STATUS_OFFSET,
+		 resp->cmd_resp_status);
 
 	/* read CMD_RESPONSE_DATA_* */
 	resp->cmd_resp_data[0] = readl(io96b_csr_addr + IOSSM_CMD_RESPONSE_DATA_0_OFFSET);
@@ -151,19 +148,10 @@ int io96b_mb_req(phys_addr_t io96b_csr_addr, u32 ip_type, u32 instance_id,
 		 __func__, io96b_csr_addr + IOSSM_CMD_RESPONSE_DATA_2_OFFSET,
 		 resp->cmd_resp_data[2]);
 
-	resp->cmd_resp_status = readl(io96b_csr_addr + IOSSM_CMD_RESPONSE_STATUS_OFFSET);
-	pr_debug("%s: CMD_RESPONSE_STATUS 0x%llx: 0x%x\n", __func__,
-		 io96b_csr_addr + IOSSM_CMD_RESPONSE_STATUS_OFFSET,
-		 resp->cmd_resp_status);
-
 	/* write CMD_RESPONSE_READY = 0 */
 	clrbits_le32((u32 *)(uintptr_t)(io96b_csr_addr + IOSSM_CMD_RESPONSE_STATUS_OFFSET),
 		     IOSSM_STATUS_COMMAND_RESPONSE_READY);
 
-	resp->cmd_resp_status = readl(io96b_csr_addr + IOSSM_CMD_RESPONSE_STATUS_OFFSET);
-	pr_debug("%s: CMD_RESPONSE_READY 0x%llx: 0x%x\n", __func__, io96b_csr_addr +
-		 IOSSM_CMD_RESPONSE_STATUS_OFFSET, resp->cmd_resp_status);
-
 	return 0;
 }
 

-- 
2.47.3




  parent reply	other threads:[~2026-04-16 15:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-16 15:25 [PATCH 0/6] arm: socfpga: iossm: code cleanup Michael Tretter
2026-04-16 15:25 ` [PATCH 1/6] arm: socfpga: iossm: make io96b_cal_status static Michael Tretter
2026-04-16 15:25 ` [PATCH 2/6] arm: socfpga: iossm: use readl_poll_timeout Michael Tretter
2026-04-16 15:25 ` Michael Tretter [this message]
2026-04-16 15:25 ` [PATCH 4/6] arm: socfpga: iossm: remove multiple read of status_addr Michael Tretter
2026-04-16 15:25 ` [PATCH 5/6] arm: socfpga: iossm: change io96b_csr_addr to void * Michael Tretter
2026-04-16 15:25 ` [PATCH 6/6] arm: socfpga: iossm: extract io96b_mb_init_instance Michael Tretter
2026-04-17  8:14 ` [PATCH 0/6] arm: socfpga: iossm: code cleanup 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=20260416-socfpga-agilex5-iossm-cleanup-v1-3-ca9aae003c84@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