From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35C0118C933 for ; Tue, 28 Jul 2026 00:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785198059; cv=none; b=gF9kWRZ3517QRN/W0X+gHyNd5PPvswkDZStEGpRFskd3X55Ki5cxLGNgqHpNHznaL0LtNucKUgrfXC4zSabDCJssn19g0tHr7mmC2/q0BRH7pTj4RgGV4AzJ67Sa/EygPn2nk0zEEIx6Tb6OR0dnwGs0ksMaeap/0w4JmsZBwCw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785198059; c=relaxed/simple; bh=AZBQH6sw52yRt+5IEYJ7WV8tHhvOu6zLPIHly2NM52c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tMI/jjjflxiDbJmJxQf6XB1BW9ltnnzjhMSRAVCB2Ir8tcbDYR0zZHL5qkWPgG8LNGpu1vFyebwweXdAxujL2RWQilSQd/PTz2a6qIxMvw91fAKnTuxN1aOQzM5jOjb9tEuqzjVBTcvWO15awBm7bpd3d7VRAUPsJysuqYakouU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hestyPTV; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hestyPTV" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5b28c91fba5so519395e87.1 for ; Mon, 27 Jul 2026 17:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785198056; x=1785802856; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=FMLSvv5jcG839oN8ASkK2rci5K2oL9ElHsLObCCCdZM=; b=hestyPTVZZV92Z0NGXqpw+heGpnluKespgcvOuDwRUGi/MNrJX3dZFCQ5QS54NrOLO WGbazGN+BM5S8SA9/27iR2ftcgcQtLDiA+wpez0VgGymxBLK49XnVXy3AVaJs8z4+nxj h3X+0fSC4BKmojvbsHB6wGjvsjTfQMvb63arcT9KZbfqZvXqTGXugGBfi/3mJektIF8c FFZrtn45PA6SWbcqdJ4xatr1tHqiv41HNNFFh4u64aiBC4+QMG1QjcQ2lT2jHvr0qL++ LBGy0NrnHVYQrLrfOfZpXerqfYGWGu1kolkBuzNjP8G6VNi/id29GPMDuRhgBIv1YZQn RyhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785198056; x=1785802856; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FMLSvv5jcG839oN8ASkK2rci5K2oL9ElHsLObCCCdZM=; b=F6njJlDv8Pfy97gsdTEo5Lnta5BE6ZQwNbaqsF+m07FXKmpQOmicUCwt54N48GA8Np ybW17MwUx0VenM7MEhzRbpap9bCMxOJKbyOu4QIsx7ukPl+V8EA7b3LlDwdAWY++ZDns ueMk0J4D3wzaJ/HAHkByhHrNLMsuGFDe8oSM6A+eGzUhNVfDJ1+G2wP6bjo0AG7d61Nd 85dmKeo5xDnOINg2PmmWNLJ5devUWE9bQYyPW3mmRBtUakwRPQBLaa2C8+MMn2lHuj4I 3K2gaNCjhYAdBArd1t1r4Z1M+ZOM28PStNsSATFgFKtDKZ6DCI2L+M3dIslzXD4/ACjp FpTw== X-Forwarded-Encrypted: i=1; AHgh+RqNLievtyRwmyG6+4zaAzse/oPs/1tu+s+56ogMfrjagw/DgEEJwjo0rw5VTEdPwr5rgyTu+O+/XBDSXes=@vger.kernel.org X-Gm-Message-State: AOJu0Yxrfob+f47zz0EIkOtZiUkEpXLKD0eeN0NHDY0wnukRHn/Fhyk+ KdTijExQrlOjg+8fsTMY64fuxYqSy8qhdIFqO1GdPvBh7X67s/f94NYI X-Gm-Gg: AR+sD11JPTebBKZnnL4icd9Vawd57kkFNOyVYRJ7WBFRvy6C63mPX2RfHRtTB67ExRB 1EyCS7Q5TmiEqCO84pISzl5QdS/mLTde/4ES7chAvJ0y4XGY4KVdV4KFgncDk3bTLIbtrruuW7A 0sNDLMe6W9tkbPieshQdQRJTZIVs9puBB9kvX1vYqKfrGsAlEuCfdeY+ye/BP2c7VqyoLKcdHaM l0xRY67I+j/iH/8qv/+JvQma9JmfRLQXXo3md+xzypiK7PEUHLQ8Oyf52RXYeLSqWpzJHqyXwfZ 0Ha6balxz0CJP4QRNAZRQsn6cCcKO8OO3WHN+9ldS1LFZ4mQzUKXeXfubjVs36hjCdQzkW41GmB 6s1KjKY7hRylL3Omg8tNiJ4XQNji3JLG8CgkPHXrWDu2Ig9dJDEbiWTE+KsBqsxzCYT5pIcWnYK U0EH10EAPZ18s= X-Received: by 2002:a05:6512:3a92:b0:5b2:a3a2:1395 with SMTP id 2adb3069b0e04-5b2d020d7b9mr22054e87.3.1785198055823; Mon, 27 Jul 2026 17:20:55 -0700 (PDT) Received: from localhost ([188.234.148.119]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b2be0817c2sm1760096e87.23.2026.07.27.17.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2026 17:20:54 -0700 (PDT) From: Mikhail Gavrilov To: linux-wireless@vger.kernel.org Cc: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Nicolas Cavallari , Bert Karwatzki , linux-kernel@vger.kernel.org, Mikhail Gavrilov Subject: [PATCH mt76] wifi: mt76: mt792x: drop redundant napi_disable() in unregister path Date: Tue, 28 Jul 2026 05:20:48 +0500 Message-ID: <20260728002048.19351-1-mikhail.v.gavrilov@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: __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 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 Closes: https://lore.kernel.org/all/20260724151419.26014-1-spasswolf@web.de/ Suggested-by: Nicolas Cavallari Signed-off-by: Mikhail Gavrilov --- 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); -- 2.55.0