summaryrefslogtreecommitdiff
path: root/drivers/usb/dwc3
diff options
context:
space:
mode:
authorHemant Kumar <hemantk@codeaurora.org>2016-08-25 16:17:48 -0700
committerHemant Kumar <hemantk@codeaurora.org>2016-08-26 18:44:04 -0700
commita1efcad026c693225305e7bf778f6bfb458c119c (patch)
treee0f10a3d4e5574f31974c2f9f41261483c139853 /drivers/usb/dwc3
parente97b6a0e0217f7c072fdad6c50673cd7a64348e1 (diff)
usb: dwc3: restart usb upon endpoint cmd timeout
Sometime endpoint command timeout happening after usb device enumeration. Controller stops responding to any endpoint commands afterwards. To recover from this condition restart usb by simulating vbus off and on except for end transfer command. Also increase the command timeout from 1500us to 3000us. Change-Id: I7c1833d844fd432b33158686361e24e66a2fd92c Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r--drivers/usb/dwc3/core.h1
-rw-r--r--drivers/usb/dwc3/dwc3-msm.c2
-rw-r--r--drivers/usb/dwc3/gadget.c7
3 files changed, 8 insertions, 2 deletions
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 2c26ae1e3eb7..1fb5ce9caf98 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1006,6 +1006,7 @@ struct dwc3 {
/* IRQ timing statistics */
int irq;
unsigned long irq_cnt;
+ unsigned long ep_cmd_timeout_cnt;
unsigned bh_completion_time[MAX_INTR_STATS];
unsigned bh_handled_evt_cnt[MAX_INTR_STATS];
unsigned bh_dbg_index;
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index 37a3c954a1dd..8189096f95c2 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -1694,7 +1694,7 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned event)
break;
case DWC3_CONTROLLER_RESTART_USB_SESSION:
dev_dbg(mdwc->dev, "DWC3_CONTROLLER_RESTART_USB_SESSION received\n");
- dwc3_restart_usb_work(&mdwc->restart_usb_work);
+ schedule_work(&mdwc->restart_usb_work);
break;
default:
dev_dbg(mdwc->dev, "unknown dwc3 event\n");
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index acaa99615d33..d90df256796c 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -340,7 +340,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
unsigned cmd, struct dwc3_gadget_ep_cmd_params *params)
{
struct dwc3_ep *dep = dwc->eps[ep];
- u32 timeout = 1500;
+ u32 timeout = 3000;
u32 reg;
trace_dwc3_gadget_ep_cmd(dep, cmd, params);
@@ -380,6 +380,11 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
"Command Timed Out");
dev_err(dwc->dev, "%s command timeout for %s\n",
dwc3_gadget_ep_cmd_string(cmd), dep->name);
+ if (!(cmd & DWC3_DEPCMD_ENDTRANSFER)) {
+ dwc->ep_cmd_timeout_cnt++;
+ dwc3_notify_event(dwc,
+ DWC3_CONTROLLER_RESTART_USB_SESSION);
+ }
return -ETIMEDOUT;
}