Re: [PATCH] usb: dwc3: gadget: Wait for ep0 xfers to complete during dequeue

From: Thinh Nguyen
Date: Wed Mar 09 2022 - 15:11:19 EST


Thinh Nguyen wrote:
> Hi,
>
> Wesley Cheng wrote:
>> From: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
>>
>> If the request being dequeued is currently active, then the current
>> logic is to issue a stop transfer command, and allow the command
>> completion to cleanup the cancelled list. The DWC3 controller will
>> run into an end transfer command timeout if there is an ongoing EP0
>> transaction. If this is the case, wait for the EP0 completion event
>> before proceeding to retry the endxfer command again.
>
> Can you fix the commit message as follow:
>
> If a Setup packet is received but yet to DMA out, the controller will
> not process the End Transfer command of any endpoint. Polling of its
> DEPCMD.CmdAct may block setting up TRB for Setup packet, causing a
> command timeout.
>
> This may occur if the driver doesn’t service the completion interrupt of
> the control status stage yet due to system latency, then it won’t
> prepare TRB and start the transfer for the next Setup Stage. To the host
> side, the control transfer had completed, and the host can send a new
> Setup packet at this point.
>
> In the meanwhile, if the driver receives an async call to dequeue a
> request (triggering End Transfer) to any endpoint, then the driver will
> service that End transfer first, blocking the control status stage
> completion handler. Since no TRB is available for the Setup stage, the
> Setup packet can’t be DMA’ed out and the End Transfer gets hung.
>
> The driver must not block setting up of the Setup stage. So track and
> only issue the End Transfer command only when there’s Setup TRB prepared
> so that the controller can DMA out the Setup packet. Delay the End
> transfer command until there's no Setup TRB available. This is

typo:
Delay the End transfer command *if* there's no Setup TRB available.


> applicable to all DWC_usb3x IPs.
>