Looks good to me.

Reviewed-by: Krzysztof Lewandowski <krzysztof.lewandowski@intel.com>

From: Cai, Xianglei <xianglei.cai@intel.com>
Sent: Wednesday, April 10, 2024 09:02
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Cai, Xianglei <xianglei.cai@intel.com>; Ni, Ray <ray.ni@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Lewandowski, Krzysztof <krzysztof.lewandowski@intel.com>; Huang, Jenny <jenny.huang@intel.com>; Shih, More <more.shih@intel.com>
Subject: [PATCH 1/1] 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.
Also 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>
---
 MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c      |  2 +-
 MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c |  2 +-
 MdePkg/Include/Protocol/UsbIo.h          | 21 +++++++++++----------
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
index f4e61d223c1b..63cc29b26536 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -825,7 +825,7 @@ XhcTransfer (
   *TransferResult = Urb->Result;
   *DataLength     = Urb->Completed;
 
-  if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE)) {
+  if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE) || (*TransferResult == EFI_USB_ERR_TRANSACTION)) {
     ASSERT (Status == EFI_DEVICE_ERROR);
     RecoveryStatus = XhcRecoverHaltedEndpoint (Xhc, Urb);
     if (EFI_ERROR (RecoveryStatus)) {
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
index 05528a478baf..e77852f62f10 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
@@ -1193,7 +1193,7 @@ XhcCheckUrbResult (
         goto EXIT;
 
       case TRB_COMPLETION_USB_TRANSACTION_ERROR:
-        CheckedUrb->Result  |= EFI_USB_ERR_TIMEOUT;
+        CheckedUrb->Result  |= EFI_USB_ERR_TRANSACTION;
         CheckedUrb->Finished = TRUE;
         DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = %x\n", EvtTrb->Completecode));
         goto EXIT;
diff --git a/MdePkg/Include/Protocol/UsbIo.h b/MdePkg/Include/Protocol/UsbIo.h
index a780b4e07b44..211ef0c94156 100644
--- a/MdePkg/Include/Protocol/UsbIo.h
+++ b/MdePkg/Include/Protocol/UsbIo.h
@@ -50,16 +50,17 @@ typedef enum {
 //
 // USB Transfer Results
 //
-#define EFI_USB_NOERROR         0x00
-#define EFI_USB_ERR_NOTEXECUTE  0x01
-#define EFI_USB_ERR_STALL       0x02
-#define EFI_USB_ERR_BUFFER      0x04
-#define EFI_USB_ERR_BABBLE      0x08
-#define EFI_USB_ERR_NAK         0x10
-#define EFI_USB_ERR_CRC         0x20
-#define EFI_USB_ERR_TIMEOUT     0x40
-#define EFI_USB_ERR_BITSTUFF    0x80
-#define EFI_USB_ERR_SYSTEM      0x100
+#define EFI_USB_NOERROR          0x00
+#define EFI_USB_ERR_NOTEXECUTE   0x01
+#define EFI_USB_ERR_STALL        0x02
+#define EFI_USB_ERR_BUFFER       0x04
+#define EFI_USB_ERR_BABBLE       0x08
+#define EFI_USB_ERR_NAK          0x10
+#define EFI_USB_ERR_CRC          0x20
+#define EFI_USB_ERR_TIMEOUT      0x40
+#define EFI_USB_ERR_BITSTUFF     0x80
+#define EFI_USB_ERR_SYSTEM       0x100
+#define EFI_USB_ERR_TRANSACTION  0x200
 
 /**
   Async USB transfer callback routine.
--
2.42.0.windows.2


Intel Technology Poland sp. z o.o.
ul. Słowackiego 173 | 80-298 Gdańsk | Sąd Rejonowy Gdańsk Północ | VII Wydział Gospodarczy Krajowego Rejestru Sądowego - KRS 101882 | NIP 957-07-52-316 | Kapitał zakładowy 200.000 PLN.
Spółka oświadcza, że posiada status dużego przedsiębiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdziałaniu nadmiernym opóźnieniom w transakcjach handlowych.

Ta wiadomość wraz z załącznikami jest przeznaczona dla określonego adresata i może zawierać informacje poufne. W razie przypadkowego otrzymania tej wiadomości, prosimy o powiadomienie nadawcy oraz trwałe jej usunięcie; jakiekolwiek przeglądanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.

_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#117635) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_