From 92f0211c73dbde4f2d3b5437d1eadfbf273e6764 Mon Sep 17 00:00:00 2001 From: Sriharsha Allenki Date: Tue, 3 Mar 2020 14:14:01 +0530 Subject: [PATCH] usb: dwc3: gadget: Let GSI ep ops allocate TRBs for GSI eps The TRBs for GSI endpoints are allocated by the GSI ep ops. The TRB pool allocated in the alloc_trb_pool is never used and never freed leading to a dangling mapping in the IOMMU. Fix this by freeing up the allocated TRB pool as part of endpoint initialization. Change-Id: Ia0f7b8725f5206c3c52db8017770b855361b0751 Signed-off-by: Sriharsha Allenki --- drivers/usb/dwc3/gadget.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 37ad064b178c..20340ab2363a 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2623,7 +2623,6 @@ static const struct usb_gadget_ops dwc3_gadget_ops = { #define NUM_GSI_OUT_EPS 1 #define NUM_GSI_IN_EPS 2 - static int dwc3_gadget_init_control_endpoint(struct dwc3_ep *dep) { struct dwc3 *dwc = dep->dwc; @@ -2727,12 +2726,16 @@ static int dwc3_gadget_init_endpoints(struct dwc3 *dwc, u8 total) /* Reserve EPs at the end for GSI */ if (!dep->direction && num > out_count - NUM_GSI_OUT_EPS - 1) { + /* Allocation of TRBs are handled by GSI EP ops. */ + dwc3_free_trb_pool(dep); idx = num - (out_count - NUM_GSI_OUT_EPS - 1); snprintf(dep->name, sizeof(dep->name), "gsi-epout%d", idx); dep->gsi = true; } else if (dep->direction && num > in_count - NUM_GSI_IN_EPS - 1) { + /* Allocation of TRBs are handled by GSI EP ops. */ + dwc3_free_trb_pool(dep); idx = num - (in_count - NUM_GSI_IN_EPS - 1); snprintf(dep->name, sizeof(dep->name), "gsi-epin%d", idx);