MdeModulePkg/Xhci: Remove TDs from transfer ring when timeout happens

The error handling for timeout case is enhanced to remove TDs from
transfer ring. The original code only removed s/w URB, but the h/w
transfer descriptor TDs didn't get removed. It would cause data lost
for data stream peripheral, such as usb-to-serial device, from the
s/w perspective.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Baraneedharan Anbazhagan <anbazhagan@hp.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18313 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Feng Tian
2015-08-26 01:19:09 +00:00
committed by erictian
parent 3b657538dc
commit 12e6c7381d
6 changed files with 618 additions and 97 deletions

View File

@@ -1,7 +1,7 @@
/** @file
Private Header file for Usb Host Controller PEIM
Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -938,6 +938,66 @@ XhcPeiSetConfigCmd64 (
IN USB_CONFIG_DESCRIPTOR *ConfigDesc
);
/**
Stop endpoint through XHCI's Stop_Endpoint cmd.
@param Xhc The XHCI device.
@param SlotId The slot id of the target device.
@param Dci The device context index of the target slot or endpoint.
@retval EFI_SUCCESS Stop endpoint successfully.
@retval Others Failed to stop endpoint.
**/
EFI_STATUS
EFIAPI
XhcPeiStopEndpoint (
IN PEI_XHC_DEV *Xhc,
IN UINT8 SlotId,
IN UINT8 Dci
);
/**
Reset endpoint through XHCI's Reset_Endpoint cmd.
@param Xhc The XHCI device.
@param SlotId The slot id of the target device.
@param Dci The device context index of the target slot or endpoint.
@retval EFI_SUCCESS Reset endpoint successfully.
@retval Others Failed to reset endpoint.
**/
EFI_STATUS
EFIAPI
XhcPeiResetEndpoint (
IN PEI_XHC_DEV *Xhc,
IN UINT8 SlotId,
IN UINT8 Dci
);
/**
Set transfer ring dequeue pointer through XHCI's Set_Tr_Dequeue_Pointer cmd.
@param Xhc The XHCI device.
@param SlotId The slot id of the target device.
@param Dci The device context index of the target slot or endpoint.
@param Urb The dequeue pointer of the transfer ring specified
by the urb to be updated.
@retval EFI_SUCCESS Set transfer ring dequeue pointer succeeds.
@retval Others Failed to set transfer ring dequeue pointer.
**/
EFI_STATUS
EFIAPI
XhcPeiSetTrDequeuePointer (
IN PEI_XHC_DEV *Xhc,
IN UINT8 SlotId,
IN UINT8 Dci,
IN URB *Urb
);
/**
Assign and initialize the device slot for a new device.
@@ -1066,6 +1126,25 @@ XhcPeiRecoverHaltedEndpoint (
IN URB *Urb
);
/**
System software shall use a Stop Endpoint Command (section 4.6.9) and the Set TR Dequeue Pointer
Command (section 4.6.10) to remove the timed-out TDs from the xHC transfer ring. The next write to
the Doorbell of the Endpoint will transition the Endpoint Context from the Stopped to the Running
state.
@param Xhc The XHCI device.
@param Urb The urb which doesn't get completed in a specified timeout range.
@retval EFI_SUCCESS The dequeuing of the TDs is successful.
@retval Others Failed to stop the endpoint and dequeue the TDs.
**/
EFI_STATUS
XhcPeiDequeueTrbFromEndpoint (
IN PEI_XHC_DEV *Xhc,
IN URB *Urb
);
/**
Create a new URB for a new transaction.