usb: dwc3: Stop active transfer on control endpoints

If cable disconnects before data stage completion dwc3_remove_requests()
gets called for ep0 in and out but dwc3_ep0_complete_data() does not
get called. dwc3_ep0_complete_data() function resets TRB enqueue count
to 0. As a result upon next cable connect start transfer is called with
wrong TRB address because trb_enqueue is set to 1. Since this TRB was
completed in the past, HWO bit is cleared for this TRB. This results into
usb enumeration failure due to control transfer stall. Fix this issue
by issuing end transfer command on control endpoints after ep0 requests
are removed for IN and OUT and reset trb_enqueue counters to 0.

Change-Id: Ic5364f11372d85ec7c133024dc48bbc5d848ebf4
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
Hemant Kumar 2019-06-20 18:14:54 -07:00 • committed by Jack Pham
commit e189769e47

View file

@ -821,6 +821,22 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)
dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
}
if (dep->number == 1 && dwc->ep0state != EP0_SETUP_PHASE) {
unsigned int dir;
dbg_log_string("CTRLPEND", dwc->ep0state);
dir = !!dwc->ep0_expect_in;
if (dwc->ep0state == EP0_DATA_PHASE)
dwc3_ep0_end_control_data(dwc, dwc->eps[dir]);
else
dwc3_ep0_end_control_data(dwc, dwc->eps[!dir]);
dwc->eps[0]->trb_enqueue = 0;
dwc->eps[1]->trb_enqueue = 0;
}
dbg_log_string("DONE for %s(%d)", dep->name, dep->number);
}
/**