amd-xgbe: do not double read link status
[ Upstream commit 16ceda2ef683a50cd0783006c0504e1931cd8879 ]
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: 4f3b20bfbb
("amd-xgbe: add support for rx-adaptation")
Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250701065016.4140707-1-Raju.Rangoju@amd.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f680a4643c
commit
70b32cba5c
@@ -1413,6 +1413,10 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)
|
||||
|
||||
pdata->phy.link = pdata->phy_if.phy_impl.link_status(pdata,
|
||||
&an_restart);
|
||||
/* bail out if the link status register read fails */
|
||||
if (pdata->phy.link < 0)
|
||||
return;
|
||||
|
||||
if (an_restart) {
|
||||
xgbe_phy_config_aneg(pdata);
|
||||
goto adjust_link;
|
||||
|
@@ -2855,8 +2855,7 @@ static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed)
|
||||
static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
|
||||
{
|
||||
struct xgbe_phy_data *phy_data = pdata->phy_data;
|
||||
unsigned int reg;
|
||||
int ret;
|
||||
int reg, ret;
|
||||
|
||||
*an_restart = 0;
|
||||
|
||||
@@ -2890,11 +2889,20 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
if (reg < 0)
|
||||
return reg;
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
|
||||
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
|
||||
|
||||
if (!pdata->phy.link && !(reg & MDIO_STAT1_LSTATUS)) {
|
||||
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
|
||||
if (reg < 0)
|
||||
return reg;
|
||||
}
|
||||
|
||||
if (pdata->en_rx_adap) {
|
||||
/* if the link is available and adaptation is done,
|
||||
@@ -2913,9 +2921,7 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
|
||||
xgbe_phy_set_mode(pdata, phy_data->cur_mode);
|
||||
}
|
||||
|
||||
/* check again for the link and adaptation status */
|
||||
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
|
||||
if ((reg & MDIO_STAT1_LSTATUS) && pdata->rx_adapt_done)
|
||||
if (pdata->rx_adapt_done)
|
||||
return 1;
|
||||
} else if (reg & MDIO_STAT1_LSTATUS)
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user