1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Date: Thu, 5 Jan 2017 00:23:40 +0000
3 Subject: [PATCH] net: phy: don't double-read clause 45 status register
5 One of the design decisions behind the link status bit in the status
6 register is that it latches low on link loss. This is so that link loss
7 events are not missed. Double-reading the status register means that we
8 always read the current state of the link, clearing any link loss event.
10 This can cause problems - for example, if the link has negotiated a
11 different set of operating parameters, these will not be communicated
12 to the MAC as the PHY state machine will still think that the link has
15 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
18 --- a/drivers/net/phy/phy-c45.c
19 +++ b/drivers/net/phy/phy-c45.c
20 @@ -143,12 +143,9 @@ int genphy_c45_read_link(struct phy_devi
21 devad = __ffs(mmd_mask);
22 mmd_mask &= ~BIT(devad);
24 - val = phy_read_mmd(phydev, devad, MDIO_STAT1);
28 - /* Read twice because link state is latched and a
29 - * read moves the current state into the register
30 + /* The link state is latched low so that momentary link
31 + * drops can be detected. Do not double-read the status
32 + * register if the link is down.
34 val = phy_read_mmd(phydev, devad, MDIO_STAT1);