On Mon, 21 Feb 2005, Glenn Maynard wrote:

> I'm polling for changes in USB devices; when something changes, I grab the
> contents of idVendor, idProduct, serial, product and manufacturer.  (The
> serial is used to make a best effort at detecting when a previously-known
> device was inserted; though I'm seeing that many devices don't have unique
> serials or anything close--best effort will have to do, I guess.)

While your approach is okay for now, it's not really a good idea.  There's 
the non-unique (or even non-existent) serial number problem you noticed.  
There's also the fact that by continually probing all the USB devices, you 
will prevent them from entering a power-saving suspend state.  Although 
the Linux USB stack doesn't implement this sort of thing now, it will in 
the future.

If all you care about is device insertion and removal, why don't you make 
use of hotplug events instead?  That's exactly what they're intended for.

> This occasionally causes a timeout with some USB pen drives.
> 
> Running
> 
>   while true; do cat 
> /sys/devices/pci0000:00/0000:00:1d.1/usb2/2-2/2-2.1/serial; done
> 
> and inserting an Attache stick with ub loaded will display the serial
> about five to seven times and then hang.  usb-storage spams the serial
> during the "waiting for device to settle" delay, and then similarly
> hangs (logs attached).

What does "spams the serial" mean?  What makes you think usb-storage is 
doing it (whatever it is) during the device-settle delay?  During that 
delay usb-storage doesn't do anything; it just sleeps.

> 2.6.10 and 2.6.11-rc4-bk8.

It's known that some USB mass storage devices are unable to handle control 
requests on endpoint 0 while carrying out SCSI commands.  Since reading 
the serial string involves just such a control request, it's not 
surprising that your stick runs into trouble.

Your log doesn't show usb-storage hanging.  In fact it doesn't show
anything at all after the error messages from trying to read the serial.  
What happens when the hang occurs?  What does Alt-SysRq-T show for the
usb-storage process and the SCSI error-handler process?  If you turn on
usb-storage verbose debugging, what does that reveal?

Alan Stern



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to