mvebu: Migrate uci config to new PCIe path
[openwrt/staging/wigyori.git] / target / linux / mvebu / patches-4.9 / 409-net-phy-don-t-double-read-clause-45-status-register.patch
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
4
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.
9
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
13 remained active.
14
15 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
16 ---
17
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);
23
24 - val = phy_read_mmd(phydev, devad, MDIO_STAT1);
25 - if (val < 0)
26 - return val;
27 -
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.
33 */
34 val = phy_read_mmd(phydev, devad, MDIO_STAT1);
35 if (val < 0)