Re: [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
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.
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 188.8.131.52 for
sequence of events and timings of connection through device reset.
4. The hub performs the required reset processing for that port (see Section 184.108.40.206). 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
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?
From: firstname.lastname@example.org <email@example.com>
On Behalf Of Guomin Jiang
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.
It may be helpful for the ASSERT issue https://edk2.groups.io/g/devel/message/62651,can you try it?
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.
ZD Technology (Beijing) Co., Ltd