From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smarthost01b.sbp.mail.zen.net.uk (smarthost01b.sbp.mail.zen.net.uk [212.23.1.3]) by mx.groups.io with SMTP id smtpd.web08.2113.1644528430442567936 for ; Thu, 10 Feb 2022 13:27:10 -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.3, mailfrom: sean@starlabs.systems) Received: from [217.155.46.38] (helo=sean-StarBook.lan) by smarthost01b.sbp.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nIGy4-0007k4-6u; Thu, 10 Feb 2022 21:27:08 +0000 From: "Sean Rhodes" To: devel@edk2.groups.io Cc: hao.a.wu@intel.com, Matt DeVillier , Patrick Rudolph Subject: [PATCH 13/18] MdeModulePkg/Usb/Keyboard.c: don't request protocol before setting Date: Thu, 10 Feb 2022 21:27:06 +0000 Message-Id: <5527aab4cdea820aa58de36fd8d58ef88f24da82.1644527848.git.sean@starlabs.systems> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 X-Originating-smarthost01b-IP: [217.155.46.38] Feedback-ID: 217.155.46.38 Content-Transfer-Encoding: quoted-printable From: Matt DeVillier 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'. Signed-off-by: Matt DeVillier Signed-off-by: Patrick Rudolph --- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Us= b/UsbKbDxe/KeyBoard.c index 5a94a4dda7..56d249f937 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -863,12 +863,24 @@ InitUSBKeyboard ( // 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 + Status =3D UsbSetProtocolRequest (=0D + UsbKeyboardDevice->UsbIo,=0D + UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,=0D + BOOT_PROTOCOL=0D + );=0D + if (EFI_ERROR (Status)) {=0D + //=0D + // If protocol could not be set here, it means=0D + // the keyboard interface has some errors and could=0D + // not be initialized=0D + //=0D + REPORT_STATUS_CODE_WITH_DEVICE_PATH (=0D + EFI_ERROR_CODE | EFI_ERROR_MINOR,=0D + (EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_INTERFACE_ERROR),=0D + UsbKeyboardDevice->DevicePath=0D );=0D +=0D + return EFI_DEVICE_ERROR;=0D }=0D =0D UsbKeyboardDevice->CtrlOn =3D FALSE;=0D --=20 2.32.0