Re: [Discussion] USB: musb-gadget: how to fix ZLP issue in musb_g_tx

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

 



2010/9/16 Sergei Shtylyov <sshtylyov@xxxxxxxxxx>:
> Hello.
>
> On 16-09-2010 8:46, Ming Lei wrote:
>
>>>> If so, once the dma interrupt comes, will request->actual be same
>>>> with request->length in musb_g_tx?  And if it is true, could we remove
>>>> the
>>>> check for 'is_dma'?
>
>>> see that is_dma is set to true by just checking if dma in enabled in
>>> txcsr, it might be that dma didn't complete everything and you need to
>>> write txpktrdy by hand to send last short packet. So to remove that you
>>> would need to re-work a bit more code.
>
>>> You need to know when this is a dma IRQ or an endpoint IRQ.
>
>> How about the fix below(against the previous patch set) for the
>> ZLP problem pointed by Sergei?
>
>> diff --git a/drivers/usb/musb/musb_gadget.c
>> b/drivers/usb/musb/musb_gadget.c
>> index 46cf94a..a15a83c 100644
>> --- a/drivers/usb/musb/musb_gadget.c
>> +++ b/drivers/usb/musb/musb_gadget.c
>> @@ -477,40 +477,37 @@ void musb_g_tx(struct musb *musb, u8 epnum)
>>                                epnum, csr, musb_ep->dma->actual_len,
>> request);
>>                }
>>
>> -               if (is_dma || request->actual == request->length) {
>> -                       /*
>> -                        * First, maybe a terminating short packet. Some
>> DMA
>> -                        * engines might handle this by themselves.
>> -                        */
>> -                       if ((request->zero && request->length
>> -                                && request->length % musb_ep->packet_sz
>> == 0)
>> +               /*
>> +                * First, maybe a terminating short packet. Some DMA
>> +                * engines might handle this by themselves.
>> +                */
>> +               if ((request->zero && (request->actual ==
>> request->length))
>
>   No. You should only send ZLP only if (request->length % musb_ep->packet_sz
> == 0)

Suppose the condition of "request->zero && (request->actual ==
request->length)" is true now:

- if request->length % musb_ep->packet_sz == 0, the patch can send zlp out
without any problem

-if request->length % musb_ep->packet_sz != 0, in the dma case we may set
txpktrdy to send out short packet since the 2nd condition is triggered, and in
pio case txstate has set it already if  request->actual == request->length;

So from the analysis, seems the patch can process correctly either
request->length % musb_ep->packet_sz is 0 or not.

Please help to check the above further.

thanks,
-- 
Lei Ming
--
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