Having problem when xHCI create Setup Stage TRB


wenyi,xie
 

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 Stage.

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


Wu, Hao A
 

Hello,

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: discuss@edk2.groups.io <discuss@edk2.groups.io> On Behalf Of
wenyi,xie via groups.io
Sent: Wednesday, May 26, 2021 2:09 PM
To: discuss@edk2.groups.io
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
Stage.

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




wenyi,xie
 

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.


Thanks
Wenyi

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

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: discuss@edk2.groups.io <discuss@edk2.groups.io> On Behalf Of
wenyi,xie via groups.io
Sent: Wednesday, May 26, 2021 2:09 PM
To: discuss@edk2.groups.io
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
Stage.

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




Wu, Hao A
 

Thanks.
Could you help to submit a BZ bug tracker at: https://bugzilla.tianocore.org/enter_bug.cgi?product=EDK2?
And could you help to propose a fix for this issue?

Best Regards,
Hao Wu

-----Original Message-----
From: xiewenyi (A) <xiewenyi2@...>
Sent: Thursday, May 27, 2021 4:20 PM
To: Wu, Hao A <hao.a.wu@...>; discuss@edk2.groups.io
Subject: Re: [edk2-discuss] 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.


Thanks
Wenyi

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

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: discuss@edk2.groups.io <discuss@edk2.groups.io> On Behalf Of
wenyi,xie via groups.io
Sent: Wednesday, May 26, 2021 2:09 PM
To: discuss@edk2.groups.io
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 Stage.

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




wenyi,xie
 

OK, I will submit a BZ bug and patch soon.

Thanks
Wenyi

On 2021/5/27 16:26, Wu, Hao A wrote:
Thanks.
Could you help to submit a BZ bug tracker at: https://bugzilla.tianocore.org/enter_bug.cgi?product=EDK2?
And could you help to propose a fix for this issue?

Best Regards,
Hao Wu

-----Original Message-----
From: xiewenyi (A) <xiewenyi2@...>
Sent: Thursday, May 27, 2021 4:20 PM
To: Wu, Hao A <hao.a.wu@...>; discuss@edk2.groups.io
Subject: Re: [edk2-discuss] 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.


Thanks
Wenyi

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

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: discuss@edk2.groups.io <discuss@edk2.groups.io> On Behalf Of
wenyi,xie via groups.io
Sent: Wednesday, May 26, 2021 2:09 PM
To: discuss@edk2.groups.io
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 Stage.

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




Wu, Hao A
 

Thanks a lot.

Best Regards,
Hao Wu

-----Original Message-----
From: xiewenyi (A) <xiewenyi2@...>
Sent: Thursday, May 27, 2021 4:32 PM
To: Wu, Hao A <hao.a.wu@...>; discuss@edk2.groups.io
Subject: Re: [edk2-discuss] Having problem when xHCI create Setup Stage
TRB

OK, I will submit a BZ bug and patch soon.

Thanks
Wenyi

On 2021/5/27 16:26, Wu, Hao A wrote:
Thanks.
Could you help to submit a BZ bug tracker at:
https://bugzilla.tianocore.org/enter_bug.cgi?product=EDK2?
And could you help to propose a fix for this issue?

Best Regards,
Hao Wu

-----Original Message-----
From: xiewenyi (A) <xiewenyi2@...>
Sent: Thursday, May 27, 2021 4:20 PM
To: Wu, Hao A <hao.a.wu@...>; discuss@edk2.groups.io
Subject: Re: [edk2-discuss] 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.


Thanks
Wenyi

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

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: discuss@edk2.groups.io <discuss@edk2.groups.io> On Behalf Of
wenyi,xie via groups.io
Sent: Wednesday, May 26, 2021 2:09 PM
To: discuss@edk2.groups.io
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 Stage.

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