Message ID | dffbaf345bfa98a97556cea41cf3b3997f1d95ac.1533266198.git.thinhn@synopsys.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | usb: dwc3: gadget: Properly check last unaligned/zero chain TRB | expand |
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
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; }
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(-)