[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220331114819.14929-1-huangguangbin2@huawei.com>
Date: Thu, 31 Mar 2022 19:48:19 +0800
From: Guangbin Huang <huangguangbin2@...wei.com>
To: <andrew@...n.ch>, <davem@...emloft.net>, <kuba@...nel.org>,
<o.rempel@...gutronix.de>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<lipeng321@...wei.com>, <huangguangbin2@...wei.com>,
<chenhao288@...ilicon.com>
Subject: [PATCH] net: phy: genphy_loopback: fix loopback failed when speed is unknown
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@...wei.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
Powered by blists - more mailing lists