USB slots stop working suddenly from time to time

After re-installing Lubuntu 12.04 system on my laptop an older problem re-emerged after a few days and installation of different programs: without apparent reason the external mouse and sometimes other usb connected devices (including hdd) stop working. The hdd shows it has tension as it has a light there, and the external mouse flashes for a second when plugged.

I have posted a different version of this problem before. I keep it for now as example of the two answers there. None of them works here.

Logging out-in does nothing, restart does.

The event seems entirely random, after reboot it will reappear after many days or weeks or, rarely, after a few hours.

  • http://pastebin.com/0qR8bhhX in var/log/syslog after new occurrence (with only external wired mouse and keyboard)

What counts is at the end I guess:

Nov 24 14:06:55 cprq-HP-Compaq-nx8220-PY518EA-ABB kernel: [29953.822962] usb 3-1: USB disconnect, device number 3
Nov 24 14:06:57 cprq-HP-Compaq-nx8220-PY518EA-ABB kernel: [29955.069427] uhci_hcd 0000:00:1d.0: host controller process error, something bad happened!
Nov 24 14:06:57 cprq-HP-Compaq-nx8220-PY518EA-ABB kernel: [29955.069439] uhci_hcd 0000:00:1d.0: host controller halted, very bad!
Nov 24 14:06:57 cprq-HP-Compaq-nx8220-PY518EA-ABB kernel: [29955.069461] uhci_hcd 0000:00:1d.0: HC died; cleaning up
Nov 24 14:06:57 cprq-HP-Compaq-nx8220-PY518EA-ABB kernel: [29955.069492] usb 2-2: USB disconnect, device number 2
  • I have noticed that on most occasions only the external mouse and keyboard are affected, but not the external HDD. Or if it is, replugging it solves the problem.

  • I have a dual boot with WinXP: in Windows this never happens, so it is not a hardware issue

  • I have used Lubuntu Quantal 12.10 and the same problem happened there as well. Upgrading to that would not be a solution

  • On certain occasion only restarting 2 or even 3 times solved it.


Using the same PC/hardware with Linux Mint 14 (Quantal) Xfce, the problem almost disappeared(it happened once since then). I am not sure whether this 'solution' comes from using Xfce or Mint (I guess Mint 14 Nadia uses the same kernel as Lubuntu Quantal).


Something similar to this was happening to me. This blog post provided a partial solution.

This is what worked for me:

sudo -s
cd /sys/bus/pci/drivers/xhci_hcd/
for file in ????:??:??.? ; do
 echo -n "$file" > unbind
 echo -n "$file" > bind
done

As noted at that block post, different systems get hung up in different places, so if the above doesn't work, you might want to try replacing /sys/bus/pci/drivers/xhci_hcd/ with /sys/bus/pci/drivers/ehci_hcd/, or /sys/bus/pci/drivers/uhci_hcd/, if one of those exists.


Power issues for USB 2.0

USB 2.0 has a maximum current draw available of 500mA, however it should be noted that the +5V on several ports may actually be on the same bus. For example on a desktop case the USB ports on the front of the machine may all be on the same bus, while the ports on the back of the machine will normally be a a different bus, or have completely separate +5V supplies for each group of USB 2.0 sockets.

A low current device as defined by the USB 2.0 standards can draw up to 100mA (1 unit) while high current devices can draw up to 5 units (500mA). Hard drives with no external source of supply are typically high current devices.

Devices should stop working if the +5V line drops below 4.75V and this is why many high power devices can cause problems on some computers.

In addition to this the circuit that supplies +5V to each bus may refuse to re-negotiate high power capability if the device is drawing enough current to pull the +5V line too low. This is why high power devices will need to be removed and re-attached before they will work if they have failed due to a power problem, and also why a reboot does not allow them to re-attach while a full power down/up cycle may do so.

Note that if one or more low power devices are already plugged into a USB bus, there may not be enough capacity available to also run a high power device such as an external hard drive.

Using high power devices therefore needs to be planned for, and if problems exist the device needs to be used on it's own on any one bus or given a separate +5V supply.

