From 3d67a3dabee93666eabc8e4a53d854f33f1f43fe Mon Sep 17 00:00:00 2001 From: Mayank Rana Date: Fri, 13 Mar 2020 16:18:42 -0700 Subject: [PATCH] dwc3-msm: Increment req->num_trbs on queueing TRB BAM endpoint TRB ring has usage of 2 TRBs (normal and LINK), and completion API (dwc3_msm_req_complete_func()) currently only increments dequeue pointer by 1 assuming that dwc3_gadget_giveback() does increment dequeue pointer for normal TRB. With newer changes in dwc3 gadget framework, it moves requests to cancelled list with usb_ep_dequeue() and reclaim those TRBs on end transfer command completion. Reclaiming TRB back to trb pool is done only when req->num_trbs is non zero. dwc3_msm_ep_queue() API checks for enqueue and dequeue pointers, and on mismatch of it error out. This results into no BAM2BAM communication after trying to use USB as sink with QDSS usecase. Fix this issue by incrementing req->num_trbs with dwc3_msm_ep_queue() API for normal TRB so dequeue pointer is incremented with dwc3_gadget_ep_cleanup_cancelled_requests() API. Change-Id: I0777aea7c6add7fb6fea7ea74056786e33435427 Signed-off-by: Mayank Rana --- drivers/usb/dwc3/dwc3-msm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index 5d92dd42fc3e..f23c30fdd4f0 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -947,6 +947,7 @@ static int __dwc3_msm_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) memset(trb, 0, sizeof(*trb)); req->trb = trb; + req->num_trbs++; trb->bph = DBM_TRB_BIT | DBM_TRB_DMA | DBM_TRB_EP_NUM(dep->number); trb->size = DWC3_TRB_SIZE_LENGTH(req->request.length); trb->ctrl = DWC3_TRBCTL_NORMAL | DWC3_TRB_CTRL_HWO |