From: "Feng Libo" <lbfeng@zd-tech.com.cn>
To: devel@edk2.groups.io, czhang@zd-tech.com.cn
Cc: Feng Libo <lbfeng@zd-tech.com.cn>
Subject: [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration.
Date: Fri, 17 Jul 2020 10:49:13 +0800 [thread overview]
Message-ID: <2a831532171eec3c9f5a0630621fc23c7f894935.1594953823.git.lbfeng@zd-tech.com.cn> (raw)
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
next reply other threads:[~2020-07-17 2:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 2:49 Feng Libo [this message]
2020-08-06 1:25 ` [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2a831532171eec3c9f5a0630621fc23c7f894935.1594953823.git.lbfeng@zd-tech.com.cn \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox