usb: gadget: Restart USB session if start xfer fails for ep0

Currently driver is just proceding further if start xfer times
out for ep0. Start xfer failing for ep0 indicates that the
controller is already in bad state and it can access unmapped
address leading to SMMU fault. Prevent this by marking this as
an error event and restart USB session.

Change-Id: Ia46387e16a79318ad945079ced7209a8f2bf47ef
Signed-off-by: Pratham Pratap <prathampratap@codeaurora.org>
This commit is contained in:
Pratham Pratap 2021-06-30 21:50:48 +05:30 • committed by Gerrit - the friendly Code Review server
commit f2f05457ef

View file

@ -78,8 +78,20 @@ static int dwc3_ep0_start_trans(struct dwc3_ep *dep)
params.param1 = lower_32_bits(dwc->ep0_trb_addr);
ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_STARTTRANSFER, &params);
if (ret < 0)
if (ret < 0) {
if (ret == -ETIMEDOUT) {
/*
* If start transfer is timing out then mark it as an error
* event since the controller is already in an unknown
* state.
*/
dbg_log_string("%s: error event seen\n", __func__);
dwc->err_evt_seen = true;
dwc3_notify_event(dwc, DWC3_CONTROLLER_ERROR_EVENT, 0);
dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_CLEAR_DB, 0);
}
return ret;
}
dwc->ep0_next_event = DWC3_EP0_COMPLETE;