MdeModulePkg/XhciDxe: Reset endpoint while USB Transaction error

https://bugzilla.tianocore.org/show_bug.cgi?id=4556

Based on XHCI spec 4.8.3, software should do the
reset endpoint while USB Transaction occur.
Add the error code for USB Transaction error
since UEFI spec don't have the related definition.

Cc: Ray Ni                  <ray.ni@intel.com>
Cc: Liming Gao              <gaoliming@byosoft.com.cn>
Cc: Krzysztof Lewandowski   <krzysztof.lewandowski@intel.com>
Cc: Jenny Huang             <jenny.huang@intel.com>
Cc: More Shih               <more.shih@intel.com>
Signed-off-by: Xianglei Cai <xianglei.cai@intel.com>
Reviewed-by: Krzysztof Lewandowski <krzysztof.lewandowski@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Xianglei Cai 2024-05-07 09:19:32 +08:00 committed by mergify[bot]
parent 17f333f2a4
commit c12bbc1490
3 changed files with 15 additions and 2 deletions

View File

@ -825,7 +825,10 @@ XhcTransfer (
*TransferResult = Urb->Result; *TransferResult = Urb->Result;
*DataLength = Urb->Completed; *DataLength = Urb->Completed;
if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE)) { //
// Based on XHCI spec 4.8.3, software should do the reset endpoint while USB Transaction occur.
//
if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE) || (*TransferResult == EDKII_USB_ERR_TRANSACTION)) {
ASSERT (Status == EFI_DEVICE_ERROR); ASSERT (Status == EFI_DEVICE_ERROR);
RecoveryStatus = XhcRecoverHaltedEndpoint (Xhc, Urb); RecoveryStatus = XhcRecoverHaltedEndpoint (Xhc, Urb);
if (EFI_ERROR (RecoveryStatus)) { if (EFI_ERROR (RecoveryStatus)) {

View File

@ -1192,8 +1192,11 @@ XhcCheckUrbResult (
DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: ERR_BUFFER! Completecode = %x\n", EvtTrb->Completecode)); DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: ERR_BUFFER! Completecode = %x\n", EvtTrb->Completecode));
goto EXIT; goto EXIT;
//
// Based on XHCI spec 4.8.3, software should do the reset endpoint while USB Transaction occur.
//
case TRB_COMPLETION_USB_TRANSACTION_ERROR: case TRB_COMPLETION_USB_TRANSACTION_ERROR:
CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT; CheckedUrb->Result |= EDKII_USB_ERR_TRANSACTION;
CheckedUrb->Finished = TRUE; CheckedUrb->Finished = TRUE;
DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = %x\n", EvtTrb->Completecode)); DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = %x\n", EvtTrb->Completecode));
goto EXIT; goto EXIT;

View File

@ -78,6 +78,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define TRB_COMPLETION_STOPPED 26 #define TRB_COMPLETION_STOPPED 26
#define TRB_COMPLETION_STOPPED_LENGTH_INVALID 27 #define TRB_COMPLETION_STOPPED_LENGTH_INVALID 27
//
// USB Transfer Results Internal Definition
// Based on XHCI spec 4.8.3, software should do the reset endpoint while USB Transaction occur.
// Add the error code for USB Transaction error since UEFI spec don't have the related definition.
//
#define EDKII_USB_ERR_TRANSACTION 0x200
// //
// The topology string used to present usb device location // The topology string used to present usb device location
// //