Skip to contentSkip to conversation

r8152: fix side effect

PATCH Superseded Hayes Wang 3 participants 14 messages Aug 23, 2019 – Aug 29, 2019

Subsystems (3)
lore
Share & tools
lore
author
#2 lore raw

PATCH 2/2 r8152: avoid using napi_disable after netif_napi_del.

In reply to Hayes Wang

Exchange netif_napi_del() and unregister_netdev() in rtl8152_disconnect() to avoid using napi_disable() after netif_napi_del().

---
 drivers/net/usb/r8152.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/r8152.c +1 -1
index 690a24d1ef82..29390eda5251 100644
@@ -5364,8 +5364,8 @@ static void rtl8152_disconnect(struct usb_interface *intf)
 	if (tp) {
 		rtl_set_unplug(tp);
 
-		netif_napi_del(&tp->napi);
 		unregister_netdev(tp->netdev);
+		netif_napi_del(&tp->napi);
 		cancel_delayed_work_sync(&tp->hw_phy_work);
 		tp->rtl_ops.unload(tp);
 		free_netdev(tp->netdev);
Signature · 1 line
2.21.0

Hayes Wang

author
#0 lore raw

cover r8152: fix side effect

The commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") add a check to avoid using napi_disable after netif_napi_del. However, the commit ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection") let the check useless.

Therefore, I revert commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") first, and add another patch to fix it.

Hayes Wang (2):
Revert "r8152: napi hangup fix after disconnect"
r8152: avoid using napi_disable after netif_napi_del.

 drivers/net/usb/r8152.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.21.0
author
#1 lore raw

PATCH 1/2 Revert "r8152: napi hangup fix after disconnect"

This reverts commit 0ee1f4734967af8321ecebaf9c74221ace34f2d5.

This conflicts with commit ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection").

---
 drivers/net/usb/r8152.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/usb/r8152.c +1 -2
index 0cc03a9ff545..690a24d1ef82 100644
@@ -4018,8 +4018,7 @@ static int rtl8152_close(struct net_device *netdev)
 #ifdef CONFIG_PM_SLEEP
 	unregister_pm_notifier(&tp->pm_notifier);
 #endif
-	if (!test_bit(RTL8152_UNPLUG, &tp->flags))
-		napi_disable(&tp->napi);
+	napi_disable(&tp->napi);
 	clear_bit(WORK_ENABLE, &tp->flags);
 	usb_kill_urb(tp->intr_urb);
 	cancel_delayed_work_sync(&tp->schedule);
Signature · 1 line
2.21.0
maintainer
#3 lore raw

Re: [PATCH net 2/2] r8152: avoid using napi_disable after netif_napi_del.

In reply to Hayes Wang

From: Hayes Wang <[email protected]>
Date: Fri, 23 Aug 2019 16:53:02 +0800

Quoted 13 lines

Exchange netif_napi_del() and unregister_netdev() in rtl8152_disconnect() to avoid using napi_disable() after netif_napi_del().

---
 drivers/net/usb/r8152.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/r8152.c +0 -0
index 690a24d1ef82..29390eda5251 100644

drivers/net/usb/r8152.c static void rtl8152_disconnect(struct usb_interface *intf) · line 5371

Quoted 9 lines
drivers/net/usb/r8152.c +1 -1
@@ -5364,8 +5364,8 @@ static void rtl8152_disconnect(struct usb_interface *intf)
 	if (tp) {
 		rtl_set_unplug(tp);
 
-		netif_napi_del(&tp->napi);
 		unregister_netdev(tp->netdev);
+		netif_napi_del(&tp->napi);
 		cancel_delayed_work_sync(&tp->hw_phy_work);
 		tp->rtl_ops.unload(tp);
 		free_netdev(tp->netdev);

This is completely redundant because free_netdev() will perform all of the necessary netif_napi_del() calls.

author
#4 lore raw

v3 cover r8152: fix side effect

In reply to Hayes Wang

v3:
Update the commit message for patch #1.

v2:
Replace patch #2 with "r8152: remove calling netif_napi_del".

v1:
The commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") add a check to avoid using napi_disable after netif_napi_del. However, the commit ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection") let the check useless.

