Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
XhciDxe: Workaround for USB Net driver
Browse files Browse the repository at this point in the history
Typically, there are two cases that the BMC device returns NAK
when receiving a BULK IN request
  - Case 1: BMC has no data for the Bulk In request
  - Case 2: BMC is preparing the data for returning to the Host
So, I'm adding a workaround for reducing the number of retries for
checking Bulk In response from BMC device in the case 1 so that
the Host will return Timeout right after receiving a series of 50
sequential NAK responses.

Signed-off-by: Nhi Pham <[email protected]>
  • Loading branch information
nhivp committed Jun 30, 2021
1 parent 4b0c883 commit ac5f121
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,9 +1281,15 @@ XhcBulkTransfer (
);

ON_EXIT:
#if 0
//
// Reduces error messages when there is no data from USB device.
//
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "XhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult));
}
#endif

gBS->RestoreTPL (OldTpl);

return Status;
Expand Down
21 changes: 21 additions & 0 deletions MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,21 @@ XhcExecTransfer (
goto DONE;
}

//
// WORKAROUND - USB Net driver
// Typically, there are two cases that the BMC device returns NAK
// when receiving a BULK IN request
// - Case 1: BMC has no data for the Bulk In request
// - Case 2: BMC is preparing the data for returning to the Host
// So, I'm adding a workaround for reducing the number of retries for
// checking Bulk In response from BMC device in the case 1 so that
// the Host will return Timeout right after receiving a series of 50
// sequential NAK responses.
//
#define MAX_NUMBER_OF_NAK_FOR_A_BULK_IN_REQUEST 50
UINTN Count;
Count = 0;

RINGDOORBELL:
XhcRingDoorBell (Xhc, SlotId, Dci);

Expand All @@ -1331,6 +1346,12 @@ XhcExecTransfer (
break;
}
gBS->Stall (XHC_1_MICROSECOND);
if (++Count > MAX_NUMBER_OF_NAK_FOR_A_BULK_IN_REQUEST
&& Urb->Ep.EpAddr == 1
&& Urb->Ep.Direction == EfiUsbDataIn
&& Urb->Ep.Type == XHC_BULK_TRANSFER) {
break;
}
} while (IndefiniteTimeout || EFI_ERROR(gBS->CheckEvent (TimeoutEvent)));

DONE:
Expand Down

0 comments on commit ac5f121

Please sign in to comment.