Skip to contentSkip to conversation

net: stmmac: fix 'ethtool -P' return -EBUSY

PATCH Superseded Hao Chen 2 participants 2 messages Jul 19, 2021

Subsystems (4)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Hao Chen

author
#0 lore raw

PATCH v2 1/1 net: stmmac: fix 'ethtool -P' return -EBUSY

The permanent mac address should be available for query when the device is not up.
NetworkManager, the system network daemon, uses 'ethtool -P' to obtain the permanent address after the kernel start. When the network device is not up, it will return the device busy error with 'ethtool -P'. At that time, it is unable to access the Internet through the permanent address by NetworkManager.
I think that the '.begin' is not used to check if the device is up.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +4 -2
index d0ce608b81c3..7ccb0d738a1c 100644
@@ -412,8 +412,10 @@ static void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level)
 
 static int stmmac_check_if_running(struct net_device *dev)
 {
-	if (!netif_running(dev))
-		return -EBUSY;
+	struct stmmac_priv *priv = netdev_priv(dev);
+
+	pm_runtime_get_sync(priv->device);
+
 	return 0;
 }
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 32 lines

-----Original Message-----
From: Hao Chen <[email protected]>
Sent: 2021年7月19日 15:44
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Hao Chen <[email protected]>
Subject: [PATCH v2] net: stmmac: fix 'ethtool -P' return -EBUSY

The permanent mac address should be available for query when the device is not up.
NetworkManager, the system network daemon, uses 'ethtool -P' to obtain the permanent address after the kernel start. When the network device is not up, it will return the device busy error with 'ethtool -P'. At that time, it is unable to access the Internet through the permanent address by NetworkManager.
I think that the '.begin' is not used to check if the device is up.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +0 -0
index d0ce608b81c3..7ccb0d738a1c 100644
@@ -412,8 +412,10 @@ static void stmmac_ethtool_setmsglevel(struct
 net_device *dev, u32 level)

drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c static void stmmac_ethtool_setmsglevel(struct · line 420

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +4 -2
 
 static int stmmac_check_if_running(struct net_device *dev)  {
-	if (!netif_running(dev))
-		return -EBUSY;
+	struct stmmac_priv *priv = netdev_priv(dev);
+
+	pm_runtime_get_sync(priv->device);
+
 	return 0;
 }

After this code change, clocks always enabled even the NIC is not up, it's not good. Should implement .complete() to disable clocks after the info you got?

Best Regards,
Joakim Zhang

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +0 -1
--

2.20.1