[PATCH v2] net/axgbe: retry transient SFP I2C read failures
Stephen Hemminger
stephen at networkplumber.org
Sun Nov 22 18:30:50 CET 2026
On Thu, 19 Nov 2026 23:05:06 +0530
Ajit Kumar <Ajit.Kumar at amd.com> wrote:
> From: Ajit Kumar <ajit.kumar at 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 at dpdk.org
>
> Signed-off-by: Ajit Kumar <ajit.kumar at amd.com>
I haven't looked into all the complexities here, but AI warnings
seem valid:
Subject: Re: [PATCH v2] net/axgbe: retry transient SFP I2C read failures
Applies on top of the bus mutex patch and builds clean with
-Dwerror=true. Two problems with how the retry window is gated.
Warning
1. The settled flag follows the wrong lifecycle.
phy_data is allocated once by axgbe_phy_init() at probe
(axgbe_ethdev.c:2410) and sfp_i2c_settled is never cleared. The
first I2C access is not after phy_init(); it is in axgbe_phy_start(),
right after i2c_start(), via axgbe_phy_sfp_detect(). That runs on
every dev_start. After a stop/start or port reset the flag is
already 1, so the case this patch targets gets no retry.
The comment and commit message should also say phy_start, not
phy_init.
2. A fault present from the start is still retried on every poll.
The v2 changelog says a persistent fault no longer pays the retry
cost. That is only true if some transfer has succeeded. If the GPIO
expander never answers, axgbe_phy_sfp_signals() fails on every link
poll (axgbe_phy_link_status -> axgbe_phy_sfp_detect), the flag is
never set, and each poll can spend about 2s per transfer in two
1s axgbe_i2c_xfer() timeouts while holding the driver-wide bus
mutex. That stalls link_update on every port.
Gate the window by when the access happens, not by success. Both
issues go away if the extended retry only applies during the
phy_start probe:
case AXGBE_PORT_MODE_SFP:
phy_data->sfp_i2c_probe = 1;
axgbe_phy_sfp_detect(pdata);
phy_data->sfp_i2c_probe = 0;
break;
and in axgbe_phy_i2c_read() test sfp_i2c_probe instead of
!sfp_i2c_settled, dropping the assignment after the read.
Info
What is the root cause? Linux xgbe does the same sequence with an
-EAGAIN-only retry. If the expander needs time after the I2C
controller is enabled, one delay in axgbe_phy_start() before
sfp_detect would be simpler than per-transfer retries. Also, after a
device has already stalled for the full 1s, does a 2ms sleep and a
second try ever succeed in your testing, or was only -ENOTCONN seen
to recover?
The "Depends on" paragraph belongs below "---", and the commit
message should not name axgbe_i2c_mdio_bus_mutex, since that symbol
may be renamed.
More information about the dev
mailing list