Re: Having problem when xHCI create Setup Stage TRB


Hi, Wu Hao

As TRT field is not set to EfiUsbNoData when Data Stage does not exist, USB controller
returns trb err and finally lead to usb enumerate fail.


On 2021/5/27 15:24, Wu, Hao A wrote:

Looking into the XHCI spec, I think the current implementation in XhciDxe & XhciPei
does not follow the spec when it comes to the TRT field.

Could you help to provide more information on what error is met?
Thanks in advance.

Best Regards,
Hao Wu

-----Original Message-----
From: <> On Behalf Of
wenyi,xie via
Sent: Wednesday, May 26, 2021 2:09 PM
Subject: [edk2-discuss] Having problem when xHCI create Setup Stage TRB

Hello, everyone,

we meet a problem and are not sure if it's an issue, here's the description.
According usb-xhci specification, at USB packet level, a Control Transfer
consists of multiple transactions partitioned into stages: a setup stage, an
optional data stage, and a terminating status stage.
If Data Stage does not exist, the Transfer Type flag(TRT) should be No Data

But in function XhcCreateUrb() in file XhciSched.c, the Direction is set to
EfiUsbDataIn or EfiUsbDataOut.
Ep->Direction = ((EpAddr & 0x80) != 0) ? EfiUsbDataIn : EfiUsbDataOut;

and then in function XhcCreateTransferTrb(), TRT is set to 3 or 2, it will never
be 0.
if (Urb->Ep.Direction == EfiUsbDataIn) {
TrbStart->TrbCtrSetup.TRT = 3;
} else if (Urb->Ep.Direction == EfiUsbDataOut) {
TrbStart->TrbCtrSetup.TRT = 2;
} else {
TrbStart->TrbCtrSetup.TRT = 0;

TRT Value Definition
0 No Data Stage
1 Reserved
2 OUT Data Stage
3 IN Data Stage

Join to automatically receive all group messages.