GL-A1300 / IPG40xx xHCI crash on usb disconnect

Hello there :slight_smile:

I've flashed GL-Inet GL-A1300 with openwrt 23.05.5 (firmware built with image builder). Firmware works great with all sorts of wacky configs, but I have issues with USB based interfaces. Whenever I connect a rndis usb dongle modem (usb0) or iphone in tethering mode (cdc modem) it works fine. But the moment I disconnect the modem/iphone from usb xhci-hcd crashes with following log message:

Wed Dec 18 18:02:28 2024 kern.info kernel: [ 1908.527821] usb 1-1: USB disconnect, device number 6
Wed Dec 18 18:02:33 2024 kern.warn kernel: [ 1913.573071] xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command.
Wed Dec 18 18:02:33 2024 kern.warn kernel: [ 1913.573137] xhci-hcd xhci-hcd.0.auto: USBSTS: 0x00000000
Wed Dec 18 18:02:33 2024 kern.warn kernel: [ 1913.612256] xhci-hcd xhci-hcd.0.auto: Host halt failed, -110
Wed Dec 18 18:02:33 2024 kern.err kernel: [ 1913.612289] xhci-hcd xhci-hcd.0.auto: xHCI host controller not responding, assume dead
Wed Dec 18 18:02:33 2024 kern.err kernel: [ 1913.617045] xhci-hcd xhci-hcd.0.auto: HC died; cleaning up
Wed Dec 18 18:02:33 2024 kern.info kernel: [ 1913.625813] rndis_host 1-1:1.0 usb0: unregister 'rndis_host' usb-xhci-hcd.0.auto-1, RNDIS device
Wed Dec 18 18:02:33 2024 daemon.notice netifd: Network device 'usb0' link is down

After this crash USB seems to be not powered on and no new devices are recognized until I do:

rmmod xhci_plat_hcd
modprobe xhci_plat_hcd

Here is my make for image builder in case it's needed (files contains irrelevant stuff like custom banner etc):

make image \
PROFILE="glinet_gl-a1300" \
FILES="files" \
PACKAGES="zsh vim tmux luci tor kmod-wireguard kmod-usb-net kmod-usb-ehci kmod-usb-net-cdc-ether kmod-usb-net-cdc-ncm kmod-usb-net-huawei-cdc-ncm kmod-usb-net-qmi-wwan kmod-usb-net-rndis luci-app-commands luci-app-openvpn luci-proto-ncm luci-proto-wireguard stubby nmap ss openssh-sftp-server wireguard-tools socat tcpdump-mini picocom usb-modeswitch shadow-chsh kmod-usb-net-ipheth usbmuxd libimobiledevice usbutils mwan3 luci-app-adblock luci-app-sqm curl"

There are no issues with usb connected modems under full load so we can rule out power issues. Help much appreciated! :slight_smile:

I have found a (somewhat dirty) workaround here: Optimized build for IPQ40xx devices - #341 by fdm - basically it's a hotplug script that reloads same module. I discovered here that you can achieve same thing by sending device id into /sys/bus/pci/drivers/xhci_hcd/bind (and unbind). This might be faster then full module reload but it's tedious (I think) to get faulty device id to echo there.