From: Ajit Kumar <Ajit.Kumar@amd.com>
To: <dev@dpdk.org>
Subject: [PATCH] net/axgbe: retry transient SFP I2C read failures
Date: Thu, 19 Nov 2026 09:21:40 +0530 [thread overview]
Message-ID: <20261119035140.2074510-1-Ajit.Kumar@amd.com> (raw)
From: Ajit Kumar <ajit.kumar@amd.com>
A port's very first I2C transaction against its SFP cage
(GPIO-expander/mux), issued right after axgbe_phy_init(), can fail even
with no other port active at all: either a quick NACK (-ENOTCONN,
IC_TX_ABRT_7B_ADDR_NOACK) or a full hardware stall with zero bus
activity until axgbe_i2c_xfer()'s own 1-second timeout fires
(-ETIMEDOUT, logged as "i2c operation timed out").
This is a different failure from the cross-port bus-contention race
fixed by the driver-wide axgbe_i2c_mdio_bus_mutex ("net/axgbe: serialize
PHY and link status access"): it reproduces on a single port with no
sibling port active, immediately after that port's own phy_init(), so
serializing the shared bus does not help with it. The SFP cage's I2C
mux/GPIO-expander device appears to simply not be ready to answer the
very first probe yet.
axgbe_phy_i2c_read()'s retry loop currently only matches -EAGAIN
(arbitration lost). Extend it to also retry -ENOTCONN and -ETIMEDOUT,
with a short (2ms) settle delay first, since an immediate retry is
unlikely to help if the device is still completing its own power-on
sequence.
Cost: on the -ETIMEDOUT path, this adds up to one more full internal
1-second timeout per phase for a genuinely persistent (non-transient)
fault. This is bounded to each port's first post-init access -- a
one-time bring-up cost, not something paid on every later
link_update() poll. Like any other access to the shared I2C/MDIO bus,
it runs while axgbe_i2c_mdio_bus_mutex is held, so it can delay other
ports' bus access by the same amount; this is no different from any
other bus access taking longer under contention.
Validated on two independent physical units (AMD CRB V3C48 and
Advantech FWA-1081): 0 I2C errors across 30 iterations of the existing
cross-port repro plus a dedicated solo-access repro, which now links
up cleanly on both ports; both failed deterministically without this
change.
Depends on the axgbe_i2c_mdio_bus_mutex added by "net/axgbe: serialize
PHY and link status access" for the cross-port case; this patch's own
hunk does not otherwise overlap it and applies independently.
Fixes: a5c7273771e8 ("net/axgbe: add phy programming APIs")
Cc: stable@dpdk.org
Signed-off-by: Ajit Kumar <ajit.kumar@amd.com>
---
drivers/net/axgbe/axgbe_phy_impl.c | 46 ++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 55d45bfb7b..a70454ecb9 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -531,6 +531,44 @@ static int axgbe_phy_redrv_write(struct axgbe_port *pdata, unsigned int reg,
return ret;
}
+/*
+ * The very first I2C transaction a port issues against its SFP cage
+ * (GPIO-expander / mux), right after axgbe_phy_init(), can legitimately
+ * find that device not yet ready to respond -- observed in the field
+ * as either a quick NACK (-ENOTCONN, IC_TX_ABRT_7B_ADDR_NOACK) or a
+ * full hardware stall with zero bus activity until axgbe_i2c_xfer()'s
+ * own 1-second timeout fires (-ETIMEDOUT). This is distinct from the
+ * cross-port bus-contention race fixed by axgbe_i2c_mdio_bus_mutex in
+ * axgbe_phy_get_comm_ownership(): it reproduces on a single port with
+ * no other port active at all, immediately after that port's own
+ * phy_init(), so serializing the bus does not help with it.
+ *
+ * Retry on these two codes as well as the existing -EAGAIN, with a
+ * short settle delay first, since an immediate retry is unlikely to
+ * help if the device is still completing its own power-on sequence.
+ *
+ * Cost: on the -ETIMEDOUT path this adds up to one more full internal
+ * 1-second timeout per phase for a genuinely persistent (non-
+ * transient) fault. This is bounded to each port's first post-init
+ * access -- a one-time bring-up cost, not a recurring one paid on
+ * every subsequent link_update() poll -- and, like any I2C/MDIO bus
+ * access, runs while axgbe_i2c_mdio_bus_mutex is held, so it can
+ * delay other ports' bus access by the same amount, same as any other
+ * access to this bus.
+ *
+ * Validated on two independent physical units (AMD CRB V3C48 and
+ * Advantech FWA-1081): 0 I2C errors across 30 iterations of the
+ * original cross-port repro plus a dedicated solo-access repro, which
+ * now links up cleanly on both ports; both failed deterministically
+ * without this change.
+ */
+static inline bool axgbe_i2c_retryable(int ret)
+{
+ return ret == -EAGAIN || ret == -ENOTCONN || ret == -ETIMEDOUT;
+}
+
+#define AXGBE_I2C_RETRY_DELAY_MS 2
+
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)
@@ -547,8 +585,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) && retry--) {
+ rte_delay_ms(AXGBE_I2C_RETRY_DELAY_MS);
goto again1;
+ }
return ret;
}
@@ -561,8 +601,10 @@ 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--)
+ if (axgbe_i2c_retryable(ret) && retry--) {
+ rte_delay_ms(AXGBE_I2C_RETRY_DELAY_MS);
goto again2;
+ }
return ret;
}
--
2.43.0
reply other threads:[~2026-11-19 10:54 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=20261119035140.2074510-1-Ajit.Kumar@amd.com \
--to=ajit.kumar@amd.com \
--cc=dev@dpdk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox