From: Oliver Neukum <oneukum@suse.com>
To: petkan@nucleusys.com, netdev@vger.kernel.org
Cc: Oliver Neukum <oneukum@suse.com>
Subject: [RFT 3/3] net: usb: rtl8150: cease all IO upon close
Date: Wed, 25 Nov 2026 15:43:09 +0100 [thread overview]
Message-ID: <20261125145313.58434-4-oneukum@suse.com> (raw)
In-Reply-To: <20261125145313.58434-1-oneukum@suse.com>
close() suffers from the same cyle of resubmission
and rescheduling as disconnect. It can be broken
by cancelling the tasklet while the URBs are poisoned.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/net/usb/rtl8150.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 5de917ce250f..f09792c4c680 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -97,6 +97,7 @@ enum rtl8150_usb_ep {
#define RX_REG_SET 1
#define RTL8150_UNPLUG 2
#define RX_URB_FAIL 3
+#define RTL8150_QUIET 4
/* Define these values to match your device */
#define VENDOR_ID_REALTEK 0x0bda
@@ -360,11 +361,11 @@ static void terminate_all_urbs(rtl8150_t *dev)
usb_poison_urb(dev->intr_urb);
}
-static void unlink_all_urbs(rtl8150_t * dev)
+static void enable_all_urbs(rtl8150_t *dev)
{
- usb_kill_urb(dev->rx_urb);
- usb_kill_urb(dev->tx_urb);
- usb_kill_urb(dev->intr_urb);
+ usb_unpoison_urb(dev->rx_urb);
+ usb_unpoison_urb(dev->tx_urb);
+ usb_unpoison_urb(dev->intr_urb);
}
static inline struct sk_buff *pull_skb(rtl8150_t *dev)
@@ -453,7 +454,8 @@ static void read_bulk_callback(struct urb *urb)
return;
resched:
- tasklet_schedule(&dev->tl);
+ if (!test_bit(RTL8150_QUIET, &dev->flags))
+ tasklet_schedule(&dev->tl);
}
static void write_bulk_callback(struct urb *urb)
@@ -536,7 +538,7 @@ static int rtl8150_suspend(struct usb_interface *intf, pm_message_t message)
rtl8150_t *dev = usb_get_intfdata(intf);
spin_lock_irq(&dev->rx_pool_lock);
- set_bit(RTL8150_UNPLUG, &dev->flags);
+ set_bit(RTL8150_QUIET, &dev->flags);
spin_unlock_irq(&dev->rx_pool_lock);
netif_device_detach(dev->netdev);
@@ -552,7 +554,7 @@ static int rtl8150_resume(struct usb_interface *intf)
rtl8150_t *dev = usb_get_intfdata(intf);
spin_lock_irq(&dev->rx_pool_lock);
- clear_bit(RTL8150_UNPLUG, &dev->flags);
+ clear_bit(RTL8150_QUIET, &dev->flags);
spin_unlock_irq(&dev->rx_pool_lock);
usb_unpoison_urb(dev->rx_urb);
@@ -636,7 +638,8 @@ static void rx_fixup(struct tasklet_struct *t)
return;
tlsched:
spin_lock_irq(&dev->rx_pool_lock);
- if (!test_bit(RTL8150_UNPLUG, &dev->flags))
+ if (!test_bit(RTL8150_UNPLUG, &dev->flags) &&
+ !test_bit(RTL8150_QUIET, &dev->flags))
tasklet_schedule(&dev->tl);
spin_unlock_irq(&dev->rx_pool_lock);
}
@@ -805,9 +808,12 @@ static int rtl8150_close(struct net_device *netdev)
rtl8150_t *dev = netdev_priv(netdev);
netif_stop_queue(netdev);
+ set_bit(RTL8150_QUIET, &dev->flags);
if (!test_bit(RTL8150_UNPLUG, &dev->flags))
disable_net_traffic(dev);
- unlink_all_urbs(dev);
+ terminate_all_urbs(dev);
+ tasklet_kill(&dev->tl);
+ enable_all_urbs(dev);
return 0;
}
--
2.56.1
next prev parent reply other threads:[~2026-11-25 14:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 14:43 [RFT 0/2] net: usb: rtl8150: cleaning up races with ceasing IO Oliver Neukum
2026-11-25 14:43 ` [RFT 1/3] net: usb: rtl8150: break cycle between tasklet and URB Oliver Neukum
2026-11-25 14:43 ` [RFT 2/3] net: usb: rtl8150: fix race in open() error handling Oliver Neukum
2026-11-25 14:43 ` Oliver Neukum [this message]
2026-11-25 14:59 ` [RFT 0/2] net: usb: rtl8150: cleaning up races with ceasing IO netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125145313.58434-4-oneukum@suse.com \
--to=oneukum@suse.com \
--cc=netdev@vger.kernel.org \
--cc=petkan@nucleusys.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.