Skip to contentSkip to conversation

smsc95xx: Ignore -ENODEV errors when device is unplugged

PATCH Applied Fabio Estevam 4 participants 6 messages Mar 5, 2022 – Mar 9, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 smsc95xx: Ignore -ENODEV errors when device is unplugged

From: Fabio Estevam <[email protected]>

According to Documentation/driver-api/usb/URB.rst when a device is unplugged usb_submit_urb() returns -ENODEV.

This error code propagates all the way up to usbnet_read_cmd() and usbnet_write_cmd() calls inside the smsc95xx.c driver during Ethernet cable unplug, unbind or reboot.

This causes the following errors to be shown on reboot, for example:

ci_hdrc ci_hdrc.1: remove, state 1
usb usb2: USB disconnect, device number 1
usb 2-1: USB disconnect, device number 2
usb 2-1.1: USB disconnect, device number 3
smsc95xx 2-1.1:1.0 eth1: unregister 'smsc95xx' usb-ci_hdrc.1-1.1, smsc95xx USB 2.0 Ethernet smsc95xx 2-1.1:1.0 eth1: Failed to read reg index 0x00000114: -19
smsc95xx 2-1.1:1.0 eth1: Error reading MII_ACCESS
smsc95xx 2-1.1:1.0 eth1: __smsc95xx_mdio_read: MII is busy
smsc95xx 2-1.1:1.0 eth1: Failed to read reg index 0x00000114: -19
smsc95xx 2-1.1:1.0 eth1: Error reading MII_ACCESS
smsc95xx 2-1.1:1.0 eth1: __smsc95xx_mdio_read: MII is busy
smsc95xx 2-1.1:1.0 eth1: hardware isn't capable of remote wakeup
usb 2-1.4: USB disconnect, device number 4
ci_hdrc ci_hdrc.1: USB bus 2 deregistered
ci_hdrc ci_hdrc.0: remove, state 4
usb usb1: USB disconnect, device number 1
ci_hdrc ci_hdrc.0: USB bus 1 deregistered
imx2-wdt 30280000.watchdog: Device shutdown: Expect reboot!
reboot: Restarting system

Ignore the -ENODEV errors inside __smsc95xx_mdio_read() and __smsc95xx_phy_wait_not_busy() and do not print error messages when -ENODEV is returned.

Fixes a049a30fc27c ("net: usb: Correct PHY handling of smsc95xx")

---
Changes since v1:
- Added 'net' annotation - Andrew
- Added Fixes tag - Andrew
- Avoided undefined 'buf' behaviour in __smsc95xx_read_reg() - Andrew

 drivers/net/usb/smsc95xx.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/net/usb/smsc95xx.c +20 -8
index b17bff6a1015..e5b744851146 100644
@@ -84,9 +84,10 @@ static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,
 	ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN
 		 | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 		 0, index, &buf, 4);
-	if (unlikely(ret < 0)) {
-		netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n",
-			    index, ret);
+	if (ret < 0) {
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n",
+				    index, ret);
 		return ret;
 	}
 
@@ -116,7 +117,7 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index,
 	ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, USB_DIR_OUT
 		 | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 		 0, index, &buf, 4);
-	if (unlikely(ret < 0))
+	if (ret < 0 && ret != -ENODEV)
 		netdev_warn(dev->net, "Failed to write reg index 0x%08x: %d\n",
 			    index, ret);
 
@@ -159,6 +160,9 @@ static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev,
 	do {
 		ret = __smsc95xx_read_reg(dev, MII_ADDR, &val, in_pm);
 		if (ret < 0) {
+			/* Ignore -ENODEV error during disconnect() */
+			if (ret == -ENODEV)
+				return 0;
 			netdev_warn(dev->net, "Error reading MII_ACCESS\n");
 			return ret;
 		}
@@ -194,7 +198,8 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx,
 	addr = mii_address_cmd(phy_id, idx, MII_READ_ | MII_BUSY_);
 	ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_ADDR\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing MII_ADDR\n");
 		goto done;
 	}
 
@@ -206,7 +211,8 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx,
 
 	ret = __smsc95xx_read_reg(dev, MII_DATA, &val, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error reading MII_DATA\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error reading MII_DATA\n");
 		goto done;
 	}
 
@@ -214,6 +220,10 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx,
 
 done:
 	mutex_unlock(&dev->phy_mutex);
+
+	/* Ignore -ENODEV error during disconnect() */
+	if (ret == -ENODEV)
+		return 0;
 	return ret;
 }
 
