From: Sean Wang <sean.wang@kernel.org>
To: Felix Fietkau <nbd@nbd.name>, Lorenzo Bianconi <lorenzo@kernel.org>
Cc: linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org,
Sean Wang <sean.wang@mediatek.com>
Subject: [PATCH 6/6] wifi: mt76: mt792x: quiesce USB paths on disconnect
Date: Sat, 13 Jun 2026 17:41:31 -0500 [thread overview]
Message-ID: <20260613224131.2396026-7-sean.wang@kernel.org> (raw)
In-Reply-To: <20260613224131.2396026-1-sean.wang@kernel.org>
From: Sean Wang <sean.wang@mediatek.com>
USB disconnect can leave reset/init work, TX worker, and MCU waiters active
while the device is being removed. Stop those paths before unregistering
the device to avoid teardown waiting on firmware or queue activity after
disconnect.
Run WFSYS reset after USB queue deinit so removal does not issue the reset
while USB traffic may still be queued.
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt792x_usb.c | 20 ++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_usb.c b/drivers/net/wireless/mediatek/mt76/mt792x_usb.c
index c4da1b900d47..e5d2d2f6a388 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_usb.c
@@ -230,9 +230,9 @@ EXPORT_SYMBOL_GPL(mt792xu_mcu_power_on);
static void mt792xu_cleanup(struct mt792x_dev *dev)
{
clear_bit(MT76_STATE_INITIALIZED, &dev->mphy.state);
- mt792xu_wfsys_reset(dev);
skb_queue_purge(&dev->mt76.mcu.res_q);
mt76u_queues_deinit(&dev->mt76);
+ mt792xu_wfsys_reset(dev);
}
static u32 mt792xu_uhw_rr(struct mt76_dev *dev, u32 addr)
@@ -494,13 +494,27 @@ void mt792xu_disconnect(struct usb_interface *usb_intf)
{
struct mt792x_dev *dev = usb_get_intfdata(usb_intf);
- mt792xu_reset_work_cleanup(dev);
+ if (!dev)
+ return;
+
+ set_bit(MT76_RESET, &dev->mphy.state);
+ set_bit(MT76_MCU_RESET, &dev->mphy.state);
+ clear_bit(MT76_STATE_RUNNING, &dev->mphy.state);
+ wake_up(&dev->mt76.mcu.wait);
+ skb_queue_purge(&dev->mt76.mcu.res_q);
+
+ cancel_work_sync(&dev->reset_work);
cancel_work_sync(&dev->init_work);
- if (!test_bit(MT76_STATE_INITIALIZED, &dev->mphy.state))
+ mt76_worker_disable(&dev->mt76.tx_worker);
+ mt792xu_reset_work_cleanup(dev);
+ if (!test_bit(MT76_STATE_INITIALIZED, &dev->mphy.state)) {
+ set_bit(MT76_REMOVED, &dev->mphy.state);
return;
+ }
mt76_unregister_device(&dev->mt76);
mt792xu_cleanup(dev);
+ set_bit(MT76_REMOVED, &dev->mphy.state);
usb_set_intfdata(usb_intf, NULL);
--
2.43.0
prev parent reply other threads:[~2026-06-13 22:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 22:41 [PATCH 0/6] wifi: mt76: mt792x: harden USB reset and disconnect paths Sean Wang
2026-06-13 22:41 ` [PATCH 1/6] wifi: mt76: mt7925: stop init retries on hung bus Sean Wang
2026-06-13 22:41 ` [PATCH 2/6] wifi: mt76: mt7925: skip reset work " Sean Wang
2026-06-13 22:41 ` [PATCH 3/6] wifi: mt76: mt792x: stop USB register access after bus hang Sean Wang
2026-06-13 22:41 ` [PATCH 4/6] wifi: mt76: mt792x: drain USB UDMA before WFSYS reset Sean Wang
2026-06-13 22:41 ` [PATCH 5/6] wifi: mt76: mt792x: enable USB UDMA TX timeout Sean Wang
2026-06-13 22:41 ` Sean Wang [this message]
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=20260613224131.2396026-7-sean.wang@kernel.org \
--to=sean.wang@kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
--cc=sean.wang@mediatek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox