USB: Fix usb host hotplug bug.
authorwlf <wulf@rock-chips.com>
Mon, 12 May 2014 09:02:05 +0000 (17:02 +0800)
committerwlf <wulf@rock-chips.com>
Mon, 12 May 2014 09:02:05 +0000 (17:02 +0800)
drivers/usb/dwc_otg_310/dwc_otg_hcd.c
drivers/usb/dwc_otg_310/dwc_otg_hcd_intr.c

index 1ac55659ca4ba9d0fc688e0200ba602d96fca526..42c241440966662e83c445b5bd9b320b1dcf9342 100755 (executable)
@@ -177,7 +177,7 @@ static void kill_urbs_in_qh_list(dwc_otg_hcd_t * hcd, dwc_list_link_t * qh_list)
                        qtd = DWC_CIRCLEQ_FIRST(&qh->qtd_list);
                        if (qtd->urb != NULL) {
                                hcd->fops->complete(hcd, qtd->urb->priv,
-                                                   qtd->urb, -DWC_E_TIMEOUT);
+                                                   qtd->urb, -DWC_E_SHUTDOWN);
                                dwc_otg_hcd_qtd_remove_and_free(hcd, qtd, qh);
                        }
 
@@ -489,7 +489,7 @@ int dwc_otg_hcd_urb_enqueue(dwc_otg_hcd_t * hcd,
 
        if (!hcd->flags.b.port_connect_status) {
                /* No longer connected. */
-               DWC_ERROR("Not connected\n");
+               DWC_DEBUG("Not connected\n");
                return -DWC_E_NO_DEVICE;
        }
 
index dfec664b39ce073493a5be9bc39ab434e19097fe..de629e0e72d909645a1f5ac79b4753d59ba7fd18 100755 (executable)
@@ -48,6 +48,7 @@
 int32_t dwc_otg_hcd_handle_intr(dwc_otg_hcd_t * dwc_otg_hcd)
 {
        int retval = 0;
+       dwc_irqflags_t flags;
 
        dwc_otg_core_if_t *core_if = dwc_otg_hcd->core_if;
        gintsts_data_t gintsts;
@@ -64,12 +65,12 @@ int32_t dwc_otg_hcd_handle_intr(dwc_otg_hcd_t * dwc_otg_hcd)
        if (core_if->hibernation_suspend == 1) {
                return retval;
        }
-       DWC_SPINLOCK(dwc_otg_hcd->lock);
+       DWC_SPINLOCK_IRQSAVE(dwc_otg_hcd->lock, &flags);
        /* Check if HOST Mode */
        if (dwc_otg_is_host_mode(core_if)) {
                gintsts.d32 = dwc_otg_read_core_intr(core_if);
                if (!gintsts.d32) {
-                       DWC_SPINUNLOCK(dwc_otg_hcd->lock);
+                       DWC_SPINUNLOCK_IRQRESTORE(dwc_otg_hcd->lock, flags);
                        return 0;
                }
 #ifdef DEBUG
@@ -138,7 +139,7 @@ int32_t dwc_otg_hcd_handle_intr(dwc_otg_hcd_t * dwc_otg_hcd)
 #endif
 
        }
-       DWC_SPINUNLOCK(dwc_otg_hcd->lock);
+       DWC_SPINUNLOCK_IRQRESTORE(dwc_otg_hcd->lock, flags);
        return retval;
 }
 
@@ -1822,6 +1823,11 @@ static int32_t handle_hc_datatglerr_intr(dwc_otg_hcd_t * hcd,
 {
        DWC_ERROR("--Host Channel %d Interrupt: "
                  "Data Toggle Error--\n", hc->hc_num);
+       if (!hcd->flags.b.port_connect_status) {
+               /* No longer connected. */
+               DWC_ERROR("Not connected\n");
+               return 1;
+       }
        if (hc->ep_is_in) {
                qtd->error_count += 3;//Complete the error URB immediately
        } else {