Re: [PATCH] usb: misc: usbtest: fix pattern tests for scatterlists.

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

 



On Tue, 3 May 2016, Felipe Balbi wrote:

> Hi,
> 
> Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> writes:
> > On Mon, 2 May 2016, Mathias Nyman wrote:
> >
> >> The current implemenentation restart the sent pattern for each entry in
> >> the sg list. The receiving end expects a continuous pattern, and test
> >> will fail unless scatterilst entries happen to be aligned with the
> >> pattern
> >
> > Ah.  We didn't spot this earlier because for non-xHCI controllers, the 
> > scatterlist entries _must_ be aligned with the maxpacket size and 
> > therefore with the pattern.
> 
> interesting. We actually found a similar issue with XHCI. scatterlist
> has to be aligned to wMaxPacketSize but only before a link TRB. Mathias
> has been working on a solution which involves memcpy()ing enough bytes
> to align to wMaxPacketSize before the link TRB (it's very infrequent as
> we have 256 TRBs per segment on XHCI), but if you know of a nicer way,
> we're all ears :-)

You should be able to handle this without memcpy'ing anything.

If the individual scatterlist entries are large enough, you can simply
end the ring segment early.  Either put a link TRB before the physical
segment end, at the last point where the cumulative transfer size is
divisible by maxpacket, or else fill out from there to the end of the
segment with no-op TRBs.  Common case: Each scatterlist entry is a
multiple of 512 bytes and the maxpacket size is 1024.  Then you either
have to split the last entry in two or move it completely into the next
ring segment.

This approach doesn't work quite as well if the scatterlist entries are
very small.  For instance, if they are 8 bytes or smaller then you
might have to fill out the segment with 128 or more no-op TRBs, which
is not so good if the segment can hold only 256 TRBs.  I suppose we
could simply rule this out by requiring SG transfers to have a minimum
entry size of 128 bytes, or something like that.

> /me goes dig EHCI

Not sure that will help.  The same issue could arise there, if the 
scatterlist entries were smaller than 512 bytes.  The driver doesn't 
handle this case properly, but it works out okay because the case never 
comes up.

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