Re: [PATCH v2 5/6] usb: musb: introduce dma_channel.packet_done

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

 



On 05/23/2014 02:14 PM, George Cherian wrote:
> On 5/23/2014 5:04 PM, Daniel Mack wrote:

>> Assume wMaxPacketSize == 512 and the following sequence of incoming
>> packet sizes: 512, 512, 384. The URB should be given back after the 384
>> packet has been received, with an effective total length of 1408 bytes.
>>
>> The code in musb_cppi41.c does the right thing by not reloading a new
>> DMA descriptor but calling musb_dma_completion() from
>> cppi41_trans_done(). However, both checks for 'done' that the core
>> currently looks at a false in that case (musb_host.c, ~ line 1740):
>
> In rx we always use the transparent mode of CPPI dma.
> In transparent mode we always program the min( packet_sz,len) 
> [musb_cppi41.c cppi41_configure_channel()]
> In your example len is 16K and packet_sz is wMaxPacketSize.

Yes, exactly. And when the DMA buffer returns from the DMA controller
with a residue of 0 (IOW, wMaxPacketSize have been transferred), the DMA
channel is reloaded, and the next packet is requested. The core has
nothing to do with this, it's only getting into the game again when
cppi41_trans_done() decides to call musb_dma_completion(), either
because the buffer is completely filled, or because of a short read.

> Basically it always does a wMaxPacketSize of dma and updates the 
> urb->actual_length in return.

That's correct. But the problem is that the musb core won't give the urb
back, as its 'done' determination fails in the cases described in my
last mail. It all works fine if the *first* packet in a sequence is
already a short read, but as soon as at least one packet was filled with
wMaxPacketSize bytes prior to a short read, 'done' will never be true in
musb_host.c. I've debugged that for many hours the last days :)

> In RX we cant use the Generic RNDIS mode of CPPI, due to some of the 
> bugs in the silicon.

Jup, I know. If been staring at the fixup code for this Advisory for
quite a while until I figured that it actually makes things a lot worse
by detecting and fixing up errors where none are, because of the missing
musb_ep_select() calls. With those in place (#6), data toggle mismatches
are only detected when they actually happened. But without them, the
manual fixup would actually cause packets to be lost, even if only one
IN endpoint is involved.


Best regards,
Daniel

--
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