]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: stmmac: enable EEE in MII, GMII or RGMII only
authorJerome Brunet <jbrunet@baylibre.com>
Wed, 3 Jan 2018 15:46:29 +0000 (16:46 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jan 2018 08:29:30 +0000 (09:29 +0100)
[ Upstream commit 879626e3a52630316d817cbda7cec9a5446d1d82 ]

Note in the databook - Section 4.4 - EEE :
" The EEE feature is not supported when the MAC is configured to use the
TBI, RTBI, SMII, RMII or SGMII single PHY interface. Even if the MAC
supports multiple PHY interfaces, you should activate the EEE mode only
when the MAC is operating with GMII, MII, or RGMII interface."

Applying this restriction solves a stability issue observed on Amlogic
gxl platforms operating with RMII interface and the internal PHY.

Fixes: 83bf79b6bb64 ("stmmac: disable at run-time the EEE if not supported")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
include/linux/phy.h

index c769da8d6f3a02e5d9e9f56129806f0574980730..103ae8ef8643d2f7b291dcd39435660989fef2f4 100644 (file)
@@ -277,8 +277,14 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
 {
        char *phy_bus_name = priv->plat->phy_bus_name;
        unsigned long flags;
+       int interface = priv->plat->interface;
        bool ret = false;
 
+       if ((interface != PHY_INTERFACE_MODE_MII) &&
+           (interface != PHY_INTERFACE_MODE_GMII) &&
+           !phy_interface_mode_is_rgmii(interface))
+               goto out;
+
        /* Using PCS we cannot dial with the phy registers at this stage
         * so we do not support extra feature like EEE.
         */
index bc79f855fc328004baca64376e8a81eee349d0d2..2b3ca63e1f4c1fa764da9d14b5523c7479330f23 100644 (file)
@@ -677,6 +677,17 @@ static inline int phy_write_mmd(struct phy_device *phydev, int devad,
        return mdiobus_write(phydev->bus, phydev->addr, regnum, val);
 }
 
+/**
+ * phy_interface_mode_is_rgmii - Convenience function for testing if a
+ * PHY interface mode is RGMII (all variants)
+ * @mode: the phy_interface_t enum
+ */
+static inline bool phy_interface_mode_is_rgmii(phy_interface_t mode)
+{
+       return mode >= PHY_INTERFACE_MODE_RGMII &&
+               mode <= PHY_INTERFACE_MODE_RGMII_TXID;
+};
+
 /**
  * phy_write_mmd_indirect - writes data to the MMD registers
  * @phydev: The PHY device