1: 8f420e4d30a8 ! 1: 2022bd73df4e wifi: rtw89: usb: keep the endpoints until the driver lets go on unbind @@ Commit message wifi: rtw89: usb: keep the endpoints until the driver lets go on unbind  When the driver is unbound from a device that is still attached (rmmod, - or an unbind through sysfs), usbcore disables the interface's endpoints - and kills their URBs before it calls the disconnect method, unless the - driver sets soft_unbind. rtw89_core_unregister() then still - deauthenticates, flushes the queues and stops the chip, but the bulk - endpoints that carry H2C and C2H are already gone. On an RTL8922AU with - an association, every unload logged: + 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)  - Set soft_unbind for the USB drivers, and in rtw89_usb_disconnect() - unregister before cancelling the RX and TX URBs while the device is - still attached. After an unplug the device is gone, so the order stays - as it was; usbcore disables the endpoints first in that case (state - NOTATTACHED) whether soft_unbind is set or not. + and an unload with no association, while a scan runs:  - Tested on an RTL8922AU (a USB 2 adapter) with the out-of-tree copy of - this driver (morrownr/rtw89, which carries rtw-next as of 2026-11-05), - kernels 7.1.5 and 7.2.15. Every unload while associated now logs only - the deauthentication and "deregistering interface driver", with no - warnings. A physical unplug while associated logs what it logged before - (the messages above), with no warnings and nothing stuck. Reordering - rtw89_usb_disconnect() without soft_unbind changed nothing. The other - USB chips share rtw89_usb_disconnect() but were not tested. + 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.  - The problem was found with Claude Code (Claude Opus 5.5) while testing - the driver, and this change and changelog were written in the same - session. + Tested on an RTL8922AU (a USB 2 adapter).  - Fixes: 2135c28be6a8 ("wifi: rtw89: Add usb.{c,h}") Signed-off-by: rcfa   ## drivers/net/wireless/realtek/rtw89/rtw8851bu.c ## @@ drivers/net/wireless/realtek/rtw89/usb.c: void rtw89_usb_disconnect(struct usb_i rtwdev = hw->priv; rtwusb = rtw89_usb_priv(rtwdev);  -- rtw89_usb_cancel_rx_bufs(rtwusb); -- rtw89_usb_cancel_tx_bufs(rtwusb); -+ /* After an unplug the device is gone, so stop the transfers first. When -+ * the driver is unbound from a device that is still attached (rmmod), -+ * rtw89_core_unregister() still talks to the firmware and needs the RX -+ * transfers for the replies. ++ /* rtw89_core_unregister() still talks to the chip, so cancel the URBs ++ * only after it.  + */ -+ if (rtwusb->udev->state == USB_STATE_NOTATTACHED) { -+ rtw89_usb_cancel_rx_bufs(rtwusb); -+ rtw89_usb_cancel_tx_bufs(rtwusb); -+ rtw89_core_unregister(rtwdev); -+ } else { -+ rtw89_core_unregister(rtwdev); -+ rtw89_usb_cancel_rx_bufs(rtwusb); -+ rtw89_usb_cancel_tx_bufs(rtwusb); -+ } -  ++ 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);