usb: dwc2: gadget: handle reset interrupt before endpoint interrupts
authorMian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tue, 29 Sep 2015 10:08:29 +0000 (12:08 +0200)
committerFelipe Balbi <balbi@ti.com>
Thu, 1 Oct 2015 17:40:27 +0000 (12:40 -0500)
If system is loaded, reset, enum-done and setup interrupts can occur
at the same time. Current interrupt handling sequence will handle
setup packet's interrupt before handling reset interrupt. Which will
break the enumeration process. Correct sequence is to handle reset,
enum-done and then any other endpoint interrupts.

Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc2/gadget.c

index ef964814b9286187067d02a49b8700e331ee0f28..bdda32cefedadc3d60390ac4c4a6d7df8c544375 100644 (file)
@@ -2460,6 +2460,36 @@ irq_retry:
 
        gintsts &= gintmsk;
 
+       if (gintsts & GINTSTS_RESETDET) {
+               dev_dbg(hsotg->dev, "%s: USBRstDet\n", __func__);
+
+               dwc2_writel(GINTSTS_RESETDET, hsotg->regs + GINTSTS);
+
+               /* This event must be used only if controller is suspended */
+               if (hsotg->lx_state == DWC2_L2) {
+                       dwc2_exit_hibernation(hsotg, true);
+                       hsotg->lx_state = DWC2_L0;
+               }
+       }
+
+       if (gintsts & (GINTSTS_USBRST | GINTSTS_RESETDET)) {
+
+               u32 usb_status = dwc2_readl(hsotg->regs + GOTGCTL);
+               u32 connected = hsotg->connected;
+
+               dev_dbg(hsotg->dev, "%s: USBRst\n", __func__);
+               dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
+                       dwc2_readl(hsotg->regs + GNPTXSTS));
+
+               dwc2_writel(GINTSTS_USBRST, hsotg->regs + GINTSTS);
+
+               /* Report disconnection if it is not already done. */
+               dwc2_hsotg_disconnect(hsotg);
+
+               if (usb_status & GOTGCTL_BSESVLD && connected)
+                       dwc2_hsotg_core_init_disconnected(hsotg, true);
+       }
+
        if (gintsts & GINTSTS_ENUMDONE) {
                dwc2_writel(GINTSTS_ENUMDONE, hsotg->regs + GINTSTS);
 
@@ -2491,36 +2521,6 @@ irq_retry:
                }
        }
 
-       if (gintsts & GINTSTS_RESETDET) {
-               dev_dbg(hsotg->dev, "%s: USBRstDet\n", __func__);
-
-               dwc2_writel(GINTSTS_RESETDET, hsotg->regs + GINTSTS);
-
-               /* This event must be used only if controller is suspended */
-               if (hsotg->lx_state == DWC2_L2) {
-                       dwc2_exit_hibernation(hsotg, true);
-                       hsotg->lx_state = DWC2_L0;
-               }
-       }
-
-       if (gintsts & (GINTSTS_USBRST | GINTSTS_RESETDET)) {
-
-               u32 usb_status = dwc2_readl(hsotg->regs + GOTGCTL);
-               u32 connected = hsotg->connected;
-
-               dev_dbg(hsotg->dev, "%s: USBRst\n", __func__);
-               dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
-                       dwc2_readl(hsotg->regs + GNPTXSTS));
-
-               dwc2_writel(GINTSTS_USBRST, hsotg->regs + GINTSTS);
-
-               /* Report disconnection if it is not already done. */
-               dwc2_hsotg_disconnect(hsotg);
-
-               if (usb_status & GOTGCTL_BSESVLD && connected)
-                       dwc2_hsotg_core_init_disconnected(hsotg, true);
-       }
-
        /* check both FIFOs */
 
        if (gintsts & GINTSTS_NPTXFEMP) {
This page took 0.027615 seconds and 5 git commands to generate.