public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
@ 2020-07-17  2:49 Feng Libo
  2020-08-06  1:25 ` [edk2-devel] " Feng Libo
  0 siblings, 1 reply; 10+ messages in thread
From: Feng Libo @ 2020-07-17  2:49 UTC (permalink / raw)
  To: devel, czhang; +Cc: Feng Libo

Some USB Pen disk can't be identified during USB enumeration during UEFI
post. We have three USB Pen disks from different manufactors, all with Innostor USB
controller chip (VID=0x1F75, PID=0x917, USB3.1), they all failed in the
second device-descritor requeset. When the first device descriptor
request for the bMaxPacketSize0, only the first 8 byte within the device
descritor is fetched, which could confuse some USB Pen disks in the next
complete device descriptor, then the request of Device descriptor is
failed and USB Pen disk can't be identified. So, we adjust the
enumeration sequences, as below:
1. Port Stabilization Debounce
2. First Port Reset
3. First Device Descriptor Request for bMaxPacketSize0.
4. Second Port Reset. add extra reset
5. Set USB address
6. Second Device Descriptor Request.

whith this adjustment, now Innostor USB Pen disk can work fine in UEFI
posting.

Signed-off-by: Feng Libo <lbfeng@zd-tech.com.cn>
---
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 47 +++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
index d3e0cfa626..eb055771d2 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
@@ -756,6 +756,40 @@ UsbEnumerateNewDev (
            Child->Translator.TranslatorPortNumber));
 
   //
+  // Host sends a Get_Descriptor request to learn the max packet
+  // size of default pipe (only part of the device's descriptor).
+  // Only the first 8 byte of Device Descriptor is requested,
+  // which could make some USB pen disks confused.
+  // therefore, a second port reset follows. 
+  //
+  Status = UsbGetMaxPacketSize0 (Child);
+
+  if (EFI_ERROR (Status)) {
+    DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to get max packet for EP 0 - %r\n", Status));
+    goto ON_ERROR;
+  }
+
+  DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0));
+
+  // 
+  // Some USB Pen disks would become confused by a second request for the Device Descriptor
+  // if they did not return the complete Device Descriptor for the first request.
+  // To allow these devices to enumerate successfully it was necessary to reset the port
+  // between the first and second requests for the device descriptor.
+  //
+  if (ResetIsNeeded) {
+    Status = HubApi->ResetPort (HubIf, Port);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to reset port %d - %r\n", Port, Status));
+
+      return Status;
+    }
+    DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));
+  } else {
+    DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port));
+  }
+
+  //
   // After port is reset, hub establishes a signal path between
   // the device and host (DEFAULT state). Device's registers are
   // reset, use default address 0 (host enumerates one device at
@@ -795,19 +829,6 @@ UsbEnumerateNewDev (
   DEBUG ((EFI_D_INFO, "UsbEnumerateNewDev: device is now ADDRESSED at %d\n", Address));
 
   //
-  // Host sends a Get_Descriptor request to learn the max packet
-  // size of default pipe (only part of the device's descriptor).
-  //
-  Status = UsbGetMaxPacketSize0 (Child);
-
-  if (EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to get max packet for EP 0 - %r\n", Status));
-    goto ON_ERROR;
-  }
-
-  DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0));
-
-  //
   // Host learns about the device's abilities by requesting device's
   // entire descriptions.
   //
-- 
2.13.2.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
  2020-07-17  2:49 [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration Feng Libo
@ 2020-08-06  1:25 ` Feng Libo
  2020-08-06  4:28   ` Guomin Jiang
       [not found]   ` <16289366B25D4B9F.5756@groups.io>
  0 siblings, 2 replies; 10+ messages in thread
From: Feng Libo @ 2020-08-06  1:25 UTC (permalink / raw)
  To: Feng Libo, devel

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

Hello,

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo

