Re: [v2] usb: UHCI: fix pkt size in TD for a non-aligned sg element

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

 



On Sat, 22 Jun 2013, Ming Lei wrote:

> On Sat, Jun 22, 2013 at 12:13 AM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> > On Fri, 21 Jun 2013, Ming Lei wrote:
> >
> > I'm not sure what you mean.  Do you mean that usb_sg_init() should fail
> > if the SG element length isn't a multiple of the maxpacket size?  That
> > probably will break wireless USB.
> >
> > Do you mean that usb_sg_init() should break the transfer up into a
> > bunch of separate URBs in this case (the way it does when the HCD
> > doesn't have native support for SG)?  That won't work because one of
> > the URBs would have a transfer length that wasn't a multiple of the
> > maxpacket size.
> 
> Yes.
> 
> Sorry, could you explain why that won't work? I understand the URBs
> with maxp-unaligned length still can be completed.

Suppose the SG list has two elements, where the first element's length 
is 1000 (not a multiple of 64) and the second element's length is 512.  
Then usb_sg_init() will create two URBs to carry out the transfer.  The 
transfer_length of the first URB will be 1000 and the transfer_length 
of the second URB will be 512.

When the first URB is submitted to uhci-hcd, it will be broken up into
15 TDs of length 64 (the maxpacket size) followed by a TD of length 40.  
The second URB will be broken up into 8 TDs of length 64.

Therefore the device will see 15 full-size packets, a short packet, and 
then 8 more full-size packets.  This is not what you want.

(By the way, this is exactly what would happen when the same transfer
is submitted to an HCD that doesn't have SG support, like ohci-hcd.  As
you can see, the problem doesn't lie in the fact that SG is being used;
it lies in the fact that the SG element length isn't a multiple of the
maxpacket length.)

> > Furthermore, URBs using SG can be submitted directly, without going
> > through usb_sg_init() at all.  So changing usb_sg_init() won't fix the
> > problem.
> 
> Looks usbtest use it, so the reported problem can be fixed.

Sometimes it's hard to tell whether you are serious or joking.

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