All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: fix two issues with linkmode bitmaps
@ 2018-11-25 14:23 Heiner Kallweit
  2018-11-25 16:45 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Heiner Kallweit @ 2018-11-25 14:23 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev

I wondered why ethtool suddenly reports that link partner doesn't
support aneg and GBit modes. It turned out that this is caused by two
bugs in conversion to linkmode bitmaps.

1. In genphy_read_status the value of phydev->lp_advertising is
   overwritten, thus GBit modes aren't reported any longer.
2. In mii_lpa_to_linkmode_lpa_t the aneg bit was overwritten by the
   call to mii_adv_to_linkmode_adv_t.

Fixes: c0ec3c273677 ("net: phy: Convert u32 phydev->lp_advertising to linkmode")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy_device.c | 5 ++++-
 include/linux/mii.h          | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 0904002b1..94f60c08b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1696,6 +1696,7 @@ int genphy_read_status(struct phy_device *phydev)
 	int lpagb = 0;
 	int common_adv;
 	int common_adv_gb = 0;
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(lpa_tmp);
 
 	/* Update the link, but return if there was an error */
 	err = genphy_update_link(phydev);
@@ -1734,7 +1735,9 @@ int genphy_read_status(struct phy_device *phydev)
 		if (lpa < 0)
 			return lpa;
 
-		mii_lpa_to_linkmode_lpa_t(phydev->lp_advertising, lpa);
+		mii_lpa_to_linkmode_lpa_t(lpa_tmp, lpa);
+		linkmode_or(phydev->lp_advertising, phydev->lp_advertising,
+			    lpa_tmp);
 
 		adv = phy_read(phydev, MII_ADVERTISE);
 		if (adv < 0)
diff --git a/include/linux/mii.h b/include/linux/mii.h
index fb7ae4ae8..08450609d 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -413,11 +413,11 @@ static inline void mii_adv_to_linkmode_adv_t(unsigned long *advertising,
 static inline void mii_lpa_to_linkmode_lpa_t(unsigned long *lp_advertising,
 					     u32 lpa)
 {
+	mii_adv_to_linkmode_adv_t(lp_advertising, lpa);
+
 	if (lpa & LPA_LPACK)
 		linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
 				 lp_advertising);
-
-	mii_adv_to_linkmode_adv_t(lp_advertising, lpa);
 }
 
 /**
-- 
2.19.2

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

end of thread, other threads:[~2018-11-26 13:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-25 14:23 [PATCH net-next] net: phy: fix two issues with linkmode bitmaps Heiner Kallweit
2018-11-25 16:45 ` Andrew Lunn
2018-11-25 17:21   ` Heiner Kallweit
2018-11-25 20:47     ` Andrew Lunn
2018-11-26  2:10     ` Andrew Lunn

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.