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!

No comments: