linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phy: genphy_loopback: fix loopback failed when speed is unknown
@ 2022-03-31 11:48 Guangbin Huang
  2022-03-31 12:23 ` Andrew Lunn
  0 siblings, 1 reply; 10+ messages in thread
From: Guangbin Huang @ 2022-03-31 11:48 UTC (permalink / raw)
  To: andrew, davem, kuba, o.rempel
  Cc: netdev, linux-kernel, lipeng321, huangguangbin2, chenhao288

If phy link status is down because link partner goes down, the phy speed
will be updated to SPEED_UNKNOWN when autoneg on with general phy driver.
If test loopback in this case, the phy speed will be set to 10M. However,
the speed of mac may not be 10M, it causes loopback test failed.

To fix this problem, if speed is SPEED_UNKNOWN, don't configure link speed.

Fixes: 014068dcb5b1 ("net: phy: genphy_loopback: add link speed configuration")
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/phy/phy_device.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8406ac739def..5001bb1a019c 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2618,6 +2618,9 @@ int genphy_loopback(struct phy_device *phydev, bool enable)
 			ctl |= BMCR_SPEED1000;
 		else if (phydev->speed == SPEED_100)
 			ctl |= BMCR_SPEED100;
+		else if (phydev->speed == SPEED_UNKNOWN)
+			return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
+					  BMCR_LOOPBACK);
 
 		if (phydev->duplex == DUPLEX_FULL)
 			ctl |= BMCR_FULLDPLX;
-- 
2.33.0


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

end of thread, other threads:[~2022-04-08 13:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 11:48 [PATCH] net: phy: genphy_loopback: fix loopback failed when speed is unknown Guangbin Huang
2022-03-31 12:23 ` Andrew Lunn
2022-03-31 13:57   ` huangguangbin (A)
2022-03-31 14:26     ` Andrew Lunn
2022-04-01  6:40       ` Oleksij Rempel
2022-04-01 12:14         ` Andrew Lunn
2022-04-07 13:54           ` huangguangbin (A)
2022-04-07 14:45             ` Andrew Lunn
2022-04-08  8:18               ` Oleksij Rempel
2022-04-08 13:04                 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).