From nobody Wed May 1 23:49:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62746+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62746+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=zd-tech.com.cn ARC-Seal: i=1; a=rsa-sha256; t=1594979497; cv=none; d=zohomail.com; s=zohoarc; b=f5aSlCKQzkxAPW9EHpBSQ1Jy4AhqIB6sdRU8abwPkVA7zg1xh1oDuf4TmKaw6rGX3AZsBCJFFHVk786qcmlJRR7g3DP4inr+bk+CjwxgKC5hLosw5+VxxkjEpLbQDpumsIMJGYasVIVAcplbXYVEM3dhBYAFtde4TADUAL2Ail0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594979497; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=CGCVGUcUDCDpLV364LF+t0A5KZ3v37vHFZssXQbsy+U=; b=IjRrKTLjBaHD2HZdrd/FQ3Y8/ChSkuvI9IGZ0wBc7g55JuPWLRDeqIiQ4Lc8GGYrbz/bVfl1uLOxl7W0JILDq1SxCuY6JrvMfiywZDJOEzmKJHTaA7VYbXHiGJ882ft0jsE0ua8GI8NQ2I7xIExh6VKGmNDzLsnxK7PfdRYlqPk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62746+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594979497838501.8419038927317; Fri, 17 Jul 2020 02:51:37 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OKzhYY1788612xuHYr6CTNY5; Fri, 17 Jul 2020 02:51:37 -0700 X-Received: from mail-m24147.qiye.163.com (mail-m24147.qiye.163.com [220.194.24.147]) by mx.groups.io with SMTP id smtpd.web11.3843.1594954172564662585 for ; Thu, 16 Jul 2020 19:49:33 -0700 X-Received: from localhost.localdomain (unknown [223.104.3.146]) by smtp4 (Coremail) with SMTP id JedpCgB3itC3ERFfKkOICA--.323S2; Fri, 17 Jul 2020 10:49:28 +0800 (CST) From: "Feng Libo" To: devel@edk2.groups.io, czhang@zd-tech.com.cn Cc: Feng Libo Subject: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: some USB PenDisk fails enumeration. Date: Fri, 17 Jul 2020 10:49:13 +0800 Message-Id: <2a831532171eec3c9f5a0630621fc23c7f894935.1594953823.git.lbfeng@zd-tech.com.cn> X-CM-TRANSID: JedpCgB3itC3ERFfKkOICA--.323S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGF1rAFy8KFyDuw17JrWDArb_yoWrJrW3pF 45Jay5trZxJF90kw4fXw18Kw1rCF4rGa93XFZ3tw12kr1avrZY9F1a93WUuayUJF1kZFyk urn8ZFWrWr429FJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0JbfdgAUUUUU= X-Originating-IP: [223.104.3.146] X-CM-SenderInfo: poeiv0vj62vghwhfxhxfrphubq/1tbiWhhkmFf4ppHJZwAAsI Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lbfeng@zd-tech.com.cn X-Gm-Message-State: o9MD3A2ZxQSrkx4A1PIuX660x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594979497; bh=WIiHh87lLC24TeNxP0n3zQeefdi10ZZvMDq50iRDq6w=; h=Cc:Date:From:Reply-To:Subject:To; b=By0a3M2zudykoWBay/PVjpZ+yoDygZs2b+CUeUTIH6AYDJyRq03by+shpYpldUuAGVQ Im7BQhzTUJO6l5npE177FbXQY8+p23gnhc5TuqjmmdQC8BzxghFQUIwoXPFfZIHgh1MpF V/xWmLu1Sql2kRJ9PHANSkS0skZG6Z8TNTM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Inno= stor USB controller chip (VID=3D0x1F75, PID=3D0x917, 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 --- 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)); =20 // + // 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.=20 + // + Status =3D 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)); + + //=20 + // 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 r= equest. + // 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 =3D 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", Por= t)); + } 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)); =20 // - // Host sends a Get_Descriptor request to learn the max packet - // size of default pipe (only part of the device's descriptor). - // - Status =3D 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. // --=20 2.13.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62746): https://edk2.groups.io/g/devel/message/62746 Mute This Topic: https://groups.io/mt/75608816/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-