From: Tomasz Duszynski <tduszynski@marvell.com>
To: <dev@dpdk.org>, Nithin Dabilpuram <ndabilpuram@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Sunil Kumar Kori <skori@marvell.com>,
Satha Rao <skoteshwar@marvell.com>,
Harman Kalra <hkalra@marvell.com>,
Jerin Jacob <jerinj@marvell.com>,
Tomasz Duszynski <tduszynski@marvell.com>,
"Jakub Palider" <jpalider@marvell.com>
Subject: [PATCH] common/cnxk: fix async event handling
Date: Wed, 30 Jul 2025 04:51:09 +0200 [thread overview]
Message-ID: <20250730025109.1245119-1-tduszynski@marvell.com> (raw)
If async event shows up unexpectedly ack it and continue
until expected event is received.
Fixes: 857721d62d42 ("common/cnxk: add BPHY communication with atf")
Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
---
drivers/common/cnxk/roc_bphy_cgx.c | 52 +++++++++++-------------------
1 file changed, 19 insertions(+), 33 deletions(-)
diff --git a/drivers/common/cnxk/roc_bphy_cgx.c b/drivers/common/cnxk/roc_bphy_cgx.c
index db70bafd9b..1de5195657 100644
--- a/drivers/common/cnxk/roc_bphy_cgx.c
+++ b/drivers/common/cnxk/roc_bphy_cgx.c
@@ -65,8 +65,7 @@ roc_bphy_cgx_ack(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
}
static int
-roc_bphy_cgx_wait_for_ownership(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
- uint64_t *scr0)
+roc_bphy_cgx_wait_ack(struct roc_bphy_cgx *roc_cgx, unsigned int lmac, uint64_t *scr0, bool ack)
{
int tries = 5000;
uint64_t scr1;
@@ -75,16 +74,18 @@ roc_bphy_cgx_wait_for_ownership(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
*scr0 = roc_bphy_cgx_read(roc_cgx, lmac, CGX_CMRX_SCRATCH0);
scr1 = roc_bphy_cgx_read(roc_cgx, lmac, CGX_CMRX_SCRATCH1);
- if (FIELD_GET(SCR1_OWN_STATUS, scr1) == ETH_OWN_NON_SECURE_SW &&
- FIELD_GET(SCR0_ETH_EVT_STS_S_ACK, *scr0) == 0)
- break;
-
/* clear async events if any */
- if (FIELD_GET(SCR0_ETH_EVT_STS_S_EVT_TYPE, *scr0) ==
- ETH_EVT_ASYNC &&
- FIELD_GET(SCR0_ETH_EVT_STS_S_ACK, *scr0))
+ if (FIELD_GET(SCR0_ETH_EVT_STS_S_EVT_TYPE, *scr0) == ETH_EVT_ASYNC &&
+ FIELD_GET(SCR0_ETH_EVT_STS_S_ACK, *scr0)) {
roc_bphy_cgx_ack(roc_cgx, lmac, scr0);
+ goto skip;
+ }
+ if (FIELD_GET(SCR1_OWN_STATUS, scr1) == ETH_OWN_NON_SECURE_SW &&
+ FIELD_GET(SCR0_ETH_EVT_STS_S_ACK, *scr0) == ack)
+ break;
+
+skip:
plt_delay_ms(1);
} while (--tries);
@@ -92,29 +93,20 @@ roc_bphy_cgx_wait_for_ownership(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
}
static int
-roc_bphy_cgx_wait_for_ack(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
- uint64_t *scr0)
+roc_bphy_cgx_wait_for_ownership(struct roc_bphy_cgx *roc_cgx, unsigned int lmac, uint64_t *scr0)
{
- int tries = 5000;
- uint64_t scr1;
-
- do {
- *scr0 = roc_bphy_cgx_read(roc_cgx, lmac, CGX_CMRX_SCRATCH0);
- scr1 = roc_bphy_cgx_read(roc_cgx, lmac, CGX_CMRX_SCRATCH1);
-
- if (FIELD_GET(SCR1_OWN_STATUS, scr1) == ETH_OWN_NON_SECURE_SW &&
- FIELD_GET(SCR0_ETH_EVT_STS_S_ACK, *scr0))
- break;
-
- plt_delay_ms(1);
- } while (--tries);
+ return roc_bphy_cgx_wait_ack(roc_cgx, lmac, scr0, false);
+}
- return tries ? 0 : -ETIMEDOUT;
+static int
+roc_bphy_cgx_wait_for_ack(struct roc_bphy_cgx *roc_cgx, unsigned int lmac, uint64_t *scr0)
+{
+ return roc_bphy_cgx_wait_ack(roc_cgx, lmac, scr0, true);
}
static int
-roc_bphy_cgx_intf_req(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
- uint64_t scr1, uint64_t *scr0)
+roc_bphy_cgx_intf_req(struct roc_bphy_cgx *roc_cgx, unsigned int lmac, uint64_t scr1,
+ uint64_t *scr0)
{
uint8_t cmd_id = FIELD_GET(SCR1_ETH_CMD_ID, scr1);
int ret;
@@ -142,12 +134,6 @@ roc_bphy_cgx_intf_req(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
if (cmd_id == ETH_CMD_INTF_SHUTDOWN)
goto out;
- if (FIELD_GET(SCR0_ETH_EVT_STS_S_EVT_TYPE, *scr0) != ETH_EVT_CMD_RESP) {
- plt_err("received async event instead of cmd resp event");
- ret = -EIO;
- goto out;
- }
-
if (FIELD_GET(SCR0_ETH_EVT_STS_S_ID, *scr0) != cmd_id) {
plt_err("received resp for cmd %d expected for cmd %d",
(int)FIELD_GET(SCR0_ETH_EVT_STS_S_ID, *scr0), cmd_id);
--
2.34.1
reply other threads:[~2025-07-30 2:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250730025109.1245119-1-tduszynski@marvell.com \
--to=tduszynski@marvell.com \
--cc=dev@dpdk.org \
--cc=hkalra@marvell.com \
--cc=jerinj@marvell.com \
--cc=jpalider@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=skori@marvell.com \
--cc=skoteshwar@marvell.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;
as well as URLs for NNTP newsgroup(s).