]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: phy: don't clear BMCR in genphy_soft_reset
authorHeiner Kallweit <hkallweit1@gmail.com>
Fri, 22 Mar 2019 19:00:20 +0000 (20:00 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Aug 2019 11:38:54 +0000 (12:38 +0100)
commit d29f5aa0bc0c321e1b9e4658a2a7e08e885da52a upstream.

So far we effectively clear the BMCR register. Some PHY's can deal
with this (e.g. because they reset BMCR to a default as part of a
soft-reset) whilst on others this causes issues because e.g. the
autoneg bit is cleared. Marvell is an example, see also thread [0].
So let's be a little bit more gentle and leave all bits we're not
interested in as-is. This change is needed for PHY drivers to
properly deal with the original patch.

[0] https://marc.info/?t=155264050700001&r=1&w=2

Fixes: 6e2d85ec0559 ("net: phy: Stop with excessive soft reset")
Tested-by: Phil Reid <preid@electromag.com.au>
Tested-by: liweihang <liweihang@hisilicon.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16: open-code phy_set_bits()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/phy/phy_device.c

index 7a6d2f8c5201acead155a88ebcb5acd826cac984..77fcb1bd81bcaa2f3e218d25e9ad36344fb3d1be 100644 (file)
@@ -1072,7 +1072,10 @@ int genphy_soft_reset(struct phy_device *phydev)
 {
        int ret;
 
-       ret = phy_write(phydev, MII_BMCR, BMCR_RESET);
+       ret = phy_read(phydev, MII_BMCR);
+       if (ret < 0)
+               return ret;
+       ret = phy_write(phydev, MII_BMCR, ret | BMCR_RESET);
        if (ret < 0)
                return ret;