All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] phylib EEE updates
@ 2017-03-31  9:36 Russell King - ARM Linux
  2017-03-31  9:37 ` [PATCH v3 1/3] net: phy: avoid setting unsupported EEE advertisments Russell King
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Russell King - ARM Linux @ 2017-03-31  9:36 UTC (permalink / raw)
  To: David S. Miller; +Cc: Andrew Lunn, Florian Fainelli, netdev

David,

This series of patches depends on the previous set of changes, and is
therefore net-next material.

While testing the EEE code, I discovered a number of issues:

1. It is possible to enable advertisment of EEE modes which are not
   supported by the hardware.  We omit to check the supported modes
   and mask off those modes that are not supported before writing the
   EEE advertisment register.

2. We need to restart autonegotiation after a change of the EEE
   advertisment, otherwise the link partner does not see the updated
   EEE modes.

3. SGMII connected PHYs are also capable of supporting EEE.

Through discussion with Florian, it has been decided to remove the check
for the PHY interface mode in patch (3).

 drivers/net/phy/phy.c | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

v2: fix "phy_restart_aneg" build error identified by 0-day
v3: drop RFC tag, replace 3rd patch

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/3] net: phy: avoid setting unsupported EEE advertisments
  2017-03-31  9:36 [PATCH v3 0/3] phylib EEE updates Russell King - ARM Linux
@ 2017-03-31  9:37 ` Russell King
  2017-03-31  9:37 ` [PATCH v3 2/3] net: phy: restart phy autonegotiation after EEE advertisment change Russell King
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King @ 2017-03-31  9:37 UTC (permalink / raw)
  To: David S. Miller; +Cc: Andrew Lunn, Florian Fainelli, netdev

We currently allow userspace to set any EEE advertisments it desires,
whether or not the PHY supports them.  For example:

 # ethtool --set-eee eth1 advertise 0xffffffff
 # ethtool --show-eee eth1
 EEE Settings for eth1:
        EEE status: disabled
        Tx LPI: disabled
        Supported EEE link modes:  100baseT/Full
                                   1000baseT/Full
                                   10000baseT/Full
        Advertised EEE link modes:  100baseT/Full
                                    1000baseT/Full
                                    1000baseKX/Full
                                    10000baseT/Full
                                    10000baseKX4/Full
                                    10000baseKR/Full

Clearly, this is not sane, we should only allow link modes that are
supported to be advertised (as we do elsewhere.)  Ensure that we mask
the MDIO_AN_EEE_ADV value with the capabilities retrieved from the
MDIO_PCS_EEE_ABLE register.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phy.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index ba4676ee9018..7b1c93b0233a 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1332,17 +1332,22 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
  */
 int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
 {
-	int val = ethtool_adv_to_mmd_eee_adv_t(data->advertised);
+	int cap, adv;
 
 	if (!phydev->drv)
 		return -EIO;
 
-	/* Mask prohibited EEE modes */
-	val &= ~phydev->eee_broken_modes;
+	/* Get Supported EEE */
+	cap = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
+	if (cap < 0)
+		return cap;
 
-	phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, val);
+	adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
 
-	return 0;
+	/* Mask prohibited EEE modes */
+	adv &= ~phydev->eee_broken_modes;
+
+	return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
 }
 EXPORT_SYMBOL(phy_ethtool_set_eee);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/3] net: phy: restart phy autonegotiation after EEE advertisment change
  2017-03-31  9:36 [PATCH v3 0/3] phylib EEE updates Russell King - ARM Linux
  2017-03-31  9:37 ` [PATCH v3 1/3] net: phy: avoid setting unsupported EEE advertisments Russell King
