tomlankhorst / comments

utterances 🔮
0 stars 0 forks source link

unresponsive-usb-unbind-bind-linux #14

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Re-binding XHCI driver to make USB responsive again after resume | Tom Lankhorst

After updating my Ubuntu 20.04 LTS installation’s Linux Kernel to 5.8 from 5.4, I started experiencing irregular problems with unresponsive USB devices after resuming from sleep. Once in every few wakeups, the USB mouse and Bluetooth transciever would ‘freeze’ and the devices vanish from the lsusb list. After some playing around, I found that unbinding and rebinding the XHCI driver resolved the issue for me. When all works fine, the output of the lsusb command would look something like this:

https://tomlankhorst.nl/unresponsive-usb-unbind-bind-linux

rHilkner commented 3 years ago

Man, this just saved me from a long time of pain. I'm actually farming Chia (XCH) and I have 44 usb external hdds farming, but after a few hours or days a few of them start giving "Input/Output error" when I try to execute any commands on them (touch, ls, cp). If I manually go and reconnect them, they start working again (maybe for a few hours or days). But this is such a pain and makes me lose so much time and farming and I also don't live in the same place of my machine, I usually just access it through ssh. For weeks now I've searched for a solution and finally, rebinding the drives seem to have fixed it! Thank you so much and I'll write here again if I have any trouble or success.

MarcoBonino commented 2 years ago

I can unbind the usb driver, but when I try to bind it get: tee: /sys/bus/pci/drivers/xhci_hcd/bind: No such device

How can I bind it again ?

Forge64 commented 1 year ago

@marcobonino I'm sorry, this is probably too late to help you, but I just whipped these up to rebind my USB controller from xhci to vfio and back again. libvirt can do it automatically, but child devices sometimes go missing while in use which makes kernel angriness.

vfio.rebind.vfio.sh:

!/bin/bash

echo '0000:08:00.0' > /sys/bus/pci/devices/0000\:08\:00.0/driver/unbind echo 1b73 1100 > /sys/bus/pci/drivers/vfio-pci/new_id EOF

(ends with USB controller operating under vfio-pci)

vfio.rebind.xhci.sh:

!/bin/bash

echo 1b73 1100 > /sys/bus/pci/drivers/vfio-pci/unbind echo 0000:08:00.0 > /sys/bus/pci/drivers/xhci_hcd/bind EOF

(ends with USB controller back under xhci, operating normally)