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

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