From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by mx.groups.io with SMTP id smtpd.web08.29904.1611158344460605935 for ; Wed, 20 Jan 2021 07:59:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@9elements.com header.s=google header.b=MfV53RvT; spf=pass (domain: 9elements.com, ip: 209.85.208.52, mailfrom: patrick.rudolph@9elements.com) Received: by mail-ed1-f52.google.com with SMTP id s11so19063965edd.5 for ; Wed, 20 Jan 2021 07:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VMV47mzWlxv7gNAX7wJUPxX3hophvBH78itl032Nnh4=; b=MfV53RvTtvse1qysIs8hplFAnEkeQI/Zitc5blp1Awp30Uj99Oj1rH/6m46/FtWyTE Ht7osfOYwF2ROtpbddfRU+D9XlwTlfx0FXFt4+oEijqaWnLXHRDnrZWZipdjKqePv9oH 8baNvOZ+bTjop2nAbPragpQHh2zNiiLM3rbs233MpxQn2AvKALTBQYB8Y3MN1BEi/vCP NMId4GQfWFobPRAmoNDKSQcufaw1BRZOqYFuxxjYvJLGPQwVMAsmQfHFDXs+YNo7er+i 7bigBs630ISHwh2lmg33hUFKNj0747pTMXWiAvjSkK+BetDEjpZSf3VEcNU+PE4RmHro 8vPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VMV47mzWlxv7gNAX7wJUPxX3hophvBH78itl032Nnh4=; b=bOQSpl1gQwdQcT5O2UYwW6pX/TsdzJNSwrT+2NTFwxpxzQyBvtUMnkXUbMkD6cvAUl ECCR+D5rufchBKbsLhH5PXLcndJfVvt3TevcqCvUv7xBp78Hdm9ByOk7Q6dCQfJvIkeT lqC32XJSBsvQJBeVAizzc5aXDxAaJ/ZS+ci30sMRDyg5F13sUWgnBAbwDYzuFyUg9O0u L+eOfkvM0q1URyFXo6scRpRhs1kEW9/EZbzjPEvVAucwgcGI+1t7r38vGJX+kn7TH8uo cKTY+ToRupZjUbo9nhPkV7XkPsTkoQjpEu1txSmho2ORf6JocDbbBEOtbi+in75m8wjB CXBg== X-Gm-Message-State: AOAM530hLLSMvi8e+zwqwnj3QNt22zlB7Hl4gfzBkrkilY7+kdMgor+M tUkN0PHo8jP6GomDKAWXbhJ58OzW4MgXYgc2 X-Google-Smtp-Source: ABdhPJzbDtxT4OvaZ6mWlisLLguS2n8/Fa7oKoBEtJ7LuPCxm47LG77TUhOVdqSiFYiOJJR5vS2GCA== X-Received: by 2002:aa7:d755:: with SMTP id a21mr7611009eds.301.1611158343120; Wed, 20 Jan 2021 07:59:03 -0800 (PST) Return-Path: Received: from rudolphp-notebook.9e.network (ip-95-222-8-167.hsi15.unitymediagroup.de. [95.222.8.167]) by smtp.gmail.com with ESMTPSA id h16sm1340360eds.21.2021.01.20.07.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 07:59:02 -0800 (PST) From: "Patrick Rudolph" To: devel@edk2.groups.io Cc: jian.j.wang@intel.com, hao.a.wu@intel.com, ray.ni@intel.com Subject: [PATCH 2/2] MdeModulePkg/Usb/Keyboard.c: don't request protocol before setting Date: Wed, 20 Jan 2021 16:59:00 +0100 Message-Id: <20210120155900.3343123-2-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210120155900.3343123-1-patrick.rudolph@9elements.com> References: <20210120155900.3343123-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 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 | 28 ++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Us= b/UsbKbDxe/KeyBoard.c index 77e20b203f..5914174b4d 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -801,7 +801,6 @@ InitUSBKeyboard ( IN OUT USB_KB_DEV *UsbKeyboardDevice=0D )=0D {=0D - UINT8 Protocol;=0D EFI_STATUS Status;=0D =0D REPORT_STATUS_CODE_WITH_DEVICE_PATH (=0D @@ -814,21 +813,28 @@ InitUSBKeyboard ( InitQueue (&UsbKeyboardDevice->EfiKeyQueue, sizeof (EFI_KEY_DATA));=0D InitQueue (&UsbKeyboardDevice->EfiKeyQueueForNotify, sizeof (EFI_KEY_DAT= A));=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 + 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.26.2