From e24e42fa12645523238e178220fdf64c5d460f2f Mon Sep 17 00:00:00 2001 From: Sriharsha Allenki Date: Thu, 28 Nov 2019 15:05:36 +0530 Subject: [PATCH] usb: dwc3: Do not process request if HWO is set for its TRB If the HWO bit is set for the TRB (or the first TRB if scatter-gather is used) of a request, it implies that core is still processing it. In that case do not reclaim that TRB and also do not process the request and give it back to the function driver. Change-Id: Ia9fbaee443ad53d9a52909b0906a1d0ec1f2638a Signed-off-by: Sriharsha Allenki --- drivers/usb/dwc3/gadget.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index a412277d1818..1c9bbdee3c89 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2830,8 +2830,19 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, const struct dwc3_event_depevt *event, struct dwc3_request *req, int status) { + struct dwc3 *dwc = dep->dwc; int ret; + /* + * If the HWO is set, it implies the TRB is still being + * processed by the core. Hence do not reclaim it until + * it is processed by the core. + */ + if (req->trb->ctrl & DWC3_TRB_CTRL_HWO) { + dbg_event(0xFF, "PEND TRB", dep->number); + return 1; + } + if (req->num_pending_sgs) ret = dwc3_gadget_ep_reclaim_trb_sg(dep, req, event, status);