diff mbox series

[v2,2/2] usb: dwc3: gadget: when the started list is empty stop the active xfer

Message ID 20200624144907.9604-3-m.grzeschik@pengutronix.de (mailing list archive)
State Superseded
Headers show
Series usb: dwc3: gadget: improve isoc handling | expand

Commit Message

Michael Grzeschik June 24, 2020, 2:49 p.m. UTC
When we have nothing left to be queued after handling the last trb
we have to stop the current transfer. This way we can ensure that
the next request will be queued with an new and valid timestamp
and will not directly run into an missed xfer.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

---
v1 -> v2: - This Patch replaces the following patch by Michael Olbrich:
            usb: dwc3: gadget: restart the transfer if a isoc request is queued too late

 drivers/usb/dwc3/gadget.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Thinh Nguyen June 24, 2020, 7:43 p.m. UTC | #1
Hi,

Michael Grzeschik wrote:
> When we have nothing left to be queued after handling the last trb
> we have to stop the current transfer. This way we can ensure that
> the next request will be queued with an new and valid timestamp
> and will not directly run into an missed xfer.
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>
> ---
> v1 -> v2: - This Patch replaces the following patch by Michael Olbrich:
>              usb: dwc3: gadget: restart the transfer if a isoc request is queued too late
>
>   drivers/usb/dwc3/gadget.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 0962ddd7fbf6ae6..b2b8b911ac79b39 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2729,7 +2729,10 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
>   	if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
>   		goto out;
>   
> -	if (status == -EXDEV && list_empty(&dep->started_list))
> +	if ((status == -EXDEV && list_empty(&dep->started_list)) ||
> +		(usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
> +			list_empty(&dep->started_list) &&
> +			list_empty(&dep->pending_list)))

The -EXDEV check is also for isoc, maybe rearrange this for easier read:
if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
     list_empty(&dep->started_list) &&
     (list_empty(&dep->pending_list) || status == -EXDEV))

>   		dwc3_stop_active_transfer(dep, true, true);
>   	else if (dwc3_gadget_ep_should_continue(dep))
>   		if (__dwc3_gadget_kick_transfer(dep, false) == 0)

BR,
Thinh
Michael Grzeschik June 25, 2020, 12:04 p.m. UTC | #2
On Wed, Jun 24, 2020 at 07:43:44PM +0000, Thinh Nguyen wrote:
>Hi,
>
>Michael Grzeschik wrote:
>> When we have nothing left to be queued after handling the last trb
>> we have to stop the current transfer. This way we can ensure that
>> the next request will be queued with an new and valid timestamp
>> and will not directly run into an missed xfer.
>>
>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>>
>> ---
>> v1 -> v2: - This Patch replaces the following patch by Michael Olbrich:
>>              usb: dwc3: gadget: restart the transfer if a isoc request is queued too late
>>
>>   drivers/usb/dwc3/gadget.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index 0962ddd7fbf6ae6..b2b8b911ac79b39 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -2729,7 +2729,10 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
>>   	if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
>>   		goto out;
>>
>> -	if (status == -EXDEV && list_empty(&dep->started_list))
>> +	if ((status == -EXDEV && list_empty(&dep->started_list)) ||
>> +		(usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
>> +			list_empty(&dep->started_list) &&
>> +			list_empty(&dep->pending_list)))
>
>The -EXDEV check is also for isoc, maybe rearrange this for easier read:
>if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
>     list_empty(&dep->started_list) &&
>     (list_empty(&dep->pending_list) || status == -EXDEV))

Right, I will change it in v3.

>>   		dwc3_stop_active_transfer(dep, true, true);
>>   	else if (dwc3_gadget_ep_should_continue(dep))
>>   		if (__dwc3_gadget_kick_transfer(dep, false) == 0)

Thanks,
Michael
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 0962ddd7fbf6ae6..b2b8b911ac79b39 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2729,7 +2729,10 @@  static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
 	if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
 		goto out;
 
-	if (status == -EXDEV && list_empty(&dep->started_list))
+	if ((status == -EXDEV && list_empty(&dep->started_list)) ||
+		(usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
+			list_empty(&dep->started_list) &&
+			list_empty(&dep->pending_list)))
 		dwc3_stop_active_transfer(dep, true, true);
 	else if (dwc3_gadget_ep_should_continue(dep))
 		if (__dwc3_gadget_kick_transfer(dep, false) == 0)