Re: [PATCH 2/3] usb: dwc3: gadget: Don't skip updating remaining data

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

 



Hi,

Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx> writes:
> DWC3 must check for the BUFSIZ and update the req->remaining
> regardless of transfer alignment. Returning early from transfer OUT
> unalignment will skip updating the req->remaining.
>
> Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
> Signed-off-by: Thinh Nguyen <thinhn@xxxxxxxxxxxx>
> ---
>  drivers/usb/dwc3/gadget.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 032ea7d709ba..a5b8387a37ba 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2246,6 +2246,9 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
>  	if (chain && (trb->ctrl & DWC3_TRB_CTRL_HWO))
>  		trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
>  
> +	count = trb->size & DWC3_TRB_SIZE_MASK;
> +	req->remaining += count;
> +
>  	/*
>  	 * If we're dealing with unaligned size OUT transfer, we will be left
>  	 * with one TRB pending in the ring. We need to manually clear HWO bit
> @@ -2256,9 +2259,6 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
>  		return 1;
>  	}
>  
> -	count = trb->size & DWC3_TRB_SIZE_MASK;
> -	req->remaining += count;
> -

this shouldn't be necessary, actually. The remaining TRB which was added
to fix alignment issues, is simply because DWC3 doesn't like OUT
transfers whose size are not aligned to wMaxPacketSize. We *know* we
have e.g. 511 bytes to receive from host, but dwc3 wants me to write
1024 bytes on the TRB (for superspeed), so I need to add this chained
TRB for the remaining 513 bytes.

I don't expect host to send us more than 511 bytes, if it does, the host
is faulty and I don't want to operate on those bytes anyway.

-- 
balbi

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux