DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/axgbe: retry transient SFP I2C read failures
@ 2026-11-19  3:51 Ajit Kumar
  2026-11-19 16:36 ` Stephen Hemminger
  2026-11-19 17:35 ` [PATCH v2] " Ajit Kumar
  0 siblings, 2 replies; 6+ messages in thread
From: Ajit Kumar @ 2026-11-19  3:51 UTC (permalink / raw)
  To: dev

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] net/axgbe: retry transient SFP I2C read failures
  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 ` [PATCH v2] " Ajit Kumar
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2026-11-19 16:36 UTC (permalink / raw)
  To: Ajit Kumar; +Cc: dev

[-- Attachment #1: Type: text/plain, Size: 2524 bytes --]

On Thu, 19 Nov 2026 09:21:40 +0530
Ajit Kumar <Ajit.Kumar@amd.com> wrote:

>  
> +/*
> + * 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;
> +}

The code is fine, but this a great example of an AI slop comment!

If you coach AI to write better commit messages and comments it will
produce something like:

/*
 * 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 to let the device settle.
 */

See attached CLAUDE.md for hints how to help reduce this kind of mess.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: CLAUDE.md --]
[-- Type: text/markdown, Size: 1383 bytes --]

## Style

Avoid sounding like everything was generated by an LLM
1. Limit em dashes:   Max one per short paragraph. Less is better. Replace extras with commas, semicolons, or restructured phrasing. 
2. Kill formulaic structures:   Avoid “It’s not just X; it’s Y” phrasing. Rework neat triplets and symmetry—variety beats rhythm.
3. Purge buzzwords:   Remove or translate vague hype terms (e.g., *elevate, robust, impactful, leverage, delve*). Use precise, plain alternatives.
4. Delete strained metaphors:   Cut weird similes or analogies that don’t land. If you wince when reading it, it goes.
5. Cut redundancy and filler:   Eliminate repeated clarifications, preamble, and excessive transitions. Get to the point, then stop.
6. Inject human voice:   Use first-person when appropriate. Add a brief observation, reaction, or informal aside. Allow small imperfections that signal a real writer.
7. Loosen formality (where context allows):   Use contractions naturally (don’t, can’t, won’t). Avoid robotic phrasing. Let the tone match the platform (Slack ≠ policy doc).
8. Vary sentence rhythm:   Break uniformity. Mix short, medium, and long sentences to avoid “AI flatline” pacing.
9. Anchor the point of view:   Stick to a consistent perspective (I, you, we). Use active voice unless there’s a reason not to.
10. Prefer plaintext over markup

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] net/axgbe: retry transient SFP I2C read failures
  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
  2026-11-22 17:30   ` Stephen Hemminger
  2026-11-23 11:52   ` [PATCH] [PATCH v3] net/axgbe: wait for SFP cage I2C readiness on first probe Ajit Kumar
  1 sibling, 2 replies; 6+ messages in thread
From: Ajit Kumar @ 2026-11-19 17:35 UTC (permalink / raw)
  To: dev; +Cc: stephen

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net/axgbe: retry transient SFP I2C read failures
  2026-11-19 17:35 ` [PATCH v2] " Ajit Kumar
@ 2026-11-22 17:30   ` Stephen Hemminger
  2026-11-23 11:52   ` [PATCH] [PATCH v3] net/axgbe: wait for SFP cage I2C readiness on first probe Ajit Kumar
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2026-11-22 17:30 UTC (permalink / raw)
  To: Ajit Kumar; +Cc: dev

On Thu, 19 Nov 2026 23:05:06 +0530
Ajit Kumar <Ajit.Kumar@amd.com> wrote:

> 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>

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] [PATCH v3] net/axgbe: wait for SFP cage I2C readiness on first probe
  2026-11-19 17:35 ` [PATCH v2] " Ajit Kumar
  2026-11-22 17:30   ` Stephen Hemminger
@ 2026-11-23 11:52   ` Ajit Kumar
  2026-11-23 18:43     ` Stephen Hemminger
  1 sibling, 1 reply; 6+ messages in thread
From: Ajit Kumar @ 2026-11-23 11:52 UTC (permalink / raw)
  To: dev; +Cc: stephen

From: Ajit Kumar <ajit.kumar@amd.com>

A port's first I2C access to its SFP cage after axgbe_phy_start() can
fail with a quick NACK (-ENOTCONN) or a stall until the 1-second I2C
timeout (-ETIMEDOUT). This is distinct from the cross-port race fixed
by the driver-wide I2C/MDIO bus mutex: it reproduces on a single port
with no sibling active, right after that port's own phy_start().

v2 retried these codes inside axgbe_phy_i2c_read(), gated by a flag
set on first success. Two problems: the flag lives in phy_data,
allocated once at probe and never cleared across phy_start()/
phy_stop(), so it doesn't track the access it's meant to gate; and a
device that never responds never sets it, so a persistent fault pays
the extra retry on every later link_update() poll, unbounded. The
retry also ran while holding the bus mutex, blocking other ports for
its duration, the concern raised against the original combined patch.

Drop the retry and the flag. Instead, wait briefly in
axgbe_phy_start() before the first SFP probe, before the bus mutex is
even taken. Fixed, known cost per phy_start(), no state to go stale,
nothing held while waiting. axgbe_phy_i2c_read() reverts to its
original -EAGAIN-only retry, unchanged.

Fixes: a5c7273771e8 ("net/axgbe: add phy programming APIs")
Cc: stable@dpdk.org

Signed-off-by: Ajit Kumar <ajit.kumar@amd.com>
---
Depends on the driver-wide I2C/MDIO bus mutex from "net/axgbe:
serialize PHY and link status access" for the cross-port case;
applies independently otherwise.

v3: dropped the retry/flag design, replaced with a settle delay before
the first SFP probe in axgbe_phy_start(), outside the bus mutex.
axgbe_phy_i2c_read() is unchanged from upstream.
v2: gated the extended retry with a per-port settled flag (bounded to
first access, per CI bot); switched to a real sleep; shortened the
comment.
---
 drivers/net/axgbe/axgbe_phy_impl.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 55d45bfb7b..83e6a16753 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -2520,6 +2520,8 @@ static void axgbe_phy_stop(struct axgbe_port *pdata)
 	pdata->i2c_if.i2c_stop(pdata);
 }
 
