From: Bert Karwatzki <spasswolf@web.de>
To: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>,
linux-wireless@vger.kernel.org
Cc: Felix Fietkau <nbd@nbd.name>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Ryder Lee <ryder.lee@mediatek.com>,
Shayne Chen <shayne.chen@mediatek.com>,
Sean Wang <sean.wang@mediatek.com>,
Nicolas Cavallari <nicolas.cavallari@green-communications.fr>,
linux-kernel@vger.kernel.org, spasswolf@web.de
Subject: Re: [PATCH mt76] wifi: mt76: mt792x: drop redundant napi_disable() in unregister path
Date: Tue, 28 Jul 2026 14:48:45 +0200 [thread overview]
Message-ID: <ae8f803765f06e0ea1968397338129bdd9766c4f.camel@web.de> (raw)
In-Reply-To: <20260728002048.19351-1-mikhail.v.gavrilov@gmail.com>
Am Dienstag, dem 28.07.2026 um 05:20 +0500 schrieb Mikhail Gavrilov:
> Commit 13b7e6a96a00 ("wifi: mt76: Disable napi when removing device")
> made mt76_dma_cleanup() disable every RX NAPI instance before deleting
> it. mt7921e_unregister_device() and mt7925e_unregister_device() already
> disable the very same instances and only afterwards call
> mt792x_dma_cleanup() -> mt76_dma_cleanup(), so each instance is now
> disabled twice.
>
> napi_disable() is not idempotent: on return it leaves NAPIF_STATE_SCHED
> and NAPIF_STATE_NPSVC set, so a second call without an intervening
> napi_enable() spins in usleep_range() forever, waiting for bits that
> nobody will clear:
>
> task:modprobe state:D stack:25720 pid:7954 tgid:7954
> Call Trace:
> <TASK>
> __schedule+0x11b8/0x26d0
> schedule+0xe7/0x2f0
> schedule_hrtimeout_range_clock+0x218/0x330
> usleep_range_state+0x133/0x1b0
> napi_disable_locked+0x37d/0x5f0
> napi_disable+0x43/0x80
> mt76_dma_cleanup+0x2b4/0x860 [mt76]
> mt7921_pci_remove+0x17f/0x350 [mt7921e]
> pci_device_remove+0xb6/0x1e0
> device_release_driver_internal+0x38d/0x540
> driver_detach+0xd0/0x1b0
> bus_remove_driver+0x127/0x2d0
> pci_unregister_driver+0x2a/0x280
> __do_sys_delete_module+0x36a/0x5b0
> do_syscall_64+0x11c/0x6d0
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
> </TASK>
>
> mt7921_pci_shutdown() and mt7925_pci_shutdown() reuse the remove path,
> so the same deadlock is hit on every reboot and poweroff. It is silent:
> the stuck task keeps sleeping and rescheduling, so neither the hung task
> detector nor the lockup detectors fire, and the last line on the console
> is "systemd-shutdown[1]: Rebooting."
>
> Drop the driver-side loops and rely on mt76_dma_cleanup() instead.
> mt792x_dma_cleanup() stops and resets the WFDMA engine before calling
> it, so RX is already quiesced when the NAPI instances are disabled
> there.
>
> Fixes: 13b7e6a96a00 ("wifi: mt76: Disable napi when removing device")
> Reported-by: Bert Karwatzki <spasswolf@web.de>
> Closes: https://lore.kernel.org/all/20260724151419.26014-1-spasswolf@web.de/
> Suggested-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
> Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
> ---
>
> I hit the same hang on an ASRock B650I Lightning WiFi with MT7922
> (mt7921e) and bisected it to the same commit. mt7921e has the same
> duplicated napi_disable() as mt7925e, so this covers both; it is
> Nicolas' suggestion from [1] extended to mt7921e and with the now
> unused 'int i' removed.
>
> Tested on 7.2.0-rc5 with KASAN and lockdep enabled, MT7922 / mt7921e.
> Before the patch 'modprobe -r mt7921e' hangs (backtrace above, taken
> with sysrq-w) and the machine never gets past "Rebooting.". With the
> patch 'modprobe -r mt7921e' and 'modprobe mt7921e' both complete and
> the interface comes back up, reboot and poweroff work again, and no
> __netif_napi_del_locked() or page_pool_disable_direct_recycling()
> warnings are logged.
>
> [1] https://lore.kernel.org/all/59c03ab1-ec4a-411b-9b7e-8183ecf3e02b@green-communications.fr/
>
> drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 3 ---
> drivers/net/wireless/mediatek/mt76/mt7925/pci.c | 3 ---
> 2 files changed, 6 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> index 7728c5ae6791..65d09d13304f 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> @@ -43,7 +43,6 @@ static int mt7921e_init_reset(struct mt792x_dev *dev)
>
> static void mt7921e_unregister_device(struct mt792x_dev *dev)
> {
> - int i;
> struct mt76_connac_pm *pm = &dev->pm;
> struct ieee80211_hw *hw = mt76_hw(dev);
>
> @@ -52,8 +51,6 @@ static void mt7921e_unregister_device(struct mt792x_dev *dev)
>
> cancel_work_sync(&dev->init_work);
> mt76_unregister_device(&dev->mt76);
> - mt76_for_each_q_rx(&dev->mt76, i)
> - napi_disable(&dev->mt76.napi[i]);
> cancel_delayed_work_sync(&pm->ps_work);
> cancel_work_sync(&pm->wake_work);
> cancel_work_sync(&dev->reset_work);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
> index ea64303283ed..eb1bd60e3d9f 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
> @@ -36,7 +36,6 @@ static int mt7925e_init_reset(struct mt792x_dev *dev)
>
> static void mt7925e_unregister_device(struct mt792x_dev *dev)
> {
> - int i;
> struct mt76_connac_pm *pm = &dev->pm;
> struct ieee80211_hw *hw = mt76_hw(dev);
>
> @@ -45,8 +44,6 @@ static void mt7925e_unregister_device(struct mt792x_dev *dev)
>
> cancel_work_sync(&dev->init_work);
> mt76_unregister_device(&dev->mt76);
> - mt76_for_each_q_rx(&dev->mt76, i)
> - napi_disable(&dev->mt76.napi[i]);
> cancel_delayed_work_sync(&pm->ps_work);
> cancel_work_sync(&pm->wake_work);
> cancel_work_sync(&dev->reset_work);
I tested this patch applied to next-20260727 with mt7925 and
rebooting works fine again.
Tested-By: Bert Karwatzki <spasswolf@web.de>
Bert Karwatzki
next prev parent reply other threads:[~2026-07-28 12:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 0:20 Mikhail Gavrilov
2026-07-28 12:48 ` Bert Karwatzki [this message]
2026-07-28 17:37 ` Mikhail Gavrilov
2026-07-30 5:04 ` Eric Biggers
2026-07-30 7:07 ` Mikhail Gavrilov
2026-07-30 15:22 ` Devin Wittmayer
2026-08-04 9:29 ` Thorsten Leemhuis
2026-08-04 10:46 ` Mikhail Gavrilov
2026-08-04 12:07 ` Mikhail Gavrilov
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=ae8f803765f06e0ea1968397338129bdd9766c4f.camel@web.de \
--to=spasswolf@web.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=mikhail.v.gavrilov@gmail.com \
--cc=nbd@nbd.name \
--cc=nicolas.cavallari@green-communications.fr \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=shayne.chen@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
all inboxes | Powered by JetHome®