@ 2017-03-31  9:37 ` Russell King
  2017-03-31  9:37 ` [PATCH v3 3/3] net: phy: allow EEE with any interface mode Russell King
  2017-04-02  3:04 ` [PATCH v3 0/3] phylib EEE updates David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King @ 2017-03-31  9:37 UTC (permalink / raw)
  To: David S. Miller; +Cc: Andrew Lunn, Florian Fainelli, netdev

When the EEE advertisment is changed, we should restart autonegotiation
to update the link partner with the new EEE settings.  Add this trigger
but only if the advertisment has changed.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phy.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 7b1c93b0233a..345251f21699 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1332,7 +1332,7 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
  */
 int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
 {
-	int cap, adv;
+	int cap, old_adv, adv, ret;
 
 	if (!phydev->drv)
 		return -EIO;
@@ -1342,12 +1342,29 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
 	if (cap < 0)
 		return cap;
 
+	old_adv = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
+	if (old_adv < 0)
+		return old_adv;
+
 	adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
 
 	/* Mask prohibited EEE modes */
 	adv &= ~phydev->eee_broken_modes;
 
-	return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
+	if (old_adv != adv) {
+		ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
+		if (ret < 0)
+			return ret;
+
+		/* Restart autonegotiation so the new modes get sent to the
+		 * link partner.
+		 */
+		ret = genphy_restart_aneg(phydev);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
 }
 EXPORT_SYMBOL(phy_ethtool_set_eee);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 3/3] net: phy: allow EEE with any interface mode
  2017-03-31  9:36 [PATCH v3 0/3] phylib EEE updates Russell King - ARM Linux
  2017-03-31  9:37 ` [PATCH v3 1/3] net: phy: avoid setting unsupported EEE advertisments Russell King
  2017-03-31  9:37 ` [PATCH v3 2/3] net: phy: restart phy autonegotiation after EEE advertisment change Russell King
@ 2017-03-31  9:37 ` Russell King
  2017-04-02  3:04 ` [PATCH v3 0/3] phylib EEE updates David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King @ 2017-03-31  9:37 UTC (permalink / raw)
  To: David S. Miller; +Cc: Andrew Lunn, Florian Fainelli, netdev

EEE is able to work in any PHY interface mode, there is nothing which
fundamentally restricts it to only a few modes.  For example, EEE works
in SGMII mode with the Marvell 88E1512.

Rather than just adding SGMII mode to the list, Florian suggests
removing the list of interface modes entirely:

  It actually sounds like we should just kill the check entirely,
  it does not appear that any of the interface mode would not
  fundamentally be able to support EEE, because the "lowest" mode
  we support is MII, and even there it's quite possible to support
  EEE.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phy.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 345251f21699..867c42154087 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1208,15 +1208,8 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
 		return -EIO;
 
 	/* According to 802.3az,the EEE is supported only in full duplex-mode.
-	 * Also EEE feature is active when core is operating with MII, GMII
-	 * or RGMII (all kinds). Internal PHYs are also allowed to proceed and
-	 * should return an error if they do not support EEE.
 	 */
-	if ((phydev->duplex == DUPLEX_FULL) &&
-	    ((phydev->interface == PHY_INTERFACE_MODE_MII) ||
-	    (phydev->interface == PHY_INTERFACE_MODE_GMII) ||
-	     phy_interface_is_rgmii(phydev) ||
-	     phy_is_internal(phydev))) {
+	if (phydev->duplex == DUPLEX_FULL) {
 		int eee_lp, eee_cap, eee_adv;
 		u32 lp, cap, adv;
 		int status;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 0/3] phylib EEE updates
  2017-03-31  9:36 [PATCH v3 0/3] phylib EEE updates Russell King - ARM Linux
                   ` (2 preceding siblings ...)
  2017-03-31  9:37 ` [PATCH v3 3/3] net: phy: allow EEE with any interface mode Russell King
@ 2017-04-02  3:04 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-04-02  3:04 UTC (permalink / raw)
  To: linux; +Cc: andrew, f.fainelli, netdev

From: Russell King - ARM Linux <linux@armlinux.org.uk>
Date: Fri, 31 Mar 2017 10:36:46 +0100

> This series of patches depends on the previous set of changes, and
> is therefore net-next material.

Series applied, thank you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-02  3:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-31  9:36 [PATCH v3 0/3] phylib EEE updates Russell King - ARM Linux
2017-03-31  9:37 ` [PATCH v3 1/3] net: phy: avoid setting unsupported EEE advertisments Russell King
2017-03-31  9:37 ` [PATCH v3 2/3] net: phy: restart phy autonegotiation after EEE advertisment change Russell King
2017-03-31  9:37 ` [PATCH v3 3/3] net: phy: allow EEE with any interface mode Russell King
2017-04-02  3:04 ` [PATCH v3 0/3] phylib EEE updates David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.