Skip to content

Commit 16ceda2

Browse files
RajuRangojukuba-moo
authored andcommitted
amd-xgbe: do not double read link status
The link status is latched low so that momentary link drops can be detected. Always double-reading the status defeats this design feature. Only double read if link was already down This prevents unnecessary duplicate readings of the link status. Fixes: 4f3b20b ("amd-xgbe: add support for rx-adaptation") Signed-off-by: Raju Rangoju <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 103406b commit 16ceda2

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-mdio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,10 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)
13041304

13051305
pdata->phy.link = pdata->phy_if.phy_impl.link_status(pdata,
13061306
&an_restart);
1307+
/* bail out if the link status register read fails */
1308+
if (pdata->phy.link < 0)
1309+
return;
1310+
13071311
if (an_restart) {
13081312
xgbe_phy_config_aneg(pdata);
13091313
goto adjust_link;

drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,8 +2746,7 @@ static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed)
27462746
static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
27472747
{
27482748
struct xgbe_phy_data *phy_data = pdata->phy_data;
2749-
unsigned int reg;
2750-
int ret;
2749+
int reg, ret;
27512750

27522751
*an_restart = 0;
27532752

@@ -2781,11 +2780,20 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
27812780
return 0;
27822781
}
27832782

2784-
/* Link status is latched low, so read once to clear
2785-
* and then read again to get current state
2786-
*/
2787-
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
27882783
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
2784+
if (reg < 0)
2785+
return reg;
2786+
2787+
/* Link status is latched low so that momentary link drops
2788+
* can be detected. If link was already down read again
2789+
* to get the latest state.
2790+
*/
2791+
2792+
if (!pdata->phy.link && !(reg & MDIO_STAT1_LSTATUS)) {
2793+
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
2794+
if (reg < 0)
2795+
return reg;
2796+
}
27892797

27902798
if (pdata->en_rx_adap) {
27912799
/* if the link is available and adaptation is done,
@@ -2804,9 +2812,7 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
28042812
xgbe_phy_set_mode(pdata, phy_data->cur_mode);
28052813
}
28062814

2807-
/* check again for the link and adaptation status */
2808-
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
2809-
if ((reg & MDIO_STAT1_LSTATUS) && pdata->rx_adapt_done)
2815+
if (pdata->rx_adapt_done)
28102816
return 1;
28112817
} else if (reg & MDIO_STAT1_LSTATUS)
28122818
return 1;

0 commit comments

Comments
 (0)