From nobody Thu Apr 25 10:22:17 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+60092+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+60092+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1590136860; cv=none; d=zohomail.com; s=zohoarc; b=RTfCjaJz4UeIWDlqbwzAe+m6hNOES6x3kWT7HjGqW389to7GcmG22QRsDXnNh1yk7Bw9wR7Cg8aNAp9qjuAFWycdyGigUMKVgoVrbz8oSJqboAgQr2AVrnswQ7lUkX/ee9q6a/Yx2gHG0JofAYnsFyMz0JAxw4hsSE7yP1WyULM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590136860; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=zApQjZnvF7hZwVeH8Kmw0YjjJW82/BEu+12cr821Zwo=; b=KQ6xt2WXcExdL3iqiYkPST+huzg17R56DVUc4VVhs1qloNnRhpAnPO+96I9vFLjBgd21i+eEx7bgRVQrjSA+vg6UeS896szKTcLu+f0oEa1oL1U46K+YOc2dJETYqvXnAfXa/CbavQnYjU/UcqlbMkdpPXKikBNHA/658pp13oo= 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+60092+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 159013686059494.07980670069435; Fri, 22 May 2020 01:41:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6vNzYY1788612xvqForT1bNq; Fri, 22 May 2020 01:41:00 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.9437.1590136859295747603 for ; Fri, 22 May 2020 01:40:59 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EA6E855D; Fri, 22 May 2020 01:40:58 -0700 (PDT) X-Received: from e123331-lin.nice.arm.com (unknown [10.37.8.250]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 300D03F52E; Fri, 22 May 2020 01:40:57 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: liming.gao@intel.com, leif@nuviainc.com, lersek@redhat.com, philmd@redhat.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH v2] ArmPkg/PlatformBootManagerLib: connect non-discoverable USB hosts Date: Fri, 22 May 2020 10:40:06 +0200 Message-Id: <20200522084006.32006-1-ard.biesheuvel@arm.com> 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,ard.biesheuvel@arm.com X-Gm-Message-State: NVZvehxViJPStXZQLHuHpjn8x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590136860; bh=maTQrl4UrL+X/+hd1+3aRwC9ZgBeqB6buBUcrSJRbU8=; h=Cc:Date:From:Reply-To:Subject:To; b=FouF32NJqF3K1DNf+nnDcbc7/3mhmkRxwH9ztOcML1Vdov+U/lri4lFd/K833pHTop5 ptIkCRW/FojMzHv6kcTYgl2ySQLMtTzoA0X8N+bR7UBF28UV1NT6DjUJuiAJqZJ7Bbc5G LPo4uqlBjaoCv60JOEXGuGpbtCMVl78uFis= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The way the BDS handles the short-form USB device path of the console keyboard relies on USB host controllers to be locatable via their PCI metadata, which implies that these controllers already have a PCI I/O protocol installed on their handle. This is not the case for non-discoverable USB host controllers that are supported by the NonDiscoverable PCI device driver. These controllers must be connected first, or the BDS will never notice their existence, and will not enable any USB keyboards connected through them. Let's work around this by connecting these handles explicitly. This is a bit of a stopgap, but it is the cleanest way of dealing with this without violating the UEFI driver model entirely. This ensures that platforms that do not rely on ConnectAll() will keep working as expected. Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek Reviewed-by: Leif Lindholm --- This is tagged as v2 since it is a followup to 'MdeModulePkg/NonDiscoverablePciDeviceDxe: connect handles on registratio= n' that I sent out yesterday. Laslzo made the point that it would be unfortunate to add yet another hack that defeats the UEFI driver model entirely, so this time, the change is in the BDS where it belongs. Note that only USB console devices are affected by this: short form block IO device paths used for booting are expanded and cached in a "HDDP" variable, and so they work as expected with fast boot without connect all. ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 4 ++ ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 42 ++++= ++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.i= nf b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index 87c9b1150c54..2f726d117d7d 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -66,6 +66,9 @@ [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut =20 [Guids] + gEdkiiNonDiscoverableEhciDeviceGuid + gEdkiiNonDiscoverableUhciDeviceGuid + gEdkiiNonDiscoverableXhciDeviceGuid gEfiFileInfoGuid gEfiFileSystemInfoGuid gEfiFileSystemVolumeLabelInfoIdGuid @@ -74,6 +77,7 @@ [Guids] gUefiShellFileGuid =20 [Protocols] + gEdkiiNonDiscoverableDeviceProtocolGuid gEfiDevicePathProtocolGuid gEfiGraphicsOutputProtocolGuid gEfiLoadedImageProtocolGuid diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Li= brary/PlatformBootManagerLib/PlatformBm.c index 3411219fbfdb..4aca1382b042 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -23,10 +23,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include =20 @@ -254,6 +256,37 @@ IsPciDisplay ( } =20 =20 +/** + This FILTER_FUNCTION checks if a handle corresponds to a non-discoverable + USB host controller. +**/ +STATIC +BOOLEAN +EFIAPI +IsUsbHost ( + IN EFI_HANDLE Handle, + IN CONST CHAR16 *ReportText + ) +{ + NON_DISCOVERABLE_DEVICE *Device; + EFI_STATUS Status; + + Status =3D gBS->HandleProtocol (Handle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, + (VOID **)&Device); + if (EFI_ERROR (Status)) { + return FALSE; + } + + if (CompareGuid (Device->Type, &gEdkiiNonDiscoverableUhciDeviceGuid) || + CompareGuid (Device->Type, &gEdkiiNonDiscoverableEhciDeviceGuid) || + CompareGuid (Device->Type, &gEdkiiNonDiscoverableXhciDeviceGuid)) { + return TRUE; + } + return FALSE; +} + + /** This CALLBACK_FUNCTION attempts to connect a handle non-recursively, ask= ing the matching driver to produce all first-level child handles. @@ -574,6 +607,15 @@ PlatformBootManagerBeforeConsole ( // FilterAndProcess (&gEfiGraphicsOutputProtocolGuid, NULL, AddOutput); =20 + // + // The core BDS code connects short-form USB device paths by explicitly + // looking for handles with PCI I/O installed, and checking the PCI class + // code whether it matches the one for a USB host controller. This means + // non-discoverable USB host controllers need to have the non-discoverab= le + // PCI driver attached first. + // + FilterAndProcess (&gEdkiiNonDiscoverableDeviceProtocolGuid, IsUsbHost, C= onnect); + // // Add the hardcoded short-form USB keyboard device path to ConIn. // --=20 2.17.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 (#60092): https://edk2.groups.io/g/devel/message/60092 Mute This Topic: https://groups.io/mt/74395026/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-