[-- Attachment #2: Type: text/html, Size: 702 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
  2020-08-06  1:25 ` [edk2-devel] " Feng Libo
@ 2020-08-06  4:28   ` Guomin Jiang
       [not found]   ` <16289366B25D4B9F.5756@groups.io>
  1 sibling, 0 replies; 10+ messages in thread
From: Guomin Jiang @ 2020-08-06  4:28 UTC (permalink / raw)
  To: devel@edk2.groups.io, lbfeng@zd-tech.com.cn

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

I will review it by next weekend(8/14).

Thanks.
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Feng Libo
Sent: Thursday, August 6, 2020 9:25 AM
To: Feng Libo <lbfeng@zd-tech.com.cn>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello,

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo


[-- Attachment #2: Type: text/html, Size: 3246 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
       [not found]   ` <16289366B25D4B9F.5756@groups.io>
@ 2020-08-11  0:21     ` Guomin Jiang
  2020-08-11  9:50       ` Feng Libo
  0 siblings, 1 reply; 10+ messages in thread
From: Guomin Jiang @ 2020-08-11  0:21 UTC (permalink / raw)
  To: devel@edk2.groups.io, Jiang, Guomin, lbfeng@zd-tech.com.cn
  Cc: jeremy.linton@arm.com

[-- Attachment #1: Type: text/plain, Size: 1363 bytes --]

+Jeremy,

I review the patch and think it is reasonable, but I want to know some more detail information

  1.  Can you provide the detail debug log about USB?
  2.  The symptom always can be seen or have fail rate?

Best Regards
Guomin
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin Jiang
Sent: Thursday, August 6, 2020 12:29 PM
To: devel@edk2.groups.io; lbfeng@zd-tech.com.cn
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

I will review it by next weekend(8/14).

Thanks.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Feng Libo
Sent: Thursday, August 6, 2020 9:25 AM
To: Feng Libo <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello,

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo


[-- Attachment #2: Type: text/html, Size: 6285 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
  2020-08-11  0:21     ` Guomin Jiang
@ 2020-08-11  9:50       ` Feng Libo
  2020-08-11 11:17         ` Guomin Jiang
       [not found]         ` <162A3294EE88D661.26440@groups.io>
  0 siblings, 2 replies; 10+ messages in thread
From: Feng Libo @ 2020-08-11  9:50 UTC (permalink / raw)
  To: Jiang, Guomin; +Cc: devel@edk2.groups.io, jeremy.linton@arm.com

[-- Attachment #1: Type: text/plain, Size: 2963 bytes --]

Hello, Mr. Jiang,


Thank for the review.


The original enumeration steps in the function of UsbEnumerateNewDev of file UsbEnumer.c: 1 reset the port, 2 set the usb device address, 3 get the Max Packet Size, 4 get the full device descriptor. However, when plugging a USB PenDisk with Innostor USB
controller chip (VID=0x1F75, PID=0x917, USB3.1), the fourth step always fails, trace as below:


========
XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = 4 XhcControlTransfer: error - Device Error, transfer - 40 UsbGetOneConfig: failed to get full descript Device Error UsbBuildDescTable: failed to get configure (index 0) UsbEnumerateNewDev: failed to build descriptor table - Device Error
=======


The host controller need to get the full device descriptor, but this moment, the Pendisk device doesn't response any more. Then timeout. and UsbEnumerateNewDev complains : failed to build descriptor.


We have three Pendisks from different manufacturers, all with Innostor USB controller chip. they all can't be enumerated all. And we observed the problem on both Huawei KunPeng(华为鲲鹏)and Loognson(龙芯)platforms.


The three Pendisks always fail the USB enumeration. Other USB 2.0 and USB 3.0 on hand can work well.


With the patch, the three pendisks and other pendisks can all work well.


THanks


--

Best Regards


Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"Jiang, Guomin" <guomin.jiang@intel.com>
发送日期:2020-08-11 08:21:10
收件人:"devel@edk2.groups.io" <devel@edk2.groups.io>,"Jiang, Guomin" <guomin.jiang@intel.com>,"lbfeng@zd-tech.com.cn" <lbfeng@zd-tech.com.cn>
抄送人:"jeremy.linton@arm.com" <jeremy.linton@arm.com>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.


+Jeremy,

 

I review the patch and think it is reasonable, but I want to know some more detail information

Can you provide the detail debug log about USB?
The symptom always can be seen or have fail rate?

 

Best Regards

Guomin

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin Jiang
Sent: Thursday, August 6, 2020 12:29 PM
To: devel@edk2.groups.io; lbfeng@zd-tech.com.cn
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

I will review it by next weekend(8/14).

 

Thanks.

From:devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Feng Libo
Sent: Thursday, August 6, 2020 9:25 AM
To: Feng Libo <lbfeng@zd-tech.com.cn>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

Hello, 

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo


[-- Attachment #2: Type: text/html, Size: 7955 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
  2020-08-11  9:50       ` Feng Libo
@ 2020-08-11 11:17         ` Guomin Jiang
       [not found]         ` <162A3294EE88D661.26440@groups.io>
  1 sibling, 0 replies; 10+ messages in thread
From: Guomin Jiang @ 2020-08-11 11:17 UTC (permalink / raw)
  To: devel@edk2.groups.io, lbfeng@zd-tech.com.cn
  Cc: jeremy.linton@arm.com, Wu, Hao A, Ni, Ray

[-- Attachment #1: Type: text/plain, Size: 4138 bytes --]

+Hao, Ray,

Hi Libo, thanks for your explanation.

So I think the patch is improvement for current logic.

Hi Hao and Ray,

Can you give some comments for the change.

Hi Jeremy,

It may be helpful for the ASSERT issue https://edk2.groups.io/g/devel/message/62651,can you try it?

Best Regards
Guomin
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Feng Libo
Sent: Tuesday, August 11, 2020 5:50 PM
To: Jiang, Guomin <guomin.jiang@intel.com>
Cc: devel@edk2.groups.io; jeremy.linton@arm.com
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello, Mr. Jiang,

Thank for the review.

The original enumeration steps in the function of UsbEnumerateNewDev of file UsbEnumer.c: 1 reset the port, 2 set the usb device address, 3 get the Max Packet Size, 4 get the full device descriptor. However, when plugging a USB PenDisk with Innostor USB
controller chip (VID=0x1F75, PID=0x917, USB3.1), the fourth step always fails, trace as below:

========
XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = 4 XhcControlTransfer: error - Device Error, transfer - 40 UsbGetOneConfig: failed to get full descript Device Error UsbBuildDescTable: failed to get configure (index 0) UsbEnumerateNewDev: failed to build descriptor table - Device Error
=======

The host controller need to get the full device descriptor, but this moment, the Pendisk device doesn't response any more. Then timeout. and UsbEnumerateNewDev complains : failed to build descriptor.

We have three Pendisks from different manufacturers, all with Innostor USB controller chip. they all can't be enumerated all. And we observed the problem on both Huawei KunPeng(华为鲲鹏)and Loognson(龙芯)platforms.

The three Pendisks always fail the USB enumeration. Other USB 2.0 and USB 3.0 on hand can work well.

With the patch, the three pendisks and other pendisks can all work well.

THanks

--
Best Regards

Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>
发送日期:2020-08-11 08:21:10
收件人:"devel@edk2.groups.io<mailto:devel@edk2.groups.io>" <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>,"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>,"lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>" <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>
抄送人:"jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>" <jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

+Jeremy,

I review the patch and think it is reasonable, but I want to know some more detail information

  1.  Can you provide the detail debug log about USB?
  2.  The symptom always can be seen or have fail rate?

Best Regards
Guomin
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Guomin Jiang
Sent: Thursday, August 6, 2020 12:29 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

I will review it by next weekend(8/14).

Thanks.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Feng Libo
Sent: Thursday, August 6, 2020 9:25 AM
To: Feng Libo <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello,

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo


[-- Attachment #2: Type: text/html, Size: 19469 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
       [not found]         ` <162A3294EE88D661.26440@groups.io>
@ 2020-08-12  8:03           ` Guomin Jiang
  2020-08-13  2:49             ` Feng Libo
  0 siblings, 1 reply; 10+ messages in thread
From: Guomin Jiang @ 2020-08-12  8:03 UTC (permalink / raw)
  To: devel@edk2.groups.io, Jiang, Guomin, lbfeng@zd-tech.com.cn
  Cc: jeremy.linton@arm.com, Wu, Hao A, Ni, Ray

[-- Attachment #1: Type: text/plain, Size: 7379 bytes --]

Hi Libo,

I review the USB Spec 2.0 and have some confusion when check the spec as below:
From the USB 2.0 spec:

Section 5.5.3 Control Transfer Packet Size Constraints
...
In order to determine the maximum packet size for the Default Control Pipe, the USB System Software
reads the device descriptor. The host will read the first eight bytes of the device descriptor. The device
always responds with at least these initial bytes in a single packet. After the host reads the initial part of the
device descriptor, it is guaranteed to have read this default pipe’s wMaxPacketSize field (byte 7 of the
device descriptor). It will then allow the correct size for all subsequent transactions. For all other control
endpoints, the maximum data payload size is known after configuration so that the USB System Software
can ensure that no data payload will be sent to the endpoint that is larger than the supported size.
...

Also,
Section 9.1.2 Bus Enumeration
...
3. Now that the host knows the port to which the new device has been attached, the host then waits for at
least 100 ms to allow completion of an insertion process and for power at the device to become stable.
The host then issues a port enable and reset command to that port. Refer to Section 7.1.7.5 for
sequence of events and timings of connection through device reset.
4. The hub performs the required reset processing for that port (see Section 11.5.1.5). When the reset
signal is released, the port has been enabled. The USB device is now in the Default state and can draw
no more than 100 mA from VBUS. All of its registers and state have been reset and it answers to the
default address.
5. The host assigns a unique address to the USB device, moving the device to the Address state.
6. Before the USB device receives a unique address, its Default Control Pipe is still accessible via the
default address. The host reads the device descriptor to determine what actual maximum data payload
size this USB device’s default pipe can use.
7. The host reads the configuration information from the device by reading each configuration zero to
n-1, where n is the number of configurations. This process may take several milliseconds to complete.
...

It seem that the original behavior follow the spec, but I don’t know why the device will not response and must reset it.

I notice that  you obtain the patch from https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20.

Do you know the device behavior from the device side when the issue happened?

Thanks.
Guomin
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin Jiang
Sent: Tuesday, August 11, 2020 7:17 PM
To: devel@edk2.groups.io; lbfeng@zd-tech.com.cn
Cc: jeremy.linton@arm.com; Wu, Hao A <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

+Hao, Ray,

Hi Libo, thanks for your explanation.

So I think the patch is improvement for current logic.

Hi Hao and Ray,

Can you give some comments for the change.

Hi Jeremy,

It may be helpful for the ASSERT issue https://edk2.groups.io/g/devel/message/62651,can you try it?

Best Regards
Guomin
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Feng Libo
Sent: Tuesday, August 11, 2020 5:50 PM
To: Jiang, Guomin <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello, Mr. Jiang,

Thank for the review.

The original enumeration steps in the function of UsbEnumerateNewDev of file UsbEnumer.c: 1 reset the port, 2 set the usb device address, 3 get the Max Packet Size, 4 get the full device descriptor. However, when plugging a USB PenDisk with Innostor USB
controller chip (VID=0x1F75, PID=0x917, USB3.1), the fourth step always fails, trace as below:

========
XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = 4 XhcControlTransfer: error - Device Error, transfer - 40 UsbGetOneConfig: failed to get full descript Device Error UsbBuildDescTable: failed to get configure (index 0) UsbEnumerateNewDev: failed to build descriptor table - Device Error
=======

The host controller need to get the full device descriptor, but this moment, the Pendisk device doesn't response any more. Then timeout. and UsbEnumerateNewDev complains : failed to build descriptor.

We have three Pendisks from different manufacturers, all with Innostor USB controller chip. they all can't be enumerated all. And we observed the problem on both Huawei KunPeng(华为鲲鹏)and Loognson(龙芯)platforms.

The three Pendisks always fail the USB enumeration. Other USB 2.0 and USB 3.0 on hand can work well.

With the patch, the three pendisks and other pendisks can all work well.

THanks

--
Best Regards

Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>
发送日期:2020-08-11 08:21:10
收件人:"devel@edk2.groups.io<mailto:devel@edk2.groups.io>" <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>,"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>,"lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>" <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>
抄送人:"jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>" <jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.


+Jeremy,

I review the patch and think it is reasonable, but I want to know some more detail information

  1.  Can you provide the detail debug log about USB?
  2.  The symptom always can be seen or have fail rate?

Best Regards
Guomin
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Guomin Jiang
Sent: Thursday, August 6, 2020 12:29 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

I will review it by next weekend(8/14).

Thanks.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Feng Libo
Sent: Thursday, August 6, 2020 9:25 AM
To: Feng Libo <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello,

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo


[-- Attachment #2: Type: text/html, Size: 29713 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
  2020-08-12  8:03           ` Guomin Jiang
@ 2020-08-13  2:49             ` Feng Libo
  2020-08-27  1:07               ` Feng Libo
  0 siblings, 1 reply; 10+ messages in thread
From: Feng Libo @ 2020-08-13  2:49 UTC (permalink / raw)
  To: Jiang, Guomin
  Cc: devel@edk2.groups.io, jeremy.linton@arm.com, Wu, Hao A, Ni, Ray,
	张超

[-- Attachment #1: Type: text/plain, Size: 8521 bytes --]

Hello, Mr. Jiang,


Most USB PenDisk work fine with the original enumeration sequence. A few can't.
 
In Microsoft Post, they explained the cause :
In the early days of USB some USB devices would become confused by a second request for the Device Descriptor if they did not return the complete Device Descriptor for the first request.  To allow these devices to enumerate successfully it was necessary to reset the port between the first and second requests for the Device Descriptor.


In our experience, only three Pendisk with Innostor USB controller chip (VID=0x1F75, PID=0x917, USB3.1) fail the enumeration. We can only observed the Pendisk not responding the second Device Descriptor Request for a full Descriptor. The first Device Descriptor Request could impact some Pendisk or as Microsoft said "confuse".  


So, We add a second port reset after the MaxPacketSize0 request. and this second reset can clear the address that is already assigned. Then, we move the MaxPacketSize request before the address assignation.


That is all patch.


Furthermore, the USB Spec states the MaxPacketSize Request could be read through the default Pipe, the address 0. So I think it implies the MaxPacketSize Request should be prior to the address assignation, just as the enumeration sequence in the Microsoft Post.


Thanks


--

Best Regards


Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"Jiang, Guomin" <guomin.jiang@intel.com>
发送日期:2020-08-12 16:03:42
收件人:"devel@edk2.groups.io" <devel@edk2.groups.io>,"Jiang, Guomin" <guomin.jiang@intel.com>,"lbfeng@zd-tech.com.cn" <lbfeng@zd-tech.com.cn>
抄送人:"jeremy.linton@arm.com" <jeremy.linton@arm.com>,"Wu, Hao A" <hao.a.wu@intel.com>,"Ni, Ray" <ray.ni@intel.com>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.


Hi Libo,

 

I review the USB Spec 2.0 and have some confusion when check the spec as below:

From the USB 2.0 spec:

 

Section 5.5.3 Control Transfer Packet Size Constraints

...

In order to determine the maximum packet size for the Default Control Pipe, the USB System Software

reads the device descriptor. The host will read the first eight bytes of the device descriptor. The device

always responds with at least these initial bytes in a single packet. After the host reads the initial part of the

device descriptor, it is guaranteed to have read this default pipe’s wMaxPacketSize field (byte 7 of the

device descriptor). It will then allow the correct size for all subsequent transactions. For all other control

endpoints, the maximum data payload size is known after configuration so that the USB System Software

can ensure that no data payload will be sent to the endpoint that is larger than the supported size.

...

 

Also,

Section 9.1.2 Bus Enumeration

...

3. Now that the host knows the port to which the new device has been attached, the host then waits for at

least 100 ms to allow completion of an insertion process and for power at the device to become stable.

The host then issues a port enable and reset command to that port. Refer to Section 7.1.7.5 for

sequence of events and timings of connection through device reset.

4. The hub performs the required reset processing for that port (see Section 11.5.1.5). When the reset

signal is released, the port has been enabled. The USB device is now in the Default state and can draw

no more than 100 mA from VBUS. All of its registers and state have been reset and it answers to the

default address.

5. The host assigns a unique address to the USB device, moving the device to the Address state.

6. Before the USB device receives a unique address, its Default Control Pipe is still accessible via the

default address. The host reads the device descriptor to determine what actual maximum data payload

size this USB device’s default pipe can use.

7. The host reads the configuration information from the device by reading each configuration zero to

n-1, where n is the number of configurations. This process may take several milliseconds to complete.

...

 

It seem that the original behavior follow the spec, but I don’t know why the device will not response and must reset it.

 

I notice that  you obtain the patch from https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20.

 

Do you know the device behavior from the device side when the issue happened?

 

Thanks.

Guomin

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin Jiang
Sent: Tuesday, August 11, 2020 7:17 PM
To: devel@edk2.groups.io; lbfeng@zd-tech.com.cn
Cc: jeremy.linton@arm.com; Wu, Hao A <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

+Hao, Ray,

 

Hi Libo, thanks for your explanation.

 

So I think the patch is improvement for current logic.

 

Hi Hao and Ray,

 

Can you give some comments for the change.

 

Hi Jeremy,

 

It may be helpful for the ASSERT issue https://edk2.groups.io/g/devel/message/62651,can you try it?

 

Best Regards

Guomin

From:devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Feng Libo
Sent: Tuesday, August 11, 2020 5:50 PM
To: Jiang, Guomin <guomin.jiang@intel.com>
Cc:devel@edk2.groups.io; jeremy.linton@arm.com
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

Hello, Mr. Jiang,

 

Thank for the review.

 

The original enumeration steps in the function of UsbEnumerateNewDev of file UsbEnumer.c: 1 reset the port, 2 set the usb device address, 3 get the Max Packet Size, 4 get the full device descriptor. However, when plugging a USB PenDisk with Innostor USB

controller chip (VID=0x1F75, PID=0x917, USB3.1), the fourth step always fails, trace as below:

 

========

XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = 4 XhcControlTransfer: error - Device Error, transfer - 40 UsbGetOneConfig: failed to get full descript Device Error UsbBuildDescTable: failed to get configure (index 0) UsbEnumerateNewDev: failed to build descriptor table - Device Error

=======

 

The host controller need to get the full device descriptor, but this moment, the Pendisk device doesn't response any more. Then timeout. and UsbEnumerateNewDev complains : failed to build descriptor.

 

We have three Pendisks from different manufacturers, all with Innostor USB controller chip. they all can't be enumerated all. And we observed the problem on both Huawei KunPeng(华为鲲鹏)and Loognson(龙芯)platforms.

 

The three Pendisks always fail the USB enumeration. Other USB 2.0 and USB 3.0 on hand can work well.

 

With the patch, the three pendisks and other pendisks can all work well.

 

THanks

 

--

Best Regards

 

Feng Libo

ZD Technology (Beijing) Co., Ltd


发件人:"Jiang, Guomin" <guomin.jiang@intel.com>
发送日期:2020-08-11 08:21:10
收件人:"devel@edk2.groups.io" <devel@edk2.groups.io>,"Jiang, Guomin" <guomin.jiang@intel.com>,"lbfeng@zd-tech.com.cn" <lbfeng@zd-tech.com.cn>
抄送人:"jeremy.linton@arm.com" <jeremy.linton@arm.com>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.




+Jeremy,

 

I review the patch and think it is reasonable, but I want to know some more detail information

Can you provide the detail debug log about USB?
The symptom always can be seen or have fail rate?

 

Best Regards

Guomin

From:devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin Jiang
Sent: Thursday, August 6, 2020 12:29 PM
To:devel@edk2.groups.io; lbfeng@zd-tech.com.cn
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

I will review it by next weekend(8/14).

 

Thanks.

From:devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Feng Libo
Sent: Thursday, August 6, 2020 9:25 AM
To: Feng Libo <lbfeng@zd-tech.com.cn>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

Hello, 

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo


[-- Attachment #2: Type: text/html, Size: 29457 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
  2020-08-13  2:49             ` Feng Libo
@ 2020-08-27  1:07               ` Feng Libo
  2020-08-28  7:50                 ` Wu, Hao A
  0 siblings, 1 reply; 10+ messages in thread
From: Feng Libo @ 2020-08-27  1:07 UTC (permalink / raw)
  To: 丰立波
  Cc: Jiang, Guomin, devel@edk2.groups.io, jeremy.linton@arm.com,
	Wu, Hao A, Ni, Ray, 张超

[-- Attachment #1: Type: text/plain, Size: 9059 bytes --]

Hello, 


How about the progress of the Patch Review?


Thanks


--

Best Regards


Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"丰立波" <lbfeng@zd-tech.com.cn>
发送日期:2020-08-13 10:49:33
收件人:"Jiang, Guomin" <guomin.jiang@intel.com>
抄送人:"devel@edk2.groups.io" <devel@edk2.groups.io>,"jeremy.linton@arm.com" <jeremy.linton@arm.com>,"Wu, Hao A" <hao.a.wu@intel.com>,"Ni, Ray" <ray.ni@intel.com>,"张超" <czhang@zd-tech.com.cn>
主题:Re:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello, Mr. Jiang,


Most USB PenDisk work fine with the original enumeration sequence. A few can't.
 
In Microsoft Post, they explained the cause :
In the early days of USB some USB devices would become confused by a second request for the Device Descriptor if they did not return the complete Device Descriptor for the first request.  To allow these devices to enumerate successfully it was necessary to reset the port between the first and second requests for the Device Descriptor.


In our experience, only three Pendisk with Innostor USB controller chip (VID=0x1F75, PID=0x917, USB3.1) fail the enumeration. We can only observed the Pendisk not responding the second Device Descriptor Request for a full Descriptor. The first Device Descriptor Request could impact some Pendisk or as Microsoft said "confuse".  


So, We add a second port reset after the MaxPacketSize0 request. and this second reset can clear the address that is already assigned. Then, we move the MaxPacketSize request before the address assignation.


That is all patch.


Furthermore, the USB Spec states the MaxPacketSize Request could be read through the default Pipe, the address 0. So I think it implies the MaxPacketSize Request should be prior to the address assignation, just as the enumeration sequence in the Microsoft Post.


Thanks


--

Best Regards


Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"Jiang, Guomin" <guomin.jiang@intel.com>
发送日期:2020-08-12 16:03:42
收件人:"devel@edk2.groups.io" <devel@edk2.groups.io>,"Jiang, Guomin" <guomin.jiang@intel.com>,"lbfeng@zd-tech.com.cn" <lbfeng@zd-tech.com.cn>
抄送人:"jeremy.linton@arm.com" <jeremy.linton@arm.com>,"Wu, Hao A" <hao.a.wu@intel.com>,"Ni, Ray" <ray.ni@intel.com>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.


Hi Libo,

 

I review the USB Spec 2.0 and have some confusion when check the spec as below:

From the USB 2.0 spec:

 

Section 5.5.3 Control Transfer Packet Size Constraints

...

In order to determine the maximum packet size for the Default Control Pipe, the USB System Software

reads the device descriptor. The host will read the first eight bytes of the device descriptor. The device

always responds with at least these initial bytes in a single packet. After the host reads the initial part of the

device descriptor, it is guaranteed to have read this default pipe’s wMaxPacketSize field (byte 7 of the

device descriptor). It will then allow the correct size for all subsequent transactions. For all other control

endpoints, the maximum data payload size is known after configuration so that the USB System Software

can ensure that no data payload will be sent to the endpoint that is larger than the supported size.

...

 

Also,

Section 9.1.2 Bus Enumeration

...

3. Now that the host knows the port to which the new device has been attached, the host then waits for at

least 100 ms to allow completion of an insertion process and for power at the device to become stable.

The host then issues a port enable and reset command to that port. Refer to Section 7.1.7.5 for

sequence of events and timings of connection through device reset.

4. The hub performs the required reset processing for that port (see Section 11.5.1.5). When the reset

signal is released, the port has been enabled. The USB device is now in the Default state and can draw

no more than 100 mA from VBUS. All of its registers and state have been reset and it answers to the

default address.

5. The host assigns a unique address to the USB device, moving the device to the Address state.

6. Before the USB device receives a unique address, its Default Control Pipe is still accessible via the

default address. The host reads the device descriptor to determine what actual maximum data payload

size this USB device’s default pipe can use.

7. The host reads the configuration information from the device by reading each configuration zero to

n-1, where n is the number of configurations. This process may take several milliseconds to complete.

...

 

It seem that the original behavior follow the spec, but I don’t know why the device will not response and must reset it.

 

I notice that  you obtain the patch from https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20.

 

Do you know the device behavior from the device side when the issue happened?

 

Thanks.

Guomin

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin Jiang
Sent: Tuesday, August 11, 2020 7:17 PM
To: devel@edk2.groups.io; lbfeng@zd-tech.com.cn
Cc: jeremy.linton@arm.com; Wu, Hao A <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

+Hao, Ray,

 

Hi Libo, thanks for your explanation.

 

So I think the patch is improvement for current logic.

 

Hi Hao and Ray,

 

Can you give some comments for the change.

 

Hi Jeremy,

 

It may be helpful for the ASSERT issue https://edk2.groups.io/g/devel/message/62651,can you try it?

 

Best Regards

Guomin

From:devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Feng Libo
Sent: Tuesday, August 11, 2020 5:50 PM
To: Jiang, Guomin <guomin.jiang@intel.com>
Cc:devel@edk2.groups.io; jeremy.linton@arm.com
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

Hello, Mr. Jiang,

 

Thank for the review.

 

The original enumeration steps in the function of UsbEnumerateNewDev of file UsbEnumer.c: 1 reset the port, 2 set the usb device address, 3 get the Max Packet Size, 4 get the full device descriptor. However, when plugging a USB PenDisk with Innostor USB

controller chip (VID=0x1F75, PID=0x917, USB3.1), the fourth step always fails, trace as below:

 

========

XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = 4 XhcControlTransfer: error - Device Error, transfer - 40 UsbGetOneConfig: failed to get full descript Device Error UsbBuildDescTable: failed to get configure (index 0) UsbEnumerateNewDev: failed to build descriptor table - Device Error

=======

 

The host controller need to get the full device descriptor, but this moment, the Pendisk device doesn't response any more. Then timeout. and UsbEnumerateNewDev complains : failed to build descriptor.

 

We have three Pendisks from different manufacturers, all with Innostor USB controller chip. they all can't be enumerated all. And we observed the problem on both Huawei KunPeng(华为鲲鹏)and Loognson(龙芯)platforms.

 

The three Pendisks always fail the USB enumeration. Other USB 2.0 and USB 3.0 on hand can work well.

 

With the patch, the three pendisks and other pendisks can all work well.

 

THanks

 

--

Best Regards

 

Feng Libo

ZD Technology (Beijing) Co., Ltd


发件人:"Jiang, Guomin" <guomin.jiang@intel.com>
发送日期:2020-08-11 08:21:10
收件人:"devel@edk2.groups.io" <devel@edk2.groups.io>,"Jiang, Guomin" <guomin.jiang@intel.com>,"lbfeng@zd-tech.com.cn" <lbfeng@zd-tech.com.cn>
抄送人:"jeremy.linton@arm.com" <jeremy.linton@arm.com>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.




+Jeremy,

 

I review the patch and think it is reasonable, but I want to know some more detail information

Can you provide the detail debug log about USB?
The symptom always can be seen or have fail rate?

 

Best Regards

Guomin

From:devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin Jiang
Sent: Thursday, August 6, 2020 12:29 PM
To:devel@edk2.groups.io; lbfeng@zd-tech.com.cn
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

I will review it by next weekend(8/14).

 

Thanks.

From:devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Feng Libo
Sent: Thursday, August 6, 2020 9:25 AM
To: Feng Libo <lbfeng@zd-tech.com.cn>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

 

Hello, 

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo


[-- Attachment #2: Type: text/html, Size: 30445 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
  2020-08-27  1:07               ` Feng Libo
@ 2020-08-28  7:50                 ` Wu, Hao A
  0 siblings, 0 replies; 10+ messages in thread
From: Wu, Hao A @ 2020-08-28  7:50 UTC (permalink / raw)
  To: devel@edk2.groups.io, lbfeng@zd-tech.com.cn
  Cc: Jiang, Guomin, jeremy.linton@arm.com, Ni, Ray, 张超

[-- Attachment #1: Type: text/plain, Size: 12093 bytes --]

Hello,

After looking into the proposed patch, I think it is reasonable to add enhanced error handling for such USB device that will fail the 2nd Device Descriptor request.

The flow of the current proposal is:
1. First Port Reset
2. First Device Descriptor Request for bMaxPacketSize0
3. Second Port Reset. add extra reset
4. Set USB address
5. Second Device Descriptor Request

For the above flow, I have a concern that a mandatory 2nd port reset may impact the performance during USB device enumeration.
So how about:
1. First Port Reset
2. First Device Descriptor Request for bMaxPacketSize0
3. Set USB address
4. Second Device Descriptor Request
5a. If the second descriptor request succeeds, the process just go on.
5b. If the second request fails:
  5b-1). Port Reset
  5b-2). Set USB address
  5b-3). Request the descriptor again
  5b-4a). If the request succeeds, the process just go on.
  5b-4b). If the request still fails, the enumeration of the device fails.

Also, could you help to file a Bugzilla tracker at https://bugzilla.tianocore.org/?
Please help to described the issue met in the tracker, thanks in advance.

Best Regards,
Hao Wu

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Feng Libo
Sent: Thursday, August 27, 2020 9:07 AM
To: 丰立波 <lbfeng@zd-tech.com.cn>
Cc: Jiang, Guomin <guomin.jiang@intel.com>; devel@edk2.groups.io; jeremy.linton@arm.com; Wu, Hao A <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>; 张超 <czhang@zd-tech.com.cn>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello,

How about the progress of the Patch Review?

Thanks

--
Best Regards

Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"丰立波" <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>
发送日期:2020-08-13 10:49:33
收件人:"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>
抄送人:"devel@edk2.groups.io<mailto:devel@edk2.groups.io>" <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>,"jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>" <jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>>,"Wu, Hao A" <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>,"Ni, Ray" <ray.ni@intel.com<mailto:ray.ni@intel.com>>,"张超" <czhang@zd-tech.com.cn<mailto:czhang@zd-tech.com.cn>>
主题:Re:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello, Mr. Jiang,

Most USB PenDisk work fine with the original enumeration sequence. A few can't.

In Microsoft Post, they explained the cause :
In the early days of USB some USB devices would become confused by a second request for the Device Descriptor if they did not return the complete Device Descriptor for the first request.  To allow these devices to enumerate successfully it was necessary to reset the port between the first and second requests for the Device Descriptor.

In our experience, only three Pendisk with Innostor USB controller chip (VID=0x1F75, PID=0x917, USB3.1) fail the enumeration. We can only observed the Pendisk not responding the second Device Descriptor Request for a full Descriptor. The first Device Descriptor Request could impact some Pendisk or as Microsoft said "confuse".

So, We add a second port reset after the MaxPacketSize0 request. and this second reset can clear the address that is already assigned. Then, we move the MaxPacketSize request before the address assignation.

That is all patch.

Furthermore, the USB Spec states the MaxPacketSize Request could be read through the default Pipe, the address 0. So I think it implies the MaxPacketSize Request should be prior to the address assignation, just as the enumeration sequence in the Microsoft Post.

Thanks

--
Best Regards

Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>
发送日期:2020-08-12 16:03:42
收件人:"devel@edk2.groups.io<mailto:devel@edk2.groups.io>" <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>,"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>,"lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>" <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>
抄送人:"jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>" <jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>>,"Wu, Hao A" <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>,"Ni, Ray" <ray.ni@intel.com<mailto:ray.ni@intel.com>>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hi Libo,

I review the USB Spec 2.0 and have some confusion when check the spec as below:
From the USB 2.0 spec:

Section 5.5.3 Control Transfer Packet Size Constraints
...
In order to determine the maximum packet size for the Default Control Pipe, the USB System Software
reads the device descriptor. The host will read the first eight bytes of the device descriptor. The device
always responds with at least these initial bytes in a single packet. After the host reads the initial part of the
device descriptor, it is guaranteed to have read this default pipe’s wMaxPacketSize field (byte 7 of the
device descriptor). It will then allow the correct size for all subsequent transactions. For all other control
endpoints, the maximum data payload size is known after configuration so that the USB System Software
can ensure that no data payload will be sent to the endpoint that is larger than the supported size.
...

Also,
Section 9.1.2 Bus Enumeration
...
3. Now that the host knows the port to which the new device has been attached, the host then waits for at
least 100 ms to allow completion of an insertion process and for power at the device to become stable.
The host then issues a port enable and reset command to that port. Refer to Section 7.1.7.5 for
sequence of events and timings of connection through device reset.
4. The hub performs the required reset processing for that port (see Section 11.5.1.5). When the reset
signal is released, the port has been enabled. The USB device is now in the Default state and can draw
no more than 100 mA from VBUS. All of its registers and state have been reset and it answers to the
default address.
5. The host assigns a unique address to the USB device, moving the device to the Address state.
6. Before the USB device receives a unique address, its Default Control Pipe is still accessible via the
default address. The host reads the device descriptor to determine what actual maximum data payload
size this USB device’s default pipe can use.
7. The host reads the configuration information from the device by reading each configuration zero to
n-1, where n is the number of configurations. This process may take several milliseconds to complete.
...

It seem that the original behavior follow the spec, but I don’t know why the device will not response and must reset it.

I notice that  you obtain the patch from https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20.

Do you know the device behavior from the device side when the issue happened?

Thanks.
Guomin
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Guomin Jiang
Sent: Tuesday, August 11, 2020 7:17 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>
Cc: jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

+Hao, Ray,

Hi Libo, thanks for your explanation.

So I think the patch is improvement for current logic.

Hi Hao and Ray,

Can you give some comments for the change.

Hi Jeremy,

It may be helpful for the ASSERT issue https://edk2.groups.io/g/devel/message/62651,can you try it?

Best Regards
Guomin
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Feng Libo
Sent: Tuesday, August 11, 2020 5:50 PM
To: Jiang, Guomin <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello, Mr. Jiang,

Thank for the review.

The original enumeration steps in the function of UsbEnumerateNewDev of file UsbEnumer.c: 1 reset the port, 2 set the usb device address, 3 get the Max Packet Size, 4 get the full device descriptor. However, when plugging a USB PenDisk with Innostor USB
controller chip (VID=0x1F75, PID=0x917, USB3.1), the fourth step always fails, trace as below:

========
XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = 4 XhcControlTransfer: error - Device Error, transfer - 40 UsbGetOneConfig: failed to get full descript Device Error UsbBuildDescTable: failed to get configure (index 0) UsbEnumerateNewDev: failed to build descriptor table - Device Error
=======

The host controller need to get the full device descriptor, but this moment, the Pendisk device doesn't response any more. Then timeout. and UsbEnumerateNewDev complains : failed to build descriptor.

We have three Pendisks from different manufacturers, all with Innostor USB controller chip. they all can't be enumerated all. And we observed the problem on both Huawei KunPeng(华为鲲鹏)and Loognson(龙芯)platforms.

The three Pendisks always fail the USB enumeration. Other USB 2.0 and USB 3.0 on hand can work well.

With the patch, the three pendisks and other pendisks can all work well.

THanks

--
Best Regards

Feng Libo
ZD Technology (Beijing) Co., Ltd

发件人:"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>
发送日期:2020-08-11 08:21:10
收件人:"devel@edk2.groups.io<mailto:devel@edk2.groups.io>" <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>,"Jiang, Guomin" <guomin.jiang@intel.com<mailto:guomin.jiang@intel.com>>,"lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>" <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>
抄送人:"jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>" <jeremy.linton@arm.com<mailto:jeremy.linton@arm.com>>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

+Jeremy,

I review the patch and think it is reasonable, but I want to know some more detail information

  1.  Can you provide the detail debug log about USB?
  2.  The symptom always can be seen or have fail rate?

Best Regards
Guomin
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Guomin Jiang
Sent: Thursday, August 6, 2020 12:29 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

I will review it by next weekend(8/14).

Thanks.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Feng Libo
Sent: Thursday, August 6, 2020 9:25 AM
To: Feng Libo <lbfeng@zd-tech.com.cn<mailto:lbfeng@zd-tech.com.cn>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.

Hello,

could anyone review this PATCH?

We encountered the USB enumeration problem and the patch is based on the Microsoft post as below.

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685#:~:text=%20How%20does%20USB%20stack%20enumerate%20a%20device%3F,a%20request%20for%20the%20USB%20Device...%20More%20

Thanks

Best Regards

Feng Libo


[-- Attachment #2: Type: text/html, Size: 59216 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-08-28  7:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-17  2:49 [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration Feng Libo
2020-08-06  1:25 ` [edk2-devel] " Feng Libo
2020-08-06  4:28   ` Guomin Jiang
     [not found]   ` <16289366B25D4B9F.5756@groups.io>
2020-08-11  0:21     ` Guomin Jiang
2020-08-11  9:50       ` Feng Libo
2020-08-11 11:17         ` Guomin Jiang
     [not found]         ` <162A3294EE88D661.26440@groups.io>
2020-08-12  8:03           ` Guomin Jiang
2020-08-13  2:49             ` Feng Libo
2020-08-27  1:07               ` Feng Libo
2020-08-28  7:50                 ` Wu, Hao A

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox