* [PATCH net 0/3] amd-xgbe: RX adaptation and PHY handling fixes
@ 2026-03-04 12:23 Raju Rangoju
2026-03-04 12:23 ` [PATCH net 1/3] amd-xgbe: fix link status handling in xgbe_rx_adaptation Raju Rangoju
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Raju Rangoju @ 2026-03-04 12:23 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, pabeni, kuba, edumazet, davem, andrew+netdev, horms,
Shyam-sundar.S-k, Raju Rangoju
This series fixes several issues in the amd-xgbe driver related to RX
adaptation and PHY handling in 10GBASE-KR mode, particularly when
auto-negotiation is disabled.
Patch 1 fixes link status handling during RX adaptation by correctly
reading the latched link status bit so transient link drops are
detected without losing the current state.
Patch 2 prevents CRC errors that can occur when performing RX
adaptation with auto-negotiation turned off. The driver now stops
TX/RX before re-triggering RX adaptation and only re-enables traffic
once adaptation completes and the link is confirmed up, ensuring
packets are not corrupted during the adaptation window.
Patch 3 restores the intended ordering of PHY reset relative to
phy_start(), making sure PHY settings are reset before the PHY is
started instead of afterwards.
Raju Rangoju (3):
amd-xgbe: fix link status handling in xgbe_rx_adaptation
amd-xgbe: prevent CRC errors during RX adaptation with AN disabled
amd-xgbe: reset PHY settings before starting PHY
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 15 ++--
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 78 +++++++++++++++++++--
drivers/net/ethernet/amd/xgbe/xgbe.h | 4 ++
3 files changed, 83 insertions(+), 14 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net 1/3] amd-xgbe: fix link status handling in xgbe_rx_adaptation
2026-03-04 12:23 [PATCH net 0/3] amd-xgbe: RX adaptation and PHY handling fixes Raju Rangoju
@ 2026-03-04 12:23 ` Raju Rangoju
2026-03-04 12:23 ` [PATCH net 2/3] amd-xgbe: prevent CRC errors during RX adaptation with AN disabled Raju Rangoju
2026-03-04 12:23 ` [PATCH net 3/3] amd-xgbe: reset PHY settings before starting PHY Raju Rangoju
2 siblings, 0 replies; 6+ messages in thread
From: Raju Rangoju @ 2026-03-04 12:23 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, pabeni, kuba, edumazet, davem, andrew+netdev, horms,
Shyam-sundar.S-k, Raju Rangoju
The link status bit is latched low to allow detection of momentary
link drops. If the status indicates that the link is already down,
read it again to obtain the current state.
Fixes: 16ceda2ef683 ("amd-xgbe: do not double read link status")
Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
index 1dbfa9d4360d..457d6049291f 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
@@ -1964,11 +1964,20 @@ static void xgbe_rx_adaptation(struct xgbe_prv_data *pdata)
/* Step 4: Check for Block lock */
- /* Link status is latched low, so read once to clear
- * and then read again to get current state
- */
- reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
+ if (reg < 0)
+ goto set_mode;
+
+ /* Link status is latched low so that momentary link drops
+ * can be detected. If link was already down read again
+ * to get the latest state.
+ */
+ if (!pdata->phy.link && !(reg & MDIO_STAT1_LSTATUS)) {
+ reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
+ if (reg < 0)
+ goto set_mode;
+ }
+
if (reg & MDIO_STAT1_LSTATUS) {
/* If the block lock is found, update the helpers
* and declare the link up
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net 2/3] amd-xgbe: prevent CRC errors during RX adaptation with AN disabled
2026-03-04 12:23 [PATCH net 0/3] amd-xgbe: RX adaptation and PHY handling fixes Raju Rangoju
2026-03-04 12:23 ` [PATCH net 1/3] amd-xgbe: fix link status handling in xgbe_rx_adaptation Raju Rangoju
@ 2026-03-04 12:23 ` Raju Rangoju
2026-03-04 13:40 ` Maxime Chevallier
2026-03-04 12:23 ` [PATCH net 3/3] amd-xgbe: reset PHY settings before starting PHY Raju Rangoju
2 siblings, 1 reply; 6+ messages in thread
From: Raju Rangoju @ 2026-03-04 12:23 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, pabeni, kuba, edumazet, davem, andrew+netdev, horms,
Shyam-sundar.S-k, Raju Rangoju
When operating in 10GBASE-KR mode with auto-negotiation disabled and RX
adaptation enabled, CRC errors can occur during the RX adaptation
process. This happens because the driver continues transmitting and
receiving packets while adaptation is in progress.
Fix this by stopping TX/RX immediately when the link goes down and RX
adaptation needs to be re-triggered, and only re-enabling TX/RX after
adaptation completes and the link is confirmed up. Introduce a flag to
track whether TX/RX was disabled for adaptation so it can be restored
correctly.
This prevents packets from being transmitted or received during the RX
adaptation window and avoids CRC errors from corrupted frames.
Fixes: 4f3b20bfbb75 ("amd-xgbe: add support for rx-adaptation")
Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 61 ++++++++++++++++++++-
drivers/net/ethernet/amd/xgbe/xgbe.h | 4 ++
2 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
index 457d6049291f..880949051c3c 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
@@ -2017,6 +2017,50 @@ static void xgbe_phy_rx_adaptation(struct xgbe_prv_data *pdata)
xgbe_rx_adaptation(pdata);
}
+/*
+ * xgbe_phy_stop_data_path - Stop TX/RX to prevent packet corruption
+ * @pdata: driver private data
+ *
+ * This function stops the data path (TX and RX) to prevent packet
+ * corruption during critical PHY operations like RX adaptation.
+ * Must be called before initiating RX adaptation when link goes down.
+ */
+static void xgbe_phy_stop_data_path(struct xgbe_prv_data *pdata)
+{
+ if (pdata->rx_adapt_data_path_stopped)
+ return;
+
+ netif_dbg(pdata, link, pdata->netdev,
+ "stopping data path for RX adaptation\n");
+
+ /* Stop TX/RX to prevent packet corruption during RX adaptation */
+ pdata->hw_if.disable_tx(pdata);
+ pdata->hw_if.disable_rx(pdata);
+
+ pdata->rx_adapt_data_path_stopped = true;
+}
+
+/*
+ * xgbe_phy_start_data_path - Re-enable TX/RX after RX adaptation
+ * @pdata: driver private data
+ *
+ * This function re-enables the data path (TX and RX) after RX adaptation
+ * has completed successfully. Only called when link is confirmed up.
+ */
+static void xgbe_phy_start_data_path(struct xgbe_prv_data *pdata)
+{
+ if (!pdata->rx_adapt_data_path_stopped)
+ return;
+
+ netif_dbg(pdata, link, pdata->netdev,
+ "restarting data path after RX adaptation\n");
+
+ pdata->hw_if.enable_rx(pdata);
+ pdata->hw_if.enable_tx(pdata);
+
+ pdata->rx_adapt_data_path_stopped = false;
+}
+
static void xgbe_phy_rx_reset(struct xgbe_prv_data *pdata)
{
int reg;
@@ -2826,6 +2870,10 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
if (pdata->en_rx_adap) {
/* if the link is available and adaptation is done,
* declare link up
+ *
+ * Note: When link is up and adaptation is done, we can
+ * safely re-enable the data path if it was stopped
+ * for adaptation.
*/
if ((reg & MDIO_STAT1_LSTATUS) && pdata->rx_adapt_done)
return 1;
@@ -2833,6 +2881,14 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
* retrigger the adaptation logic. (if the mode is not set,
* then issue mailbox command first)
*/
+
+ /* CRITICAL: Stop data path BEFORE triggering RX adaptation
+ * to prevent CRC errors from packets corrupted during
+ * the adaptation process. This is especially important
+ * when AN is OFF in 10G KR mode.
+ */
+ xgbe_phy_stop_data_path(pdata);
+
if (pdata->mode_set) {
xgbe_phy_rx_adaptation(pdata);
} else {
@@ -2840,8 +2896,11 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
xgbe_phy_set_mode(pdata, phy_data->cur_mode);
}
- if (pdata->rx_adapt_done)
+ if (pdata->rx_adapt_done) {
+ /* Adaptation complete, safe to re-enable data path */
+ xgbe_phy_start_data_path(pdata);
return 1;
+ }
} else if (reg & MDIO_STAT1_LSTATUS)
return 1;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index 4333d269ee84..75c021b38a28 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -1266,6 +1266,10 @@ struct xgbe_prv_data {
bool en_rx_adap;
int rx_adapt_retries;
bool rx_adapt_done;
+ /* Flag to track if data path (TX/RX) was stopped for RX adaptation.
+ * This prevents packet corruption during the adaptation window.
+ */
+ unsigned int rx_adapt_data_path_stopped;
bool mode_set;
bool sph;
};
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net 3/3] amd-xgbe: reset PHY settings before starting PHY
2026-03-04 12:23 [PATCH net 0/3] amd-xgbe: RX adaptation and PHY handling fixes Raju Rangoju
2026-03-04 12:23 ` [PATCH net 1/3] amd-xgbe: fix link status handling in xgbe_rx_adaptation Raju Rangoju
2026-03-04 12:23 ` [PATCH net 2/3] amd-xgbe: prevent CRC errors during RX adaptation with AN disabled Raju Rangoju
@ 2026-03-04 12:23 ` Raju Rangoju
2026-03-04 13:44 ` Maxime Chevallier
2 siblings, 1 reply; 6+ messages in thread
From: Raju Rangoju @ 2026-03-04 12:23 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, pabeni, kuba, edumazet, davem, andrew+netdev, horms,
Shyam-sundar.S-k, Raju Rangoju
commit f93505f35745 ("amd-xgbe: let the MAC manage PHY PM") moved
xgbe_phy_reset() from xgbe_open() to xgbe_start(), placing it after
phy_start(). As a result, the PHY settings were being reset after the
PHY had already started.
Reorder the calls so that the PHY settings are reset before
phy_start() is invoked.
Fixes: f93505f35745 ("amd-xgbe: let the MAC manage PHY PM")
Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 8b79d88480db..fd4f451efcb2 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1271,6 +1271,12 @@ static int xgbe_start(struct xgbe_prv_data *pdata)
if (ret)
goto err_napi;
+ /* Reset the phy settings */
+ ret = xgbe_phy_reset(pdata);
+ if (ret)
+ goto err_irqs;
+
+ /* Start the phy */
ret = phy_if->phy_start(pdata);
if (ret)
goto err_irqs;
@@ -1280,11 +1286,6 @@ static int xgbe_start(struct xgbe_prv_data *pdata)
udp_tunnel_nic_reset_ntf(netdev);
- /* Reset the phy settings */
- ret = xgbe_phy_reset(pdata);
- if (ret)
- goto err_txrx;
-
netif_tx_start_all_queues(netdev);
xgbe_start_timers(pdata);
@@ -1294,10 +1295,6 @@ static int xgbe_start(struct xgbe_prv_data *pdata)
return 0;
-err_txrx:
- hw_if->disable_rx(pdata);
- hw_if->disable_tx(pdata);
-
err_irqs:
xgbe_free_irqs(pdata);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net 2/3] amd-xgbe: prevent CRC errors during RX adaptation with AN disabled
2026-03-04 12:23 ` [PATCH net 2/3] amd-xgbe: prevent CRC errors during RX adaptation with AN disabled Raju Rangoju
@ 2026-03-04 13:40 ` Maxime Chevallier
0 siblings, 0 replies; 6+ messages in thread
From: Maxime Chevallier @ 2026-03-04 13:40 UTC (permalink / raw)
To: Raju Rangoju, netdev
Cc: linux-kernel, pabeni, kuba, edumazet, davem, andrew+netdev, horms,
Shyam-sundar.S-k
Hi Raju,
On 04/03/2026 13:23, Raju Rangoju wrote:
> When operating in 10GBASE-KR mode with auto-negotiation disabled and RX
> adaptation enabled, CRC errors can occur during the RX adaptation
> process. This happens because the driver continues transmitting and
> receiving packets while adaptation is in progress.
>
> Fix this by stopping TX/RX immediately when the link goes down and RX
> adaptation needs to be re-triggered, and only re-enabling TX/RX after
> adaptation completes and the link is confirmed up. Introduce a flag to
> track whether TX/RX was disabled for adaptation so it can be restored
> correctly.
>
> This prevents packets from being transmitted or received during the RX
> adaptation window and avoids CRC errors from corrupted frames.
>
> Fixes: 4f3b20bfbb75 ("amd-xgbe: add support for rx-adaptation")
> Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
Small nit on my side :
[...]
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
> index 4333d269ee84..75c021b38a28 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe.h
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
> @@ -1266,6 +1266,10 @@ struct xgbe_prv_data {
> bool en_rx_adap;
> int rx_adapt_retries;
> bool rx_adapt_done;
> + /* Flag to track if data path (TX/RX) was stopped for RX adaptation.
> + * This prevents packet corruption during the adaptation window.
> + */
> + unsigned int rx_adapt_data_path_stopped;
This is only ever set as true/false, maybe make it a bool ?
> bool mode_set;
> bool sph;
> };
Maxime
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net 3/3] amd-xgbe: reset PHY settings before starting PHY
2026-03-04 12:23 ` [PATCH net 3/3] amd-xgbe: reset PHY settings before starting PHY Raju Rangoju
@ 2026-03-04 13:44 ` Maxime Chevallier
0 siblings, 0 replies; 6+ messages in thread
From: Maxime Chevallier @ 2026-03-04 13:44 UTC (permalink / raw)
To: Raju Rangoju, netdev
Cc: linux-kernel, pabeni, kuba, edumazet, davem, andrew+netdev, horms,
Shyam-sundar.S-k
Hi Raju,
On 04/03/2026 13:23, Raju Rangoju wrote:
> commit f93505f35745 ("amd-xgbe: let the MAC manage PHY PM") moved
> xgbe_phy_reset() from xgbe_open() to xgbe_start(), placing it after
> phy_start(). As a result, the PHY settings were being reset after the
> PHY had already started.
>
> Reorder the calls so that the PHY settings are reset before
> phy_start() is invoked.
>
> Fixes: f93505f35745 ("amd-xgbe: let the MAC manage PHY PM")
> Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
This looks good to me,
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-04 13:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04 12:23 [PATCH net 0/3] amd-xgbe: RX adaptation and PHY handling fixes Raju Rangoju
2026-03-04 12:23 ` [PATCH net 1/3] amd-xgbe: fix link status handling in xgbe_rx_adaptation Raju Rangoju
2026-03-04 12:23 ` [PATCH net 2/3] amd-xgbe: prevent CRC errors during RX adaptation with AN disabled Raju Rangoju
2026-03-04 13:40 ` Maxime Chevallier
2026-03-04 12:23 ` [PATCH net 3/3] amd-xgbe: reset PHY settings before starting PHY Raju Rangoju
2026-03-04 13:44 ` Maxime Chevallier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox