X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FPci%2FXhciDxe%2FXhci.c;h=20ad3f1611979ff187abb7fb47c0ed800be32fa8;hp=e3cbdbc800387670d060ada28fe2f0b755c876b4;hb=49be9c3c20cea7477b9c9e390c9f97735760e216;hpb=41fb8ce93930c33931a54550b12e1247fb86c805 diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c index e3cbdbc800..20ad3f1611 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c @@ -780,26 +780,32 @@ XhcTransfer ( Status = XhcExecTransfer (Xhc, FALSE, Urb, Timeout); - *TransferResult = Urb->Result; - *DataLength = Urb->Completed; - if (Status == EFI_TIMEOUT) { // // The transfer timed out. Abort the transfer by dequeueing of the TD. // - RecoveryStatus = XhcDequeueTrbFromEndpoint (Xhc, Urb); - if (EFI_ERROR (RecoveryStatus)) { - DEBUG((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcDequeueTrbFromEndpoint failed\n", Type)); - } - } else { - if (*TransferResult == EFI_USB_NOERROR) { + RecoveryStatus = XhcDequeueTrbFromEndpoint(Xhc, Urb); + if (RecoveryStatus == EFI_ALREADY_STARTED) { + // + // The URB is finished just before stopping endpoint. + // Change returning status from EFI_TIMEOUT to EFI_SUCCESS. + // + ASSERT (Urb->Result == EFI_USB_NOERROR); Status = EFI_SUCCESS; - } else if (*TransferResult == EFI_USB_ERR_STALL) { - RecoveryStatus = XhcRecoverHaltedEndpoint (Xhc, Urb); - if (EFI_ERROR (RecoveryStatus)) { - DEBUG ((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcRecoverHaltedEndpoint failed\n", Type)); - } - Status = EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "XhcTransfer[Type=%d]: pending URB is finished, Length = %d.\n", Type, Urb->Completed)); + } else if (EFI_ERROR(RecoveryStatus)) { + DEBUG((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcDequeueTrbFromEndpoint failed!\n", Type)); + } + } + + *TransferResult = Urb->Result; + *DataLength = Urb->Completed; + + if (*TransferResult == EFI_USB_ERR_STALL) { + ASSERT (Status == EFI_DEVICE_ERROR); + RecoveryStatus = XhcRecoverHaltedEndpoint(Xhc, Urb); + if (EFI_ERROR (RecoveryStatus)) { + DEBUG ((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcRecoverHaltedEndpoint failed!\n", Type)); } }