Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43874173 authored by Hemant Kumar's avatar Hemant Kumar Committed by Mayank Rana
Browse files

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: default avatarHemant Kumar <hemantk@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent e1f1af43
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -1061,6 +1061,7 @@ struct dwc3 {


	/* IRQ timing statistics */
	/* IRQ timing statistics */
	int			irq;
	int			irq;
	unsigned long		ep_cmd_timeout_cnt;
	unsigned long		irq_cnt;
	unsigned long		irq_cnt;
	unsigned int		bh_completion_time[MAX_INTR_STATS];
	unsigned int		bh_completion_time[MAX_INTR_STATS];
	unsigned int		bh_handled_evt_cnt[MAX_INTR_STATS];
	unsigned int		bh_handled_evt_cnt[MAX_INTR_STATS];
+1 −1
Original line number Original line Diff line number Diff line
@@ -1694,7 +1694,7 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event)
		break;
		break;
	case DWC3_CONTROLLER_RESTART_USB_SESSION:
	case DWC3_CONTROLLER_RESTART_USB_SESSION:
		dev_dbg(mdwc->dev, "DWC3_CONTROLLER_RESTART_USB_SESSION received\n");
		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;
		break;
	default:
	default:
		dev_dbg(mdwc->dev, "unknown dwc3 event\n");
		dev_dbg(mdwc->dev, "unknown dwc3 event\n");
+6 −1
Original line number Original line Diff line number Diff line
@@ -238,7 +238,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
		struct dwc3_gadget_ep_cmd_params *params)
		struct dwc3_gadget_ep_cmd_params *params)
{
{
	struct dwc3		*dwc = dep->dwc;
	struct dwc3		*dwc = dep->dwc;
	u32			timeout = 1500;
	u32			timeout = 3000;
	u32			reg;
	u32			reg;


	int			cmd_status = 0;
	int			cmd_status = 0;
@@ -320,6 +320,11 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
		dwc3_trace(trace_dwc3_gadget, "Command Timed Out");
		dwc3_trace(trace_dwc3_gadget, "Command Timed Out");
		dev_err(dwc->dev, "%s command timeout for %s\n",
		dev_err(dwc->dev, "%s command timeout for %s\n",
			dwc3_gadget_ep_cmd_string(cmd), dep->name);
			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);
		}
		cmd_status = -ETIMEDOUT;
		cmd_status = -ETIMEDOUT;
	}
	}