From nobody Sun Apr 28 22:54:07 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+53268+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+53268+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1579083751; cv=none; d=zohomail.com; s=zohoarc; b=WF4GsVpJSE0dFZJeWiJvRIgYAiJj6jrnjyOCFKbq435ANVEvNpLaHklT1qTWfR5eMBUBbyimSLuFG543GFclB8rtflaT8kvoopLjeI2GeMNAP5w0EICnl4o61yvdn8MgjrvAFxDBFsV1pWtb913hcJzSZi2l/GLKjpTtXuQvAgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579083751; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=yy/BARKc6619oIDbKICJpst39SB/8eewi8tOaEXjcwA=; b=BbNwtfLO2HNGH4diyhwNh5KM2RRbE+YhKRBXaOaJ47Fe+1pNqZHEShIQAbXRRb4fJLmhKfUSR8xcPVaKmiRlLBoyMcOA9NLcnyVv0bJuXzROlE+r3dHreSa7b7pqx4MycxQUU1nECXOaeoSw8Qh4oBykIwQHmVNEXS71rGW6tcU= 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+53268+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 1579083751240964.4731451228906; Wed, 15 Jan 2020 02:22:31 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id DFZJYY1788612xVpa3FEIWPe; Wed, 15 Jan 2020 02:22:30 -0800 X-Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.groups.io with SMTP id smtpd.web10.5176.1579083749935263005 for ; Wed, 15 Jan 2020 02:22:30 -0800 X-Received: by mail-wm1-f65.google.com with SMTP id p17so17195182wma.1 for ; Wed, 15 Jan 2020 02:22:29 -0800 (PST) X-Gm-Message-State: S4nkoqEQdIrc2GZxQG7nnf1Ex1787277AA= X-Google-Smtp-Source: APXvYqzj5MUL0gFHPt7o9NE2a/s8fVSUtn1oiZg3HfUQg++lZ/m/4bNbNByTjuMxFlkg+hMIkm7fgw== X-Received: by 2002:a05:600c:2c44:: with SMTP id r4mr31581692wmg.140.1579083748216; Wed, 15 Jan 2020 02:22:28 -0800 (PST) X-Received: from dogfood.home ([2a01:cb1d:112:6f00:d550:cc24:ff08:3949]) by smtp.gmail.com with ESMTPSA id b68sm23118038wme.6.2020.01.15.02.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2020 02:22:27 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, leif.lindholm@linaro.org, ray.ni@intel.com, afish@apple.com, Ard Biesheuvel Subject: [edk2-devel] [RFC PATCH] ArmPkg/PlatformBmLib: defer GOP console discovery after Driver#### dispatch Date: Wed, 15 Jan 2020 11:22:17 +0100 Message-Id: <20200115102217.3027-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 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@linaro.org Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579083750; bh=tv0K+F3WUJAWa0OfW6UmRKIphyGSAMbHI/CbJ/XSpLw=; h=Cc:Date:From:Reply-To:Subject:To; b=Y3ekRMelRorccqhcir4cy4Xxp+jDzRI0+WF5h/0EY0bmjjrwxAyIjB83PSZhyUh8yhp ObFnidefaT/VRhNdmjJAXPg+jNrJyy+8X9KOq4qTLtIG842QPV8rbbq0gE5cygwkjzKHM /mhpH+OoDfXIcwGVDXnqw01/7nrOUJEa6Cc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Currently, ArmPkg's implementation of PlatformBootManagerBeforeConsole() iterates over all PCI I/O handles in the database and connects the ones that may produce an instance of the Graphics Output Protocol (GOP) once connected. After that, it enumerates all the GOP instances and adds them to the stdout/stderr console variables so that they will be used for console output. At this point in the boot, the BDS has not dispatched drivers loaded via Driver#### options yet, making Driver#### options unsuitable for loading drivers that are needed to produce GOP consoles. This is unfortunate, since it prevents us from using commodity GFX hardware that ships without AARCH64 option ROMs on AARCH64 hardware and load the driver from the ESP. So let's fix this, by deferring the discovery of PCI backed GOP instances until PlatformBootManagerAfterConsole(). Note that non-PCI GOP instances are still connected in the original spot, so platform framebuffers will still work as before. Also note that the entire dance of connecting PCI root bridges and I/O handles, matching PCI class codes and updating console variables is all encapsulated in EfiBootManagerConnectVideoController(), so let's just call that from PlatformBootManagerAfterConsole(). Signed-off-by: Ard Biesheuvel --- Tested on AMD Overdrive with an AMD Radeon GPU plugged in and the AARCH64 AmdGop.efi driver loaded via Driver0000. ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 81 ++----------------= -- 1 file changed, 7 insertions(+), 74 deletions(-) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Li= brary/PlatformBootManagerLib/PlatformBm.c index e6e788e0f107..7c63a7b98847 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -219,66 +219,6 @@ FilterAndProcess ( } =20 =20 -/** - This FILTER_FUNCTION checks if a handle corresponds to a PCI display dev= ice. -**/ -STATIC -BOOLEAN -EFIAPI -IsPciDisplay ( - IN EFI_HANDLE Handle, - IN CONST CHAR16 *ReportText - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 Pci; - - Status =3D gBS->HandleProtocol (Handle, &gEfiPciIoProtocolGuid, - (VOID**)&PciIo); - if (EFI_ERROR (Status)) { - // - // This is not an error worth reporting. - // - return FALSE; - } - - Status =3D PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0 /* Offset */, - sizeof Pci / sizeof (UINT32), &Pci); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status)= ); - return FALSE; - } - - return IS_PCI_DISPLAY (&Pci); -} - - -/** - This CALLBACK_FUNCTION attempts to connect a handle non-recursively, ask= ing - the matching driver to produce all first-level child handles. -**/ -STATIC -VOID -EFIAPI -Connect ( - IN EFI_HANDLE Handle, - IN CONST CHAR16 *ReportText - ) -{ - EFI_STATUS Status; - - Status =3D gBS->ConnectController ( - Handle, // ControllerHandle - NULL, // DriverImageHandle - NULL, // RemainingDevicePath -- produce all children - FALSE // Recursive - ); - DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE, "%a: %s: %r\n", - __FUNCTION__, ReportText, Status)); -} - - /** This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the handle, and adds it to ConOut and ErrOut. @@ -554,20 +494,6 @@ PlatformBootManagerBeforeConsole ( // EfiBootManagerDispatchDeferredImages (); =20 - // - // Locate the PCI root bridges and make the PCI bus driver connect each, - // non-recursively. This will produce a number of child handles with Pci= Io on - // them. - // - FilterAndProcess (&gEfiPciRootBridgeIoProtocolGuid, NULL, Connect); - - // - // Find all display class PCI devices (using the handles from the previo= us - // step), and connect them non-recursively. This should produce a number= of - // child handles with GOPs on them. - // - FilterAndProcess (&gEfiPciIoProtocolGuid, IsPciDisplay, Connect); - // // Now add the device path of all handles with GOP on them to ConOut and // ErrOut. @@ -674,6 +600,13 @@ PlatformBootManagerAfterConsole ( UINTN PosX; UINTN PosY; =20 + // + // Defer this call to PlatformBootManagerAfterConsole () so that devices + // managed by drivers that were loaded via Driver#### options are covered + // as well. + // + EfiBootManagerConnectVideoController (NULL); + FirmwareVerLength =3D StrLen (PcdGetPtr (PcdFirmwareVersionString)); =20 // --=20 2.20.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 (#53268): https://edk2.groups.io/g/devel/message/53268 Mute This Topic: https://groups.io/mt/69714171/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-