From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=152.67.88.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796199726; b=poIFz5b6Jr903USplRFxOyqizFdl3TLaZPSkmNyvyR1eQgCVoNu+56DV6laR2IPqbyfl IPWSMo+K+NZ+frxCfSuidMlvFQIS3k3BnhNaaYKmzCOMXPnHLoIgDHXg3oZ0LiFpQmTmc FMiZ8RQ5nyEE/rNLPmYKl9yi9z8QVPg2bPmBrZFnSmYWcXjJPCSN3zv/CN0mzIQ73r9Eg x104Bxs+gQ6fNweZwotPONMTNd1gcdVkfKHSgSGbIUT9l5pVX7mC7Fv1FMMuvEHUEzBfy l9ZsvHtENHsya2FT3O3e2D4EUhq8t4gh2yEQYSC5OMNidN2RoqN1SqQJ+HLAsJvpn+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796199726; h=DMARC-Filter:DKIM-Signature:DKIM-Signature:Message-Instance: DKIM2-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=3PQaaDQLY3iXw6aaFYxUjuF2BrdMgYHWn+S9CgXnR1U=; b=EwGd1eAL5li8RJVb6WwSSbZibt85UZIZmNKxQy98w2FmcZUdctwmXfKRLTjnx2rTOjXe WJSOABlGVebwQkuVMsHQRJNXAV0uMlEgtDuuQ9uNGMmPNdhENPMjOzXAgUleUGHte07iN MZrR+J9vU1B9Hz+jXEDwipdqMnHxSFHsyw6Z4IxxZpWv8quQxdmx91acmW5bcg7OSmpdN 4m3XeCm0vARlaBxAIiEELGHQhRY/WUyeBsrL61Ol5kc38KrCMa9sb5ISxh19Fq0UweZVp zjyzd/lXsGxwgZf67r+K2YR4OlzHH3TYcJRS8/yZ90gTFwci4oHwd56rTcJRo+WN7Uw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cubiculum.net; spf=pass smtp.mailfrom=cubiculum.net; dkim=pass header.d=cubiculum.net header.i=@cubiculum.net header.a=ed25519-sha256 header.s=202501e header.b=tUuQ57l6; dkim=pass header.d=cubiculum.net header.i=@cubiculum.net header.a=rsa-sha256 header.s=202501r header.b=dvomJxBB; arc=none smtp.remote-ip=152.67.88.11 Received: from mail.cubiculum.net (mail.cubiculum.net [152.67.88.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A8B8606A32A for ; Wed, 2 Dec 2026 08:22:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3A8B8606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cubiculum.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cubiculum.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass header.d=cubiculum.net header.i=@cubiculum.net header.a=ed25519-sha256 header.s=202501e header.b=tUuQ57l6; dkim=pass (2048-bit key) header.d=cubiculum.net header.i=@cubiculum.net header.a=rsa-sha256 header.s=202501r header.b=dvomJxBB DKIM-Signature: v=1; a=ed25519-sha256; s=202501e; d=cubiculum.net; c=relaxed/relaxed; r=y; h=Message-ID:Date:Subject:To:From; t=1796199673; bh=3PQaaDQLY3iXw6aaFYxUjuF 2BrdMgYHWn+S9CgXnR1U=; b=tUuQ57l6J0EkLnPWZwq0U50WNsrl3nThdLZgMu22/wRFzykXYD DNAcryUrAWSIFq2QUxUH3PDwUk1+bSmZ6oAQ==; DKIM-Signature: v=1; a=rsa-sha256; s=202501r; d=cubiculum.net; c=relaxed/relaxed; r=y; h=Message-ID:Date:Subject:To:From; t=1796199673; bh=3PQaaDQLY3iXw6aaFYxUjuF 2BrdMgYHWn+S9CgXnR1U=; b=dvomJxBBk+eXnIXtMVWleCUatXMHM0tjgoj6b61leXmn4pqfsj knSzoLBHTknjEeXJhtSeTC3fQbSIZvfGkFsggJsIDjSEgBO4yrMVNZ+kBIO4+oj1v9emf3gL92k km9pGiwTJi2IE2kDBohr1I78b3U4LYIs2YYykRaLTtr2Nr1lD71izarFo16DwKXcTx4UXTpwApo 5GYlwOvd70FdNlcSw9J108xDLwYI6T3f+EiutpmznOE+kooa3BkhUUotxkXVYAHVNTO4NtuiyuY fx5Py2TSJElago1YDi5bopWDfLcLwFUjpsbaudxbot7eOh9eNM3fhnZeHWmdotkUjrg==; Message-Instance: m=1; h=sha256:pwYjkIgz36+vKkLTqzdUI4Fj8pnZjfHt23tCBezY n84=:9ofeeQFOmTT5c2b2wFXvDqIrberU53Z7AG5KfB9jBOA=; DKIM2-Signature: i=1; m=1; t=1796199673; d=cubiculum.net; mf=PGtlcm5lbEBj dWJpY3VsdW0ubmV0Pg==; rt=PGtlcm5lbEBjdWJpY3VsdW0ubmV0Pg==,PHJ0bDg4MjFjZXJm ZTJAZ21haWwuY29tPg==,PHBrc2hpaEByZWFsdGVrLmNvbT4=,PGxpbnV4LXdpcmVsZXNzQHZn ZXIua2VybmVsLm9yZz4=; s=v2-ed25519-20260926:ed25519-sha256:QQ6PPo3oP2xTz9J8 g7ndoJaeHKIoHNLEW2uOtl/2QVIvAx9L16uHblBs9EPatxU9YqUxRpy72c6dizdZfGguCQ==| v2-rsa-20260926:rsa-sha256:sBEgjAXlj8YCJUjxxObP2waHemvHk+JVMjVR5O6ib2vpdEYc zRUOnsUpQ/kUAnxjKpV2xri2ZvlA6d4MYg4rv9PtKJnSv/xuzQgG/AsAMyS3vF9SxQQEKG15 5+Q0ymS/Plki3/PIdfSytHaWq/0jkUelChWkpwEFAWVyRezma8a3xWFCUQGDbKTtd3u1BYPZ aOCsF8JZia4jAG1ATFN4aBWJYlCHJ3pmtUob2M9UyBylVa5DOUSaJlYmsffxqRIP64mEJRkH Hr59mFbiOqW2j+2rOndiBlqhd+XxoxUas67hgtdSa2nd+HBN+1yDDWn1dWVpPd5E3bKyuh+N z8eDsg==; From: rcfa To: Ping-Ke Shih Cc: linux-wireless@vger.kernel.org, Bitterblue Smith , kernel@cubiculum.net Subject: [PATCH rtw-next v2] wifi: rtw89: usb: keep the endpoints until the driver lets go on unbind Date: Wed, 2 Dec 2026 08:21:02 +0000 Message-ID: <20261202082102.3027727-1-kernel@cubiculum.net> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When the driver is unbound from a device that is still attached (rmmod, or an unbind through sysfs), usbcore kills the URBs of the interface's endpoints before it calls the disconnect method, unless the driver sets soft_unbind; and rtw89_usb_disconnect() cancels the RX and TX URBs itself before it calls rtw89_core_unregister(). Whatever rtw89_core_unregister() still asks of the chip then fails. On an RTL8922AU, an unload while associated logs: c2h reg timeout timed out to flush queues (3 times) read HWSI is busy (18 times) and an unload with no association, while a scan runs: rtw89_hw_scan_offload failed ret -110 read HWSI is busy (18 times) failed to wait RF TSSI (2 times) Set soft_unbind for the USB drivers, and unregister before cancelling the URBs. Tested on an RTL8922AU (a USB 2 adapter). Signed-off-by: rcfa --- Notes: v2: - One calling order in rtw89_usb_disconnect(): unregister, then cancel the URBs, after an unplug too (v1 kept the old order for a device in USB_STATE_NOTATTACHED). - Commit message reduced to the problem, the log and the test line, without the Fixes tag, as asked; the rest follows here. - Rebased on rtw-next ae6b9e98b904. On the name: rcfa is the name I sign with everywhere, and it is my GitHub identity (https://github.com/rcfa), where the out-of-tree side of this rtw89 work is public, e.g. morrownr/rtw89 pull requests #139 and #141. submitting-patches.rst asks for "a known identity" (since d4563201f33a, 2023), not a legal name. I hope that is acceptable. v1: https://lore.kernel.org/linux-wireless/20261107230547.3673679-1-kernel@cubiculum.net/ You asked whether this comes from sending the deauth frames. Not only: unloading the unchanged driver with no association, so with no deauthentication, still logs the HWSI and RF TSSI errors and a scan abort that times out. The deauthentication adds the three flush timeouts, because its frame cannot be sent. Whatever rtw89_core_unregister() asks of the chip fails, because the URBs are gone by then. You also asked whether soft_unbind alone is enough, and whether one calling order would do. soft_unbind alone is not enough: with the old order an unload logs the same as without it, associated or not, because rtw89_usb_disconnect() then cancels the URBs itself before rtw89_core_unregister(). The reorder without soft_unbind did not help either (tested for v1). One calling order does work; see below. Test details: the out-of-tree copy of this driver (morrownr/rtw89, which carries rtw-next as of 2026-11-05; hence the module name in the log), kernel 7.2.15, IPS off before each unload. Time of the rmmod and the kernel lines after "deregistering interface driver": associated not associated unchanged 2.2, 2.4 s: errors 1.6, 1.6 s: errors soft_unbind only 2.6, 2.2 s: errors 1.5 s: errors this patch 1.9, 1.1 s: deauth (*) 1.0 s: nothing (*) The first of these also logged one "rtw89_hw_scan_offload failed ret -110" and nothing else: a scan was running at the unload, and its abort timed out. v1, which runs the same code on an rmmod, did not log it in three unloads. Unplugging the adapter while associated, with this patch: the disconnect took 1.3 s and logged one "c2h reg timeout", three "timed out to flush queues" and 18 "read HWSI is busy", with no warnings and no task stuck. v1's unplug (2026-11-07), which kept the old order, logged the same lines in the same time: the device is gone by then, so these lines come with either order. Plugged back in, the adapter was probed and connected again. The problem was found with Claude Code (Claude Opus 5.5) while testing the driver; this change and its changelog were written in the same session. drivers/net/wireless/realtek/rtw89/rtw8851bu.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852au.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852bu.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852cu.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8922au.c | 1 + drivers/net/wireless/realtek/rtw89/usb.c | 6 ++++-- 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851bu.c b/drivers/net/wireless/realtek/rtw89/rtw8851bu.c index 6672ebe68f17..e89d5dd05fc8 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8851bu.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8851bu.c @@ -70,6 +70,7 @@ static struct usb_driver rtw_8851bu_driver = { .id_table = rtw_8851bu_id_table, .probe = rtw8851bu_probe, .disconnect = rtw89_usb_disconnect, + .soft_unbind = 1, }; module_usb_driver(rtw_8851bu_driver); diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852au.c b/drivers/net/wireless/realtek/rtw89/rtw8852au.c index ea465d7f8329..2862fab49c06 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852au.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852au.c @@ -86,6 +86,7 @@ static struct usb_driver rtw_8852au_driver = { .id_table = rtw_8852au_id_table, .probe = rtw8852au_probe, .disconnect = rtw89_usb_disconnect, + .soft_unbind = 1, }; module_usb_driver(rtw_8852au_driver); diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852bu.c b/drivers/net/wireless/realtek/rtw89/rtw8852bu.c index 550fc4ac7a21..9c53bc686bca 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852bu.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852bu.c @@ -84,6 +84,7 @@ static struct usb_driver rtw_8852bu_driver = { .id_table = rtw_8852bu_id_table, .probe = rtw8852bu_probe, .disconnect = rtw89_usb_disconnect, + .soft_unbind = 1, }; module_usb_driver(rtw_8852bu_driver); diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852cu.c b/drivers/net/wireless/realtek/rtw89/rtw8852cu.c index 2e46b05b05ee..dbc2274dfc49 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852cu.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852cu.c @@ -145,6 +145,7 @@ static struct usb_driver rtw_8852cu_driver = { .id_table = rtw_8852cu_id_table, .probe = rtw8852cu_probe, .disconnect = rtw89_usb_disconnect, + .soft_unbind = 1, }; module_usb_driver(rtw_8852cu_driver); diff --git a/drivers/net/wireless/realtek/rtw89/rtw8922au.c b/drivers/net/wireless/realtek/rtw89/rtw8922au.c index 4a2bc1b2037f..5715decdc42b 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8922au.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8922au.c @@ -93,6 +93,7 @@ static struct usb_driver rtw_8922au_driver = { .id_table = rtw_8922au_id_table, .probe = rtw8922au_probe, .disconnect = rtw89_usb_disconnect, + .soft_unbind = 1, }; module_usb_driver(rtw_8922au_driver); diff --git a/drivers/net/wireless/realtek/rtw89/usb.c b/drivers/net/wireless/realtek/rtw89/usb.c index 8dc2c93e502e..c854f43c439b 100644 --- a/drivers/net/wireless/realtek/rtw89/usb.c +++ b/drivers/net/wireless/realtek/rtw89/usb.c @@ -1314,10 +1314,12 @@ void rtw89_usb_disconnect(struct usb_interface *intf) rtwdev = hw->priv; rtwusb = rtw89_usb_priv(rtwdev); + /* rtw89_core_unregister() still talks to the chip, so cancel the URBs + * only after it. + */ + rtw89_core_unregister(rtwdev); rtw89_usb_cancel_rx_bufs(rtwusb); rtw89_usb_cancel_tx_bufs(rtwusb); - - rtw89_core_unregister(rtwdev); rtw89_core_deinit(rtwdev); rtw89_usb_deinit_rx(rtwdev); rtw89_usb_free_rx_bufs(rtwusb); base-commit: ae6b9e98b9045e47f609ec2a8197a3f3109627cb -- 2.53.0