From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smarthost01b.ixn.mail.zen.net.uk (smarthost01b.ixn.mail.zen.net.uk [212.23.1.21]) by mx.groups.io with SMTP id smtpd.web08.9191.1645702704572188896 for ; Thu, 24 Feb 2022 03:38:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=permerror, err=parse error for token &{10 18 sdn.klaviyomail.com}: permanent DNS error (domain: starlabs.systems, ip: 212.23.1.21, mailfrom: sean@starlabs.systems) Received: from [217.155.46.38] (helo=sean-StarBook.lan) by smarthost01b.ixn.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nNCRw-0002Vb-Iy; Thu, 24 Feb 2022 11:38:20 +0000 From: "Sean Rhodes" To: devel@edk2.groups.io Cc: guo.dong@intel.com, Sean Rhodes , Hao A Wu , Ray Ni , Matt DeVillier , Patrick Rudolph Subject: [PATCH] MdeModulePkg/Usb/Keyboard.c: Don't request protocol before setting Date: Thu, 24 Feb 2022 11:38:18 +0000 Message-Id: <96aee2ccd71e956372fa85cfafbf4fa03da3ae1f.1645702698.git.sean@starlabs.systems> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Originating-smarthost01b-IP: [217.155.46.38] Feedback-ID: 217.155.46.38 Content-Transfer-Encoding: quoted-printable No need to check the interface protocol then conditionally setting, just set it to BOOT_PROTOCOL and check for error. This is what Linux does for HID devices as some don't follow the USB spec. One example is the Aspeed BMC HID keyboard device, which adds a massive boot delay without this patch as it doesn't respond to 'GetProtocolRequest'. Cc: Hao A Wu Cc: Ray Ni Signed-off-by: Matt DeVillier Signed-off-by: Patrick Rudolph Signed-off-by: Sean Rhodes --- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Us= b/UsbKbDxe/KeyBoard.c index 5a94a4dda7..b5a6459a35 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -805,7 +805,6 @@ InitUSBKeyboard ( )=0D {=0D UINT16 ConfigValue;=0D - UINT8 Protocol;=0D EFI_STATUS Status;=0D UINT32 TransferResult;=0D =0D @@ -854,22 +853,15 @@ InitUSBKeyboard ( }=0D }=0D =0D - UsbGetProtocolRequest (=0D - UsbKeyboardDevice->UsbIo,=0D - UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,=0D - &Protocol=0D - );=0D //=0D // Set boot protocol for the USB Keyboard.=0D // This driver only supports boot protocol.=0D //=0D - if (Protocol !=3D BOOT_PROTOCOL) {=0D - UsbSetProtocolRequest (=0D - UsbKeyboardDevice->UsbIo,=0D - UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,=0D - BOOT_PROTOCOL=0D - );=0D - }=0D + UsbSetProtocolRequest (=0D + UsbKeyboardDevice->UsbIo,=0D + UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,=0D + BOOT_PROTOCOL=0D + );=0D =0D UsbKeyboardDevice->CtrlOn =3D FALSE;=0D UsbKeyboardDevice->AltOn =3D FALSE;=0D --=20 2.32.0