While the USB 2.0 standards document might be a little difficult to read, there is some very good information and explanations in the wikipedia page on the subject of USB 2.0

Also note that plugging in many low power devices such as through an external USB hub device can also cause a voltage drop on the bus supply line, causing some or all of the devices to be disabled.

The types of cables used may also affect the reliability of high power devices. For example an external hard drive plugged in via a regular long USB cable may see enough of a voltage drop at 500mA to disable itself to prevent damage to its circuitry or drive motors. These devices are typically supplied with a special short cable, or a 'Y' cable that plugs into two USB ports to help with the power problem. Note that this only a partial solution to the problem relating specifically to the cabling issue, it's doesn't actually allow more than 500mA to be supplied since adjacent USB ports are likely to be on the same 5V 500mA supply internally in the computer. Even where a separate bus is used for the second plug on the 'Y' cable it won't be able to get a high current supply since it has no data connection to request it from the USB bus. Only one of the ports will be enabled as a high current supply.

Since the very common use of USB keyboards and mice, problems can sometimes occur when these are both plugged into the same bus. Peak load currents at power-on can exceed the design specification of the USB bus and cause one or both of the devices to be disabled or to malfunction.

Solutions to these problems usually involve using only a minimum of low power devices, using only well designed and made low power devices, making sure they are plugged into different buses with separate +5V lines, and where high power devices are involved using a powered hub to help with the supply problems seen on many USB 2.0 bus supplies. If it's not possible to use a powered hub, then the high power device should only be plugged in after the computer is powered up and the current drain from low power devices has stabilised.

It should also be noted here that computers such as laptops and netbooks may have low power USB devices incorporated internally. Hardware such as internal card readers, wireless 3G adapters, and webcams are often connected internally to a USB bus. This may be a dedicated bus with it's own +5V power, or it may be shared with one or more external USB ports.


Old post, and replies are not relevant to USB 3.0. So here's how to reset a 3.0 Bus that stopped serving data:

su -

and as root:

echo -n "0000:06:00.0" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
echo -n "0000:06:00.0" | tee /sys/bus/pci/drivers/xhci_hcd/bind

After this, USB should start to work correctly again, just like after a restart.


Explanation

In case you're using a different driver, this is how I found what to do, use it as a reference:

A lsusb -t will output this - take a note of the xhci_hcd driver for the fast bus, it's the 3.0 driver name:

$ lsusb -t
        /:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
        /:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
            |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=dvb_usb_it913x, 480M
        /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
            |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
            ...etc

The directory to look for is /sys/bus/pci/drivers/xhci_hcd

        drwxr-xr-x  2 root root    0   5 21:48 ./
        drwxr-xr-x 28 root root    0   1 00:21 ../
        lrwxrwxrwx  1 root root    0   6 00:29 0000:06:00.0 -> ../../../../devices/pci0000:00/0000:00:1c.3/0000:06:00.0/
        --w-------  1 root root 4096   5 22:33 bind
        lrwxrwxrwx  1 root root    0   5 22:32 module -> ../../../../module/xhci_hcd/
        --w-------  1 root root 4096   5 22:32 new_id
        --w-------  1 root root 4096   5 22:32 remove_id
        --w-------  1 root root 4096   5 22:32 uevent
        --w-------  1 root root 4096   5 22:33 unbind

In my case I needed to unbind "0000:06:00.0".

ps. If you need to rebind the USB 2.0 driver, follow the above instructions but with ehci-pci, or look here (deserves a credit).


kernel vs hardware issues

If you have ruled out possible hardware issues such as voltage/current problems, failing USB ports/hubs then this is probably a kernel problem.

If you feel comfortable with possible non-booting issues/black screen issues on boot, you could try installing the quantal kernel available in the 12.04 repositories.

  • My computer boots to a black screen, what options do I have to fix it?

Remember - most blackscreen issues are due to installation of proprietary graphics drivers. You will have most luck removing these first before upgrading your kernel.

To install the quantal kernel:

sudo apt-get install linux-generic-lts-quantal

Remember to do a full system backup to allow you to recover if the new kernel breaks more than it fixes.

  • Comparison of backup tools