2006-07-18

USB mass storage support in Linux sucks!

After an extremely frustrating afternoon of seeing the Linux UHCI driver repeatedly shut itself down, following several successive I/O errors while accessing USB mass storage (a 512Mb Compact Flash connected via a USB card reader, in one case, and a 512Mb USB stick, in the other), I spent an even more frustrating evening surfing the Internet for a solution. Conclusion:

USB mass storage support in Linux sucks!

Several mailing lists and user forums report similar failures using USB 2.0 devices on Linux UHCI or EHCI drivers, down to the exact same error messages that I get. Some even report the whole USB subsystem going down, leaving the user without any keyboard or mouse on USB-only systems (this matches my findings on one particular hardware platform that happens to be at the core of a project I'm working on). The suspected cause, in all cases, apparently boils down to either or all these:

  • The SCSI subsystem upon which USB (and Firewire) mass storage is built is utter crap that would need a complete rewrite. The issue has been known for ages, it's even a proverbial elephant in the corner that nobody wants to see, but rewriting the subsystem for a standard that barely has any real-life application left means opening a big can of worms.
  • None of the Linux kernel's HCI are capable of anticipating the quirks present in some implementations of the USB hardware specifications, so they simply panic and commit suicide in syslog-flooding glory.
  • There is apparently a hard-coded limit of 1000 units (blocks?) that, when exceeded, will make the mass storage driver reset itself! Doesn't sound like Willliam Gates the Third's often-mentioned "Nobody needs more than 640k" now, does it?

I can feel for the average user who is just trying to extract a few pictures off a USB stick and who simply ends up reinstalling $commercial_os in frustration. Wasting a couple of days trying to debug support for what is supposedly a well-documented industry standard should never happen. There is no excuse for a broken USB mass storage on Linux. Let's fix it!

1 kommentti:

p2 kirjoitti...

The problem is not so much linux but the USB 'specifications' and the compliance level of the devices. A customer of our company did his own USB stack including mass storage support and found in his testing that exactly 1 out of 50 mass storage devices adheres to all the relevant specifications. In testing my own USB devices I noticed that some hosts (Dell in particular) show poor signal quality on some ports. Also official USB certification consists of testing the device against a whole range of machines and OSes instead. Apparently verifying the device complies with all the relevant specifications is not enough to guarantee interoperability... IMO this points to a broken spec. Obviously better error handling would hide the problems, but proper adherence to specifications would avoid the problems in the first place. In
short USB is a nightmare ! I'm always surprised I manage to get correct data over this sick interface.