Therefore, I revert commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") first, and add another patch to fix it.

Hayes Wang (2):
Revert "r8152: napi hangup fix after disconnect"
r8152: remove calling netif_napi_del

 drivers/net/usb/r8152.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Signature · 1 line
2.21.0
author
#5 lore raw

PATCH v3 1/2 Revert "r8152: napi hangup fix after disconnect"

This reverts commit 0ee1f4734967af8321ecebaf9c74221ace34f2d5.

The commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") adds a check about RTL8152_UNPLUG to determine if calling napi_disable() is invalid in rtl8152_close(), when rtl8152_disconnect() is called. This avoids to use napi_disable() after calling netif_napi_del().

Howver, commit ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection") causes that RTL8152_UNPLUG is not always set when calling rtl8152_disconnect(). Therefore, I have to revert commit 0ee1f4734967 ("r8152:
napi hangup fix after disconnect"), first. And submit another patch to fix it.

---
 drivers/net/usb/r8152.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/usb/r8152.c +1 -2
index eee0f5007ee3..ad3abe26b51b 100644
@@ -4021,8 +4021,7 @@ static int rtl8152_close(struct net_device *netdev)
 #ifdef CONFIG_PM_SLEEP
 	unregister_pm_notifier(&tp->pm_notifier);
 #endif
-	if (!test_bit(RTL8152_UNPLUG, &tp->flags))
-		napi_disable(&tp->napi);
+	napi_disable(&tp->napi);
 	clear_bit(WORK_ENABLE, &tp->flags);
 	usb_kill_urb(tp->intr_urb);
 	cancel_delayed_work_sync(&tp->schedule);
Signature · 1 line
2.21.0
author
#6 lore raw

PATCH v3 2/2 r8152: remove calling netif_napi_del

In reply to Hayes Wang

Remove unnecessary use of netif_napi_del. This also avoids to call napi_disable() after netif_napi_del().

---
 drivers/net/usb/r8152.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/usb/r8152.c +0 -2
index ad3abe26b51b..04137ac373b0 100644
@@ -5352,7 +5352,6 @@ static int rtl8152_probe(struct usb_interface *intf,
 	return 0;
 
 out1:
-	netif_napi_del(&tp->napi);
 	usb_set_intfdata(intf, NULL);
 out:
 	free_netdev(netdev);
@@ -5367,7 +5366,6 @@ static void rtl8152_disconnect(struct usb_interface *intf)
 	if (tp) {
 		rtl_set_unplug(tp);
 
-		netif_napi_del(&tp->napi);
 		unregister_netdev(tp->netdev);
 		cancel_delayed_work_sync(&tp->hw_phy_work);
 		tp->rtl_ops.unload(tp);
Signature · 1 line
2.21.0
#7 lore raw
In reply to Hayes Wang
Quoted 6 lines · Hayes Wang

v3:
Update the commit message for patch #1.

v2:
Replace patch #2 with "r8152: remove calling netif_napi_del".

Quoted 8 lines

v1:
The commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") add a check to avoid using napi_disable after netif_napi_del. However, the commit ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection") let the check useless.

Therefore, I revert commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") first, and add another patch to fix it.

LGTM, seems like if we were to add a Fixes tag it'd point to the

ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection")

commit, then? So only net needs it, v5.2 is fine.

author
#9 lore raw

v4 cover r8152: fix side effect

In reply to Hayes Wang

v4:
Add Fixes tag for both patch #1 and #2.

v3:
Update the commit message for patch #1.

v2:
Replace patch #2 with "r8152: remove calling netif_napi_del".

v1:
The commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") add a check to avoid using napi_disable after netif_napi_del. However, the commit ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection") let the check useless.

