From: Ajit Kumar <Ajit.Kumar@amd.com>
To: <dev@dpdk.org>
Cc: <stephen@networkplumber.org>
Subject: [PATCH v2] net/axgbe: retry transient SFP I2C read failures
Date: Thu, 19 Nov 2026 23:05:06 +0530 [thread overview]
Message-ID: <20261119173506.840405-1-Ajit.Kumar@amd.com> (raw)
In-Reply-To: <20261119035140.2074510-1-Ajit.Kumar@amd.com>
From: Ajit Kumar <ajit.kumar@amd.com>
A port's first I2C access to its SFP cage can fail right after
axgbe_phy_init(), even alone on the bus: a quick NACK (-ENOTCONN) or
a full stall until axgbe_i2c_xfer()'s own 1s timeout (-ETIMEDOUT).
This is separate from the cross-port race fixed by
axgbe_i2c_mdio_bus_mutex; it shows up on a single port with no
sibling active, so serializing the bus doesn't help.
axgbe_phy_i2c_read() only retried -EAGAIN. Retry -ENOTCONN and
-ETIMEDOUT too, with a short settle delay, but only until the port's
bus has one successful transfer since phy_init(). After that, a
repeat is a real fault, not a settling device, and shouldn't cost
every later poll an extra second while holding the shared mutex.
Validated on AMD CRB V3C48 and Advantech FWA-1081: 0 I2C errors
across 30 iterations of the cross-port repro plus a solo-access
repro that now links up cleanly on both; both failed every time
without this change.
Depends on axgbe_i2c_mdio_bus_mutex from "net/axgbe: serialize PHY
and link status access" for the cross-port case; otherwise applies
independently.
Fixes: a5c7273771e8 ("net/axgbe: add phy programming APIs")
Cc: stable@dpdk.org
Signed-off-by: Ajit Kumar <ajit.kumar@amd.com>
---
v2:
- the extended retry wasn't actually limited to the first access as
claimed; nothing tracked that state, so a persistent fault paid
the cost on every poll. Added a per-port settled flag to gate it
correctly (per DPDK AI code-review bot).
- switched the delay to rte_delay_us_sleep(), a real sleep, since it
can now be held more than once.
- cut the in-code comment, which just repeated this commit log
(per Stephen Hemminger's review).
---
drivers/net/axgbe/axgbe_phy_impl.c | 38 ++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 55d45bfb7b..57bd1f64d4 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -223,6 +223,7 @@ struct axgbe_phy_data {
unsigned int sfp_tx_fault;
unsigned int sfp_mod_absent;
unsigned int sfp_changed;
+ unsigned int sfp_i2c_settled;
unsigned int sfp_phy_avail;
unsigned int sfp_cable_len;
enum axgbe_sfp_base sfp_base;
@@ -531,10 +532,29 @@ static int axgbe_phy_redrv_write(struct axgbe_port *pdata, unsigned int reg,
return ret;
}
+/*
+ * The SFP cage mux/GPIO expander may not respond to the first access
+ * after phy_init(), either NACKing (-ENOTCONN) or stalling until the
+ * transfer times out (-ETIMEDOUT). Retry those as well as
+ * arbitration loss (-EAGAIN) after a short delay, but only until the
+ * first successful transfer; after that it's a real fault, not a
+ * settling device.
+ */
+static inline bool axgbe_i2c_retryable(int ret, bool settled)
+{
+ if (ret == -EAGAIN)
+ return true;
+
+ return !settled && (ret == -ENOTCONN || ret == -ETIMEDOUT);
+}
+
+#define AXGBE_I2C_RETRY_DELAY_US 2000
+
static int axgbe_phy_i2c_read(struct axgbe_port *pdata, unsigned int target,
void *reg, unsigned int reg_len,
void *val, unsigned int val_len)
{
+ struct axgbe_phy_data *phy_data = pdata->phy_data;
struct axgbe_i2c_op i2c_op;
int retry, ret;
@@ -547,8 +567,10 @@ static int axgbe_phy_i2c_read(struct axgbe_port *pdata, unsigned int target,
i2c_op.buf = reg;
ret = axgbe_phy_i2c_xfer(pdata, &i2c_op);
if (ret) {
- if ((ret == -EAGAIN) && retry--)
+ if (axgbe_i2c_retryable(ret, phy_data->sfp_i2c_settled) && retry--) {
+ rte_delay_us_sleep(AXGBE_I2C_RETRY_DELAY_US);
goto again1;
+ }
return ret;
}
@@ -561,10 +583,18 @@ static int axgbe_phy_i2c_read(struct axgbe_port *pdata, unsigned int target,
i2c_op.len = val_len;
i2c_op.buf = val;
ret = axgbe_phy_i2c_xfer(pdata, &i2c_op);
- if ((ret == -EAGAIN) && retry--)
- goto again2;
+ if (ret) {
+ if (axgbe_i2c_retryable(ret, phy_data->sfp_i2c_settled) && retry--) {
+ rte_delay_us_sleep(AXGBE_I2C_RETRY_DELAY_US);
+ goto again2;
+ }
- return ret;
+ return ret;
+ }
+
+ phy_data->sfp_i2c_settled = 1;
+
+ return 0;
}
static int axgbe_phy_sfp_put_mux(struct axgbe_port *pdata)
--
2.43.0
prev parent reply other threads:[~2026-11-20 10:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 3:51 [PATCH] net/axgbe: retry transient SFP I2C read failures Ajit Kumar
2026-11-19 16:36 ` Stephen Hemminger
2026-11-19 17:35 ` Ajit Kumar [this message]
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=20261119173506.840405-1-Ajit.Kumar@amd.com \
--to=ajit.kumar@amd.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.