/** @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
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
(EFI_IO_BUS_USB | EFI_IOB_PC_RESET),\r
Xhc->DevicePath\r
);\r
- } \r
+ }\r
\r
OldTpl = gBS->RaiseTPL (XHC_TPL);\r
\r
\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
// 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
ClearPortRequest.Length = 0;\r
\r
XhcControlTransfer (\r
- This, \r
+ This,\r
DeviceAddress,\r
DeviceSpeed,\r
MaximumPacketLength,\r