All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: gadget: Properly check last unaligned/zero chain TRB
@ 2018-08-03  3:17 ` Thinh Nguyen
  0 siblings, 0 replies; 4+ messages in thread
From: Thinh Nguyen @ 2018-08-03  3:17 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb; +Cc: John Youn, stable

Current check for the last extra TRB for zero and unaligned transfers
does not account for isoc OUT. The last TRB of the Buffer Descriptor for
isoc OUT transfers will be retired with HWO=0. As a result, we won't
return early. The req->remaining will be updated to include the BUFSIZ
count of the extra TRB, and the actual number of transferred bytes
calculation will be wrong.

To fix this, check whether it's a short or zero packet and the last TRB
chain bit to return early.

Cc: stable@vger.kernel.org
Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 032ea7d709ba..c09e4f784810 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2251,7 +2251,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
 	 * with one TRB pending in the ring. We need to manually clear HWO bit
 	 * from that TRB.
 	 */
-	if ((req->zero || req->unaligned) && (trb->ctrl & DWC3_TRB_CTRL_HWO)) {
+	if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
 		trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
 		return 1;
 	}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* usb: dwc3: gadget: Properly check last unaligned/zero chain TRB
@ 2018-08-03  3:17 ` Thinh Nguyen
  0 siblings, 0 replies; 4+ messages in thread
From: Thinh Nguyen @ 2018-08-03  3:17 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb; +Cc: John Youn, stable

Current check for the last extra TRB for zero and unaligned transfers
does not account for isoc OUT. The last TRB of the Buffer Descriptor for
isoc OUT transfers will be retired with HWO=0. As a result, we won't
return early. The req->remaining will be updated to include the BUFSIZ
count of the extra TRB, and the actual number of transferred bytes
calculation will be wrong.

To fix this, check whether it's a short or zero packet and the last TRB
chain bit to return early.

Cc: stable@vger.kernel.org
Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 032ea7d709ba..c09e4f784810 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2251,7 +2251,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
 	 * with one TRB pending in the ring. We need to manually clear HWO bit
 	 * from that TRB.
 	 */
-	if ((req->zero || req->unaligned) && (trb->ctrl & DWC3_TRB_CTRL_HWO)) {
+	if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
 		trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
 		return 1;
 	}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc3: gadget: Properly check last unaligned/zero chain TRB
@ 2018-10-09 18:24   ` Thinh Nguyen
  0 siblings, 0 replies; 4+ messages in thread
From: Thinh Nguyen @ 2018-10-09 18:24 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb; +Cc: John Youn, stable

Hi Felipe,

On 8/2/2018 8:17 PM, Thinh Nguyen wrote:
> Current check for the last extra TRB for zero and unaligned transfers
> does not account for isoc OUT. The last TRB of the Buffer Descriptor for
> isoc OUT transfers will be retired with HWO=0. As a result, we won't
> return early. The req->remaining will be updated to include the BUFSIZ
> count of the extra TRB, and the actual number of transferred bytes
> calculation will be wrong.
>
> To fix this, check whether it's a short or zero packet and the last TRB
> chain bit to return early.
>
> Cc: stable@vger.kernel.org
> Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
> ---
>  drivers/usb/dwc3/gadget.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 032ea7d709ba..c09e4f784810 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2251,7 +2251,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
>  	 * with one TRB pending in the ring. We need to manually clear HWO bit
>  	 * from that TRB.
>  	 */
> -	if ((req->zero || req->unaligned) && (trb->ctrl & DWC3_TRB_CTRL_HWO)) {
> +	if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
>  		trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
>  		return 1;
>  	}

Can you pick up this patch and the patch subject "[PATCH] usb: dwc3:
gadget: fix ISOC TRB type on unaligned transfers" for the next -rc?

Thanks,
Thinh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* usb: dwc3: gadget: Properly check last unaligned/zero chain TRB
@ 2018-10-09 18:24   ` Thinh Nguyen
  0 siblings, 0 replies; 4+ messages in thread
From: Thinh Nguyen @ 2018-10-09 18:24 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb; +Cc: John Youn, stable

Hi Felipe,

On 8/2/2018 8:17 PM, Thinh Nguyen wrote:
> Current check for the last extra TRB for zero and unaligned transfers
> does not account for isoc OUT. The last TRB of the Buffer Descriptor for
> isoc OUT transfers will be retired with HWO=0. As a result, we won't
> return early. The req->remaining will be updated to include the BUFSIZ
> count of the extra TRB, and the actual number of transferred bytes
> calculation will be wrong.
>
> To fix this, check whether it's a short or zero packet and the last TRB
> chain bit to return early.
>
> Cc: stable@vger.kernel.org
> Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
> ---
>  drivers/usb/dwc3/gadget.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 032ea7d709ba..c09e4f784810 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2251,7 +2251,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
>  	 * with one TRB pending in the ring. We need to manually clear HWO bit
>  	 * from that TRB.
>  	 */
> -	if ((req->zero || req->unaligned) && (trb->ctrl & DWC3_TRB_CTRL_HWO)) {
> +	if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
>  		trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
>  		return 1;
>  	}

Can you pick up this patch and the patch subject "[PATCH] usb: dwc3:
gadget: fix ISOC TRB type on unaligned transfers" for the next -rc?

Thanks,
Thinh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-10  1:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-03  3:17 [PATCH] usb: dwc3: gadget: Properly check last unaligned/zero chain TRB Thinh Nguyen
2018-08-03  3:17 ` Thinh Nguyen
2018-10-09 18:24 ` [PATCH] " Thinh Nguyen
2018-10-09 18:24   ` Thinh Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.