Therefore, I revert commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") first, and add another patch to fix it.

Hayes Wang (2):
Revert "r8152: napi hangup fix after disconnect"
r8152: remove calling netif_napi_del

 drivers/net/usb/r8152.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Signature · 1 line
2.21.0
author
#10 lore raw

PATCH v4 1/2 Revert "r8152: napi hangup fix after disconnect"

This reverts commit 0ee1f4734967af8321ecebaf9c74221ace34f2d5.

The commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") adds a check about RTL8152_UNPLUG to determine if calling napi_disable() is invalid in rtl8152_close(), when rtl8152_disconnect() is called. This avoids to use napi_disable() after calling netif_napi_del().

However, commit ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection") causes that RTL8152_UNPLUG is not always set when calling rtl8152_disconnect(). Therefore, I have to revert commit 0ee1f4734967 ("r8152:
napi hangup fix after disconnect"), first. And submit another patch to fix it.

Fixes ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection")
---
 drivers/net/usb/r8152.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/usb/r8152.c +1 -2
index eee0f5007ee3..ad3abe26b51b 100644
@@ -4021,8 +4021,7 @@ static int rtl8152_close(struct net_device *netdev)
 #ifdef CONFIG_PM_SLEEP
 	unregister_pm_notifier(&tp->pm_notifier);
 #endif
-	if (!test_bit(RTL8152_UNPLUG, &tp->flags))
-		napi_disable(&tp->napi);
+	napi_disable(&tp->napi);
 	clear_bit(WORK_ENABLE, &tp->flags);
 	usb_kill_urb(tp->intr_urb);
 	cancel_delayed_work_sync(&tp->schedule);
Signature · 1 line
2.21.0
author
#11 lore raw

PATCH v4 2/2 r8152: remove calling netif_napi_del

In reply to Hayes Wang

Remove unnecessary use of netif_napi_del. This also avoids to call napi_disable() after netif_napi_del().

Fixes ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection")
---
 drivers/net/usb/r8152.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/usb/r8152.c +0 -2
index ad3abe26b51b..04137ac373b0 100644
@@ -5352,7 +5352,6 @@ static int rtl8152_probe(struct usb_interface *intf,
 	return 0;
 
 out1:
-	netif_napi_del(&tp->napi);
 	usb_set_intfdata(intf, NULL);
 out:
 	free_netdev(netdev);
@@ -5367,7 +5366,6 @@ static void rtl8152_disconnect(struct usb_interface *intf)
 	if (tp) {
 		rtl_set_unplug(tp);
 
-		netif_napi_del(&tp->napi);
 		unregister_netdev(tp->netdev);
 		cancel_delayed_work_sync(&tp->hw_phy_work);
 		tp->rtl_ops.unload(tp);
Signature · 1 line
2.21.0
maintainer
#8 lore raw
In reply to Hayes Wang

From: Hayes Wang <[email protected]>
Date: Wed, 28 Aug 2019 09:51:40 +0800

Quoted 6 lines

v3:
Update the commit message for patch #1.

v2:
Replace patch #2 with "r8152: remove calling netif_napi_del".

Quoted 8 lines

v1:
The commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") add a check to avoid using napi_disable after netif_napi_del. However, the commit ffa9fec30ca0 ("r8152: set RTL8152_UNPLUG only for real disconnection") let the check useless.

Therefore, I revert commit 0ee1f4734967 ("r8152: napi hangup fix after disconnect") first, and add another patch to fix it.

Series applied, thank you.

author
#13 lore raw

David Miller [mailto:[email protected]]

Quoted 1 line

Sent: Thursday, August 29, 2019 7:18 AM

[...]

Quoted 6 lines
Quoted 2 lines

v4:
Add Fixes tag for both patch #1 and #2.

I applied v3, sorry.

I think it is OK as I will backport things to v5.2 -stable anyways.

Thanks.

Best Regards,
Hayes