@@ -235,7 +245,8 @@ static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id,
 	val = regval;
 	ret = __smsc95xx_write_reg(dev, MII_DATA, val, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_DATA\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing MII_DATA\n");
 		goto done;
 	}
 
@@ -243,7 +254,8 @@ static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id,
 	addr = mii_address_cmd(phy_id, idx, MII_WRITE_ | MII_BUSY_);
 	ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_ADDR\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing MII_ADDR\n");
 		goto done;
 	}
 
Signature · 1 line
2.25.1
#1 lore raw
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 10 lines · On Sat, 5 Mar 2022 17:47:20 -0300 you wrote:

From: Fabio Estevam <[email protected]>

According to Documentation/driver-api/usb/URB.rst when a device is unplugged usb_submit_urb() returns -ENODEV.

This error code propagates all the way up to usbnet_read_cmd() and usbnet_write_cmd() calls inside the smsc95xx.c driver during Ethernet cable unplug, unbind or reboot.

[...]

Here is the summary with links:
- [v2,net] smsc95xx: Ignore -ENODEV errors when device is unplugged

    https://git.kernel.org/netdev/net/c/c70c453abcbf

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#2 lore raw

Re: (EXT) [PATCH v2 net] smsc95xx: Ignore -ENODEV errors when device is unplugged

In reply to Fabio Estevam

Hello Fabio,

Am Samstag, 5. März 2022, 21:47:20 CET schrieb Fabio Estevam:

Quoted 32 lines

From: Fabio Estevam <[email protected]>

According to Documentation/driver-api/usb/URB.rst when a device is unplugged usb_submit_urb() returns -ENODEV.

This error code propagates all the way up to usbnet_read_cmd() and usbnet_write_cmd() calls inside the smsc95xx.c driver during Ethernet cable unplug, unbind or reboot.

This causes the following errors to be shown on reboot, for example:

ci_hdrc ci_hdrc.1: remove, state 1
usb usb2: USB disconnect, device number 1
usb 2-1: USB disconnect, device number 2
usb 2-1.1: USB disconnect, device number 3
smsc95xx 2-1.1:1.0 eth1: unregister 'smsc95xx' usb-ci_hdrc.1-1.1, smsc95xx USB 2.0 Ethernet smsc95xx 2-1.1:1.0 eth1: Failed to read reg index 0x00000114: -19
smsc95xx 2-1.1:1.0 eth1: Error reading MII_ACCESS
smsc95xx 2-1.1:1.0 eth1: __smsc95xx_mdio_read: MII is busy smsc95xx 2-1.1:1.0 eth1: Failed to read reg index 0x00000114: -19 smsc95xx 2-1.1:1.0 eth1: Error reading MII_ACCESS
smsc95xx 2-1.1:1.0 eth1: __smsc95xx_mdio_read: MII is busy smsc95xx 2-1.1:1.0 eth1: hardware isn't capable of remote wakeup usb 2-1.4: USB disconnect, device number 4
ci_hdrc ci_hdrc.1: USB bus 2 deregistered
ci_hdrc ci_hdrc.0: remove, state 4
usb usb1: USB disconnect, device number 1
ci_hdrc ci_hdrc.0: USB bus 1 deregistered
imx2-wdt 30280000.watchdog: Device shutdown: Expect reboot!
reboot: Restarting system

Quoted 3 lines

Ignore the -ENODEV errors inside __smsc95xx_mdio_read() and __smsc95xx_phy_wait_not_busy() and do not print error messages when -ENODEV is returned.

Just FYI, this even fixed a suspend problem on a 5.10 imx downstream kernel which had similar symptoms. Thanks a lot.

Regards
Alexander

Quoted 16 lines
Fixes a049a30fc27c ("net: usb: Correct PHY handling of smsc95xx")

---
Changes since v1:
- Added 'net' annotation - Andrew
- Added Fixes tag - Andrew
- Avoided undefined 'buf' behaviour in __smsc95xx_read_reg() - Andrew

 drivers/net/usb/smsc95xx.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/net/usb/smsc95xx.c +0 -0
index b17bff6a1015..e5b744851146 100644

