On Fri, 29 Aug 2003, Barbini Uberto wrote:

> ok, I'll try but I want to understand better the code before.
> I hope you don't minds some questions:
> Do you think the problem is related to my specific usb-key hw or software
> (i.e. fs, partitions)?

I think the problem is the software (firmware really) embedded within your 
usb-key.  It should respond properly to all the different driver versions 
you have tried, but it doesn't.

> I was surprise that your patch affect /scsi/sd.c. I though the problem was
> in usb-storage, what are the responsabilities of these two modules and
> exactly what does do_mode_sense?

Usb-storage is responsible for taking the commands issued by the SCSI 
driver and sending them to the device, then taking the replies from the 
device and sending them back to the SCSI driver.  It does not look at the 
contents of the commands or replies (or at least, not very much).

sd.c is the SCSI disk driver.  It constructs the commands that are sent to 
the device.  In this case, the subroutine sd_read_cache_type() sends 
commands that attempt to determine what kind of cache the device uses.  
The MODE-SENSE command tells the device to send back various pieces of 
information that describe how it works.  The information is organized into 
pages, and one of the pages (number 8, as you can see in the source code) 
contains the caching information.

The problem is how much of the page's data should sd.c ask for?  According 
to the SCSI specification, any device should be able to handle a 
request of any size.  If the request is smaller than the size of the page, 
the device should return only the amount requested.  If it is larger than 
the size of the page, the device should return only the actual page size.
sd.c tries to be cautious about this.  First it asks just for the page 
header, which contains the actual page size.  Then it asks for the actual 
page size or 128 bytes, whichever is smaller.
 
But in practice many devices aren't compliant with the specification and
don't work properly.  For example, on your CF card the total page size is
16 bytes.  It worked with 2.6.0-test3, where sd.c asked for 128 bytes and
the card returned 16.  It didn't work with the first patch I sent you,
which caused sd.c to ask for only 12 bytes (which is all it really needs).  
I've seen debugging logs from other users where the device worked when
asked for 12 bytes but crashed when asked for 128.

So far your usb-key device hasn't responded at all to this command, no
matter how many bytes it was asked for.  That is, it sent the page header
okay but not the actual page data.  Maybe it just doesn't like the
mode-sense cache page.

If you want, you could try getting rid of most of the sd_read_cache_type
routine in sd.c.  Just leave the last few lines, where it prints a log
message saying that it assumes the cache is write-through and it sets
sdkp->WCE and sdkp->RCD to 0.  Maybe then the usb-key will work.  Of
course, this would also affect the operation of any other SCSI devices you
have on your system.

Alan Stern



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to