From 42a90ced1264c72fc3dfe04cdcaad0bd9eb06484 Mon Sep 17 00:00:00 2001 From: Pratham Pratap Date: Thu, 31 Dec 2020 19:36:18 +0530 Subject: [PATCH] usb: dwc3: Issue ENDTRANSFER cmd on ep0 unconditionally Consider a case where ep0 is not in setup stage and composition switch happens. Currently DWC3_DEPCMD_ENDTRANSFER command is not issued on ep0 which means that the transfers are not flushed out and driver clears the run/stop bit hence stopping the controller. Now as soon as driver sets the run/stop bit controller tries to access the trb from the previous session which is already unmapped resulting in SMMU fault. Fix this by unconditionally issuing DWC3_DEPCMD_ENDTRANSFER command on ep0. Although it is not specified in the data book but if we know for sure that we are anyway going to stop the controller then we can issue ENDTRANSFER command on ep0. Change-Id: Ic6ee570acc8926897d3b6042181a501a47438d92 Signed-off-by: Pratham Pratap --- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 3b7bc0501c4f..de7bdc7a9448 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -799,7 +799,7 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) struct dwc3_request *req; int ret = -EINVAL; - if (dep->number == 0 && dwc->ep0state != EP0_SETUP_PHASE) { + if (dep->number == 0) { unsigned int dir; dbg_log_string("CTRLPEND", dwc->ep0state);