Flattr this!

One of the developers of the Linux kernel Sarah Sharpe at Intel sprinkles ashes on his head : for the eight years of work on Linux USB stack are repeatedly confronted with a situation where USB-device is suddenly disconnected after leaving the standby mode activated auto-Suspend . All the while, the problem ascribed to Chinese manufacturers of cheap flash drives, mice and keyboards. Even discussed the idea to introduce a “black list” of models of these devices into the kernel, to keep them activated on power saving mode. The idea was abandoned only when it became clear that the list would be too large: there are so many USB-devices that work properly.

Now it turned out that the failures were not always the hardware.

In the code, the host controller Intel xHCI (drivers / usb / core / hub.c) is a line with a laconic comment “TRSMRCY = 10 msec”. In accordance with paragraph of specifications USB 2.0, USB System Software system should provide time of 10 milliseconds for the restoration of the device, for which it does not send any requests. In the Linux kernel simply inserted a timeout of 10 ms. But experts on the hardware now noticed the kernel developers Linux, which in Table 7-14 USB 2.0 specification states that the timeout should be at least 10 milliseconds, not the maximum. This means that the device can recover longer than currently found in a row in TRSMRCY Linux USB. In such cases, when you try to access it may be a communication error – then the operating system considers the device turned off.

Tests have shown that the yield of the device from sleep mode is never greater than 17 ms, but 8% of the more than 10 ms. To fix the bug is enough to increase the timeout value from 10 to 20 ms, after which all USB-devices will begin to work normally. Sarah Sharp has produced a patch.

The developers say that most of the bug affects users ChromeOS, because this system uses a very aggressive power saving mode to USB, activating the auto-suspend for all internal USB-devices such as WiFi and Bluetooth.