From 05c86e9eefd671afcb022c47a3309fc7c22dd634 Mon Sep 17 00:00:00 2001 From: Ren Jianing Date: Tue, 11 Aug 2020 18:25:23 +0800 Subject: [PATCH] usb: dwc3: gadget: fix bug of clac_trbs_left at isoc in transfer This patch clear the HWO bit in trb_ctrl by software when requests are moved to queued list. There are some cases which can lead to missed isoc event in dwc3 endpoint interrupt. For example, in uac+uvc mode, if PC start to playpack audio or open uvc preview while captureing audio, a lot of control transfer will bring missed isoc event and we will unmap all request in started list and move them to queued list. Without this patch, the number of trbs left will be incorrectle calculated as 0 and no trbs will be prepared at next transfer. Signed-off-by: Ren Jianing Change-Id: Idca5cd10f291962a480fc7e01e2186beaae2efb9 --- drivers/usb/dwc3/gadget.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 9ca5ac361175..540ea35fd239 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h @@ -74,7 +74,14 @@ static inline struct dwc3_request *next_request(struct list_head *list) static inline void dwc3_gadget_move_queued_request(struct dwc3_request *req) { struct dwc3_ep *dep = req->dep; + struct dwc3_trb *trb; + u8 tmp = dep->trb_enqueue; + if (!tmp) + tmp = DWC3_TRB_NUM - 1; + + trb = &dep->trb_pool[tmp - 1]; + trb->ctrl &= ~DWC3_TRB_CTRL_HWO; req->status = DWC3_REQUEST_STATUS_QUEUED; list_move_tail(&req->list, &dep->pending_list); }