From c0c12707894fb8035927d35e04d4ca7e82ec762b Mon Sep 17 00:00:00 2001 From: William Wu Date: Tue, 1 Sep 2020 19:55:23 +0800 Subject: [PATCH] usb: dwc3: gadget: clear HWO when move req to pending list Clear the HWO of TRB belongs to the current req which will be moved to the pending list, rather than clear the HWO of previous TRB in the ring. Fixes: 05c86e9eefd6 ("usb: dwc3: gadget: fix bug of clac_trbs_left at isoc in transfer") Signed-off-by: William Wu Change-Id: If11c296db902631587cf36731242d12ddb5c4c28 --- drivers/usb/dwc3/gadget.c | 2 +- drivers/usb/dwc3/gadget.h | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index ad6358e9556b..1f7be980e44b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2613,12 +2613,12 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, */ req->remaining = 0; req->needs_extra_trb = false; + dwc3_gadget_move_queued_request(req); if (req->trb) usb_gadget_unmap_request_by_dev(dwc->sysdev, &req->request, req->direction); req->trb = NULL; - dwc3_gadget_move_queued_request(req); } else { __dwc3_gadget_kick_transfer(dep); } diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 540ea35fd239..ba495ace7e51 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h @@ -74,14 +74,9 @@ 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; + if (req->trb) + req->trb->ctrl &= ~DWC3_TRB_CTRL_HWO; req->status = DWC3_REQUEST_STATUS_QUEUED; list_move_tail(&req->list, &dep->pending_list); }