Re: [PATCH] usb: gadget: file_storage: don't assume wMaxPacketSize to be 512

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 3 Apr 2011, Felipe Balbi wrote:

> > It's a bad idea.  I advise against using a variable block size; keep it 
> > set to 512.
> 
> In that case, how do we avoid short on SuperSpeed ? OUT transfers will
> have to be aligned on wMaxPacketSize (on the controller level at least),
> so if block size is always 512 how can I make a three block transfer be
> aligned on 1024 ?

Felipe, you're not using the word "short" correctly.  A short packet is
one that's smaller than the maxpacket size, whereas a short transfer is
one that's smaller than the recipient expected.

So, in your example, if the device expects to receive 3 * 512 bytes,
and the host sends one packet containing 1024 bytes followed by another
packet containing 512 bytes, it _isn't_ a short transfer -- the device 
receives exactly what it expects!  True, the last packet is a short 
packet, but so what?

Now, are you asking how to avoid short packets or short transfers?  
There's no way to avoid short packets.  If the hardware can't handle 
short packets, it is completely broken and there's no sense even trying 
to use it.  As an example, consider that the CBW packet is 31 bytes and 
therefore will be short at any speed.

As for short transfers...  In theory, if everything is working 
correctly, the Bulk-Only Transport never has short bulk-OUT transfers.  
(Of course, if something goes wrong then one could occur.)  Still, I 
don't see why you're so anxious to avoid them.  Short transfers are a 
fact of life, explicitly allowed for in the USB spec.  Why worry about 
them?

> IMO, it's best to either use wMaxPacketSize as block size, or use "the
> more common value of 2048", to avoid it for a few more USB revisions.
> Isn't it bad to have the assumption that block size is 512 no matter
> what ?

What's bad about it?  Virtually all the existing disk-like USB mass
storage devices (i.e., pretty much everything except USB CDROM drives)  
use 512-byte blocks.  I bet a lot of BIOSes won't be able to boot from 
a USB disk/flash drive with a block size other than 512.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux