Skip to content

Commit

Permalink
net: pcs: xpcs: remove double-read of link state when using AN
Browse files Browse the repository at this point in the history
[ Upstream commit ef63461 ]

Phylink does not want the current state of the link when reading the
PCS link state - it wants the latched state. Don't double-read the
MII status register. Phylink will re-read as necessary to capture
transient link-down events as of dbae338 ("net: phylink: Force
retrigger in case of latched link-fail indicator").

The above referenced commit is a dependency for this change, and thus
this change should not be backported to any kernel that does not
contain the above referenced commit.

Fixes: fcb26bd ("net: phy: Add Synopsys DesignWare XPCS MDIO module")
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Russell King (Oracle) authored and gregkh committed May 11, 2023
1 parent f6b05f8 commit 1e9f725
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions drivers/net/pcs/pcs-xpcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ static int xpcs_read_fault_c73(struct dw_xpcs *xpcs,
return 0;
}

static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
static int xpcs_read_link_c73(struct dw_xpcs *xpcs)
{
bool link = true;
int ret;
Expand All @@ -333,15 +333,6 @@ static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
if (!(ret & MDIO_STAT1_LSTATUS))
link = false;

if (an) {
ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1);
if (ret < 0)
return ret;

if (!(ret & MDIO_STAT1_LSTATUS))
link = false;
}

return link;
}

Expand Down Expand Up @@ -935,7 +926,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
int ret;

/* Link needs to be read first ... */
state->link = xpcs_read_link_c73(xpcs, state->an_enabled) > 0 ? 1 : 0;
state->link = xpcs_read_link_c73(xpcs) > 0 ? 1 : 0;

/* ... and then we check the faults. */
ret = xpcs_read_fault_c73(xpcs, state);
Expand Down

0 comments on commit 1e9f725

Please sign in to comment.