drivers/net/usb/smsc95xx.c static int __must_check __smsc95xx_read_reg(struct usbnet · line 90

Quoted 7 lines
drivers/net/usb/smsc95xx.c +0 -2
@@ -84,9 +84,10 @@ static int __must_check __smsc95xx_read_reg(struct usbnet
 *dev, u32 index, ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN
 
 		 | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 		 0, index, &buf, 4);
-	if (unlikely(ret < 0)) {
-		netdev_warn(dev->net, "Failed to read reg index 0x%08x: 

%d\n",

drivers/net/usb/smsc95xx.c static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,

Quoted 4 lines
drivers/net/usb/smsc95xx.c +3 -1
-			    index, ret);
+	if (ret < 0) {
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Failed to read reg 

index 0x%08x: %d\n",

Quoted 8 lines
drivers/net/usb/smsc95xx.c +1 -0
+				    index, ret);
 		return ret;
drivers/net/usb/smsc95xx.c +0 -0
 	}
@@ -116,7 +117,7 @@ static int __must_check __smsc95xx_write_reg(struct
 usbnet *dev, u32 index, ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER,

USB_DIR_OUT

drivers/net/usb/smsc95xx.c static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index,

Quoted 6 lines
drivers/net/usb/smsc95xx.c +1 -1
 		 | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 		 0, index, &buf, 4);
-	if (unlikely(ret < 0))
+	if (ret < 0 && ret != -ENODEV)
 		netdev_warn(dev->net, "Failed to write reg index 0x%08x: 

%d\n",

drivers/net/usb/smsc95xx.c static int __must_check · line 163

Quoted 7 lines
drivers/net/usb/smsc95xx.c +1 -0
 			    index, ret);
@@ -159,6 +160,9 @@ static int __must_check
 __smsc95xx_phy_wait_not_busy(struct usbnet *dev, do {
 		ret = __smsc95xx_read_reg(dev, MII_ADDR, &val, in_pm);
 		if (ret < 0) {
+			/* Ignore -ENODEV error during disconnect() 

*/

drivers/net/usb/smsc95xx.c static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev,

Quoted 3 lines
drivers/net/usb/smsc95xx.c +2 -0
+			if (ret == -ENODEV)
+				return 0;
 			netdev_warn(dev->net, "Error reading 

MII_ACCESS\n");

drivers/net/usb/smsc95xx.c static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx,

Quoted 10 lines
drivers/net/usb/smsc95xx.c +0 -0
 			return ret;
 		}
@@ -194,7 +198,8 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int

phy_id, int idx, addr = mii_address_cmd(phy_id, idx, MII_READ_ | MII_BUSY_);

drivers/net/usb/smsc95xx.c +2 -1
 	ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_ADDR\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing 

MII_ADDR\n");

drivers/net/usb/smsc95xx.c static int __smsc95xx_mdio_read(struct usbnet *dev, int · line 216

Quoted 11 lines
drivers/net/usb/smsc95xx.c +2 -1
 		goto done;
 	}
@@ -206,7 +211,8 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int
 phy_id, int idx,
 
 	ret = __smsc95xx_read_reg(dev, MII_DATA, &val, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error reading MII_DATA\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error reading 

MII_DATA\n");

Quoted 16 lines
drivers/net/usb/smsc95xx.c +4 -0
 		goto done;
 	}
@@ -214,6 +220,10 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int
 phy_id, int idx,
 
 done:
 	mutex_unlock(&dev->phy_mutex);
+
+	/* Ignore -ENODEV error during disconnect() */
+	if (ret == -ENODEV)
+		return 0;
 	return ret;
 }

drivers/net/usb/smsc95xx.c static void __smsc95xx_mdio_write(struct usbnet *dev, · line 249

Quoted 6 lines
drivers/net/usb/smsc95xx.c +2 -1
@@ -235,7 +245,8 @@ static void __smsc95xx_mdio_write(struct usbnet *dev,
 int phy_id, val = regval;
 	ret = __smsc95xx_write_reg(dev, MII_DATA, val, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_DATA\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing 

MII_DATA\n");

drivers/net/usb/smsc95xx.c static void __smsc95xx_mdio_write(struct usbnet *dev, · line 258

Quoted 10 lines
drivers/net/usb/smsc95xx.c +2 -1
 		goto done;
 	}
 
@@ -243,7 +254,8 @@ static void __smsc95xx_mdio_write(struct usbnet *dev,
 int phy_id, addr = mii_address_cmd(phy_id, idx, MII_WRITE_ | MII_BUSY_);
 	ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_ADDR\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing 

MII_ADDR\n");

Quoted 2 lines
drivers/net/usb/smsc95xx.c +0 -0
 		goto done;
 	}
#3 lore raw

Re: (EXT) [PATCH v2 net] smsc95xx: Ignore -ENODEV errors when device is unplugged

In reply to Fabio Estevam

Am Samstag, 5. März 2022, 21:47:20 CET schrieb Fabio Estevam:

Quoted 32 lines

From: Fabio Estevam <[email protected]>

According to Documentation/driver-api/usb/URB.rst when a device is unplugged usb_submit_urb() returns -ENODEV.

This error code propagates all the way up to usbnet_read_cmd() and usbnet_write_cmd() calls inside the smsc95xx.c driver during Ethernet cable unplug, unbind or reboot.

This causes the following errors to be shown on reboot, for example:

ci_hdrc ci_hdrc.1: remove, state 1
usb usb2: USB disconnect, device number 1
usb 2-1: USB disconnect, device number 2
usb 2-1.1: USB disconnect, device number 3
smsc95xx 2-1.1:1.0 eth1: unregister 'smsc95xx' usb-ci_hdrc.1-1.1, smsc95xx USB 2.0 Ethernet smsc95xx 2-1.1:1.0 eth1: Failed to read reg index 0x00000114: -19
smsc95xx 2-1.1:1.0 eth1: Error reading MII_ACCESS
smsc95xx 2-1.1:1.0 eth1: __smsc95xx_mdio_read: MII is busy smsc95xx 2-1.1:1.0 eth1: Failed to read reg index 0x00000114: -19 smsc95xx 2-1.1:1.0 eth1: Error reading MII_ACCESS
smsc95xx 2-1.1:1.0 eth1: __smsc95xx_mdio_read: MII is busy smsc95xx 2-1.1:1.0 eth1: hardware isn't capable of remote wakeup usb 2-1.4: USB disconnect, device number 4
ci_hdrc ci_hdrc.1: USB bus 2 deregistered
ci_hdrc ci_hdrc.0: remove, state 4
usb usb1: USB disconnect, device number 1
ci_hdrc ci_hdrc.0: USB bus 1 deregistered
imx2-wdt 30280000.watchdog: Device shutdown: Expect reboot!
reboot: Restarting system

Quoted 6 lines

Ignore the -ENODEV errors inside __smsc95xx_mdio_read() and __smsc95xx_phy_wait_not_busy() and do not print error messages when -ENODEV is returned.

Fixes a049a30fc27c ("net: usb: Correct PHY handling of smsc95xx")

Oh BTW, is this queued for stable? Which versions? If 'Fixes: a049a30fc27c ("net: usb: Correct PHY handling of smsc95xx")' is the indicator, it's not enough. This errors also shows up on v5.15.27 and is fixed with this patch.

Regards,
Alexander

Quoted 14 lines

---
Changes since v1:
- Added 'net' annotation - Andrew
- Added Fixes tag - Andrew
- Avoided undefined 'buf' behaviour in __smsc95xx_read_reg() - Andrew

 drivers/net/usb/smsc95xx.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/net/usb/smsc95xx.c +0 -0
index b17bff6a1015..e5b744851146 100644

drivers/net/usb/smsc95xx.c static int __must_check __smsc95xx_read_reg(struct usbnet · line 90

Quoted 7 lines
drivers/net/usb/smsc95xx.c +0 -2
@@ -84,9 +84,10 @@ static int __must_check __smsc95xx_read_reg(struct usbnet
 *dev, u32 index, ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN
 
 		 | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 		 0, index, &buf, 4);
-	if (unlikely(ret < 0)) {
-		netdev_warn(dev->net, "Failed to read reg index 0x%08x: 

%d\n",

drivers/net/usb/smsc95xx.c static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,

Quoted 4 lines
drivers/net/usb/smsc95xx.c +3 -1
-			    index, ret);
+	if (ret < 0) {
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Failed to read reg 

index 0x%08x: %d\n",

Quoted 8 lines
drivers/net/usb/smsc95xx.c +1 -0
+				    index, ret);
 		return ret;
drivers/net/usb/smsc95xx.c +0 -0
 	}
@@ -116,7 +117,7 @@ static int __must_check __smsc95xx_write_reg(struct
 usbnet *dev, u32 index, ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER,

USB_DIR_OUT

drivers/net/usb/smsc95xx.c static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index,

Quoted 6 lines
drivers/net/usb/smsc95xx.c +1 -1
 		 | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 		 0, index, &buf, 4);
-	if (unlikely(ret < 0))
+	if (ret < 0 && ret != -ENODEV)
 		netdev_warn(dev->net, "Failed to write reg index 0x%08x: 

%d\n",

drivers/net/usb/smsc95xx.c static int __must_check · line 163

Quoted 7 lines
drivers/net/usb/smsc95xx.c +1 -0
 			    index, ret);
@@ -159,6 +160,9 @@ static int __must_check
 __smsc95xx_phy_wait_not_busy(struct usbnet *dev, do {
 		ret = __smsc95xx_read_reg(dev, MII_ADDR, &val, in_pm);
 		if (ret < 0) {
+			/* Ignore -ENODEV error during disconnect() 

*/

drivers/net/usb/smsc95xx.c static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev,

Quoted 3 lines
drivers/net/usb/smsc95xx.c +2 -0
+			if (ret == -ENODEV)
+				return 0;
 			netdev_warn(dev->net, "Error reading 

MII_ACCESS\n");

drivers/net/usb/smsc95xx.c static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx,

Quoted 10 lines
drivers/net/usb/smsc95xx.c +0 -0
 			return ret;
 		}
@@ -194,7 +198,8 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int

phy_id, int idx, addr = mii_address_cmd(phy_id, idx, MII_READ_ | MII_BUSY_);

drivers/net/usb/smsc95xx.c +2 -1
 	ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_ADDR\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing 

MII_ADDR\n");

drivers/net/usb/smsc95xx.c static int __smsc95xx_mdio_read(struct usbnet *dev, int · line 216

Quoted 11 lines
drivers/net/usb/smsc95xx.c +2 -1
 		goto done;
 	}
@@ -206,7 +211,8 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int
 phy_id, int idx,
 
 	ret = __smsc95xx_read_reg(dev, MII_DATA, &val, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error reading MII_DATA\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error reading 

MII_DATA\n");

Quoted 16 lines
drivers/net/usb/smsc95xx.c +4 -0
 		goto done;
 	}
@@ -214,6 +220,10 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int
 phy_id, int idx,
 
 done:
 	mutex_unlock(&dev->phy_mutex);
+
+	/* Ignore -ENODEV error during disconnect() */
+	if (ret == -ENODEV)
+		return 0;
 	return ret;
 }

drivers/net/usb/smsc95xx.c static void __smsc95xx_mdio_write(struct usbnet *dev, · line 249

Quoted 6 lines
drivers/net/usb/smsc95xx.c +2 -1
@@ -235,7 +245,8 @@ static void __smsc95xx_mdio_write(struct usbnet *dev,
 int phy_id, val = regval;
 	ret = __smsc95xx_write_reg(dev, MII_DATA, val, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_DATA\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing 

MII_DATA\n");

drivers/net/usb/smsc95xx.c static void __smsc95xx_mdio_write(struct usbnet *dev, · line 258

Quoted 10 lines
drivers/net/usb/smsc95xx.c +2 -1
 		goto done;
 	}
 
@@ -243,7 +254,8 @@ static void __smsc95xx_mdio_write(struct usbnet *dev,
 int phy_id, addr = mii_address_cmd(phy_id, idx, MII_WRITE_ | MII_BUSY_);
 	ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm);
 	if (ret < 0) {
-		netdev_warn(dev->net, "Error writing MII_ADDR\n");
+		if (ret != -ENODEV)
+			netdev_warn(dev->net, "Error writing 

MII_ADDR\n");

Quoted 2 lines
drivers/net/usb/smsc95xx.c +0 -0
 		goto done;
 	}
maintainer
#4 lore raw

Re: (EXT) [PATCH v2 net] smsc95xx: Ignore -ENODEV errors when device is unplugged

Quoted 6 lines · On Wed, 09 Mar 2022 15:02:21 +0100 Alexander Stein wrote:
Quoted 2 lines
Fixes a049a30fc27c ("net: usb: Correct PHY handling of smsc95xx")

Oh BTW, is this queued for stable? Which versions? If 'Fixes: a049a30fc27c ("net: usb: Correct PHY handling of smsc95xx")' is the indicator, it's not enough. This errors also shows up on v5.15.27 and is fixed with this patch.

The stable machinery will most likely suck it in automatically. The patch should reach Linus tomorrow evening if you want to ping Greg and make sure.

#5 lore raw

Re: (EXT) [PATCH v2 net] smsc95xx: Ignore -ENODEV errors when device is unplugged

In reply to Alexander Stein

Hi Alexander,

Quoted 3 lines · Alexander Stein

Oh BTW, is this queued for stable? Which versions? If 'Fixes: a049a30fc27c ("net: usb: Correct PHY handling of smsc95xx")' is the indicator, it's not enough. This errors also shows up on v5.15.27 and is fixed with this patch.

("net: usb: Correct PHY handling of smsc95xx")' is also present in 5.15:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/log/drivers/net/usb/smsc95xx.c?h=v5.15.27

so the fix should land in 5.15 too.

For 5.10, when the fix reaches Linus' tree, then I will ping Dave/Jakub/Greg to apply the 3 latest smsc95xx commits to 5.10 stable tree:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/log/drivers/net/usb/smsc95xx.c?id=c70c453abcbf

I have been running 5.10 + the 3 commits above and no more smsc95xx errors are seen.