]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / XhciDxe / Xhci.c
index e3cbdbc800387670d060ada28fe2f0b755c876b4..48eccf770a35f9be5092faf11f3a2968a04230ae 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The XHCI controller driver.\r
 \r
-Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -159,7 +159,7 @@ XhcReset (
   EFI_TPL            OldTpl;\r
 \r
   Xhc = XHC_FROM_THIS (This);\r
-  \r
+\r
   if (Xhc->DevicePath != NULL) {\r
     //\r
     // Report Status Code to indicate reset happens\r
@@ -169,7 +169,7 @@ XhcReset (
       (EFI_IO_BUS_USB | EFI_IOB_PC_RESET),\r
       Xhc->DevicePath\r
       );\r
-  }  \r
+  }\r
 \r
   OldTpl = gBS->RaiseTPL (XHC_TPL);\r
 \r
@@ -780,26 +780,32 @@ XhcTransfer (
 \r
   Status = XhcExecTransfer (Xhc, FALSE, Urb, Timeout);\r
 \r
-  *TransferResult = Urb->Result;\r
-  *DataLength     = Urb->Completed;\r
-\r
   if (Status == EFI_TIMEOUT) {\r
     //\r
     // The transfer timed out. Abort the transfer by dequeueing of the TD.\r
     //\r
-    RecoveryStatus = XhcDequeueTrbFromEndpoint (Xhc, Urb);\r
-    if (EFI_ERROR (RecoveryStatus)) {\r
-      DEBUG((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcDequeueTrbFromEndpoint failed\n", Type));\r
-    }\r
-  } else {\r
-    if (*TransferResult == EFI_USB_NOERROR) {\r
+    RecoveryStatus = XhcDequeueTrbFromEndpoint(Xhc, Urb);\r
+    if (RecoveryStatus == EFI_ALREADY_STARTED) {\r
+      //\r
+      // The URB is finished just before stopping endpoint.\r
+      // Change returning status from EFI_TIMEOUT to EFI_SUCCESS.\r
+      //\r
+      ASSERT (Urb->Result == EFI_USB_NOERROR);\r
       Status = EFI_SUCCESS;\r
-    } else if (*TransferResult == EFI_USB_ERR_STALL) {\r
-      RecoveryStatus = XhcRecoverHaltedEndpoint (Xhc, Urb);\r
-      if (EFI_ERROR (RecoveryStatus)) {\r
-        DEBUG ((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcRecoverHaltedEndpoint failed\n", Type));\r
-      }\r
-      Status = EFI_DEVICE_ERROR;\r
+      DEBUG ((DEBUG_ERROR, "XhcTransfer[Type=%d]: pending URB is finished, Length = %d.\n", Type, Urb->Completed));\r
+    } else if (EFI_ERROR(RecoveryStatus)) {\r
+      DEBUG((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcDequeueTrbFromEndpoint failed!\n", Type));\r
+    }\r
+  }\r
+\r
+  *TransferResult = Urb->Result;\r
+  *DataLength     = Urb->Completed;\r
+\r
+  if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE)) {\r
+    ASSERT (Status == EFI_DEVICE_ERROR);\r
+    RecoveryStatus = XhcRecoverHaltedEndpoint(Xhc, Urb);\r
+    if (EFI_ERROR (RecoveryStatus)) {\r
+      DEBUG ((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcRecoverHaltedEndpoint failed!\n", Type));\r
     }\r
   }\r
 \r
@@ -989,7 +995,7 @@ XhcControlTransfer (
   // Hook Set_Config request from UsbBus as we need configure device endpoint.\r
   //\r
   if ((Request->Request     == USB_REQ_GET_DESCRIPTOR) &&\r
-      ((Request->RequestType == USB_REQUEST_TYPE (EfiUsbDataIn, USB_REQ_TYPE_STANDARD, USB_TARGET_DEVICE)) || \r
+      ((Request->RequestType == USB_REQUEST_TYPE (EfiUsbDataIn, USB_REQ_TYPE_STANDARD, USB_TARGET_DEVICE)) ||\r
       ((Request->RequestType == USB_REQUEST_TYPE (EfiUsbDataIn, USB_REQ_TYPE_CLASS, USB_TARGET_DEVICE))))) {\r
     DescriptorType = (UINT8)(Request->Value >> 8);\r
     if ((DescriptorType == USB_DESC_TYPE_DEVICE) && ((*DataLength == sizeof (EFI_USB_DEVICE_DESCRIPTOR)) || ((DeviceSpeed == EFI_USB_SPEED_FULL) && (*DataLength == 8)))) {\r
@@ -1138,7 +1144,7 @@ XhcControlTransfer (
         ClearPortRequest.Length       = 0;\r
 \r
         XhcControlTransfer (\r
-          This, \r
+          This,\r
           DeviceAddress,\r
           DeviceSpeed,\r
           MaximumPacketLength,\r