+#define AXGBE_SFP_I2C_SETTLE_DELAY_US	2000
+
 static int axgbe_phy_start(struct axgbe_port *pdata)
 {
 	struct axgbe_phy_data *phy_data = pdata->phy_data;
@@ -2536,9 +2538,16 @@ static int axgbe_phy_start(struct axgbe_port *pdata)
 	/* Reset CDR support */
 	axgbe_phy_cdr_track(pdata);
 
-	/* After starting the I2C controller, we can check for an SFP */
+	/*
+	 * After starting the I2C controller, we can check for an SFP. The
+	 * cage's GPIO expander/mux may not yet be ready to respond to the
+	 * very first access, so give it a short settle delay before the
+	 * first probe instead of failing and leaving recovery to a later
+	 * poll.
+	 */
 	switch (phy_data->port_mode) {
 	case AXGBE_PORT_MODE_SFP:
+		rte_delay_us_sleep(AXGBE_SFP_I2C_SETTLE_DELAY_US);
 		axgbe_phy_sfp_detect(pdata);
 		break;
 	default:
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] [PATCH v3] net/axgbe: wait for SFP cage I2C readiness on first probe
  2026-11-23 11:52   ` [PATCH] [PATCH v3] net/axgbe: wait for SFP cage I2C readiness on first probe Ajit Kumar
@ 2026-11-23 18:43     ` Stephen Hemminger
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2026-11-23 18:43 UTC (permalink / raw)
  To: Ajit Kumar; +Cc: dev

On Mon, 23 Nov 2026 17:22:24 +0530
Ajit Kumar <Ajit.Kumar@amd.com> wrote:

> From: Ajit Kumar <ajit.kumar@amd.com>
> 
> A port's first I2C access to its SFP cage after axgbe_phy_start() can
> fail with a quick NACK (-ENOTCONN) or a stall until the 1-second I2C
> timeout (-ETIMEDOUT). This is distinct from the cross-port race fixed
> by the driver-wide I2C/MDIO bus mutex: it reproduces on a single port
> with no sibling active, right after that port's own phy_start().
> 
> v2 retried these codes inside axgbe_phy_i2c_read(), gated by a flag
> set on first success. Two problems: the flag lives in phy_data,
> allocated once at probe and never cleared across phy_start()/
> phy_stop(), so it doesn't track the access it's meant to gate; and a
> device that never responds never sets it, so a persistent fault pays
> the extra retry on every later link_update() poll, unbounded. The
> retry also ran while holding the bus mutex, blocking other ports for
> its duration, the concern raised against the original combined patch.
> 
> Drop the retry and the flag. Instead, wait briefly in
> axgbe_phy_start() before the first SFP probe, before the bus mutex is
> even taken. Fixed, known cost per phy_start(), no state to go stale,
> nothing held while waiting. axgbe_phy_i2c_read() reverts to its
> original -EAGAIN-only retry, unchanged.
> 
> Fixes: a5c7273771e8 ("net/axgbe: add phy programming APIs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ajit Kumar <ajit.kumar@amd.com>
> ---
> Depends on the driver-wide I2C/MDIO bus mutex from "net/axgbe:
> serialize PHY and link status access" for the cross-port case;
> applies independently otherwise.
> 
> v3: dropped the retry/flag design, replaced with a settle delay before
> the first SFP probe in axgbe_phy_start(), outside the bus mutex.
> axgbe_phy_i2c_read() is unchanged from upstream.
> v2: gated the extended retry with a per-port settled flag (bounded to
> first access, per CI bot); switched to a real sleep; shortened the
> comment.

Yes, dealing with real hardware is hard, and seems reasonable.

AI review said:

Subject: Re: [PATCH v3] net/axgbe: wait for SFP cage I2C readiness on first probe

Applies on top of the bus mutex patch and builds clean. A delay
before the first probe is the right shape, and it fixes both v2
problems. But nothing says what the delay waits for, and nothing
shows that 2ms is enough.

Warning

The delay is not tied to any hardware event. axgbe_i2c_start() only
sets pdata->i2c.started, and the controller is enabled separately for
each transfer in axgbe_i2c_xfer(). So "after starting the I2C
controller" there is nothing new to settle. Before the delay,
axgbe_phy_set_mode() has already run the redriver programming (I2C or
MDIO) and a firmware rate change mailbox command that it waits on.
Whatever the expander is waiting for, it is not i2c_start().

Please say what the cage is waiting for: power or reset release
after phy_stop(), the mux left on a channel, or firmware still using
the bus after the rate change. Then wait for that condition instead
of a fixed delay. If a fixed delay really is the only option, say
where 2ms comes from, such as a datasheet value or measured margin.

v3 has no test result. The v2 validation was for a different change.
Please report results for this exact patch on the CRB and FWA-1081,
including whether the -ETIMEDOUT case (a full 1s stall) goes away
with a 2ms pre-delay. That would be surprising and needs data.

Info

The second paragraph of the commit message is v2 history; move it
below "---". The commit message should describe this change only.

The subject has "[PATCH] [PATCH v3]"; use --subject-prefix="PATCH v3"
or -v3 only.

The new comment can be one line once the cause is known, for example:

	/* SFP GPIO expander needs <N>us after <event> */


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-23 18:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2] " Ajit Kumar
2026-11-22 17:30   ` Stephen Hemminger
2026-11-23 11:52   ` [PATCH] [PATCH v3] net/axgbe: wait for SFP cage I2C readiness on first probe Ajit Kumar
2026-11-23 18:43     ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox