From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=bGnJJFZc; spf=pass (domain: linaro.org, ip: 209.85.128.65, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wm1-f65.google.com with SMTP id p17so17195182wma.1 for ; Wed, 15 Jan 2020 02:22:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wHPE6oDk2uk793vMactgArw23DgwNOpCAhWoc/xqo8k=; b=bGnJJFZc2faQKrdbwGgpPVkkmLzLg71W/ZXfMFHEKj6YRBqTQyFhITkTaJDFXodKsc r0ntLMx/oJ4RrNCMTHZzVDTFu1nMc45+xkiPVLekrWmzq5cl65OvOK9xGxU0w3GDnyjs myujkZUJ1zVEdBzKTa89Fu+V+BYW2fKu0cJTMQTox6/fO5gzo5zSqdst2EdxAtx8t0lS 2HFQbkzhyDKtNMfNeFsP9N+9M1fYFP0LtBwyCJ1tqTiIK7FDgiv1PEsJyGa8W6Q6H81/ jwqUGpM2RTW8WoKgkNKO/zMCKb7ZvIgPG2m7z/vX+3tflAHvyHLdDFH4frMDzxbe6i/y xttg== 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:mime-version :content-transfer-encoding; bh=wHPE6oDk2uk793vMactgArw23DgwNOpCAhWoc/xqo8k=; b=gZj7dGTlvMvaYY1MZxHxkt5BOpXlNkv4PDFZmbcEIpdGrx1QN3RgIjguWZBikdFLVD oLsLsPhmzCeqFy4/Yl8FzchLgc51wyW4V0vQ579tCbq0yMFpaF6ZNR90IDlNEhOVk54e AOL7LV2vC0+GpPRO7LzFyVdluIhYQl3G9nQ6q+xlwAec6U388TDQQGfZtxPtCyBZzyy/ 4SbGj9qxISrYmKK02WasP6/Hc4hrWpxjBx68baAPJETOaz/X0P9oVXNwQfN8r6dB2Uec kcUwT5FhkAyktoa5g5LSO0oUs56j/MLXj6957Ubs+3OIouWfWLtAsHBtEZJ3YhXZXLtN caBg== X-Gm-Message-State: APjAAAWLsv1+g37S/VS/kxlwK7UflBX/NOe/kKVXmOIPiNlNBZip5yCb mZemAz0i1zrgGh1N81G1gzMzCQIKWJJlRQ== 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) Return-Path: 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: [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> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/Library/PlatformBootManagerLib/PlatformBm.c index e6e788e0f107..7c63a7b98847 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -219,66 +219,6 @@ FilterAndProcess ( } -/** - This FILTER_FUNCTION checks if a handle corresponds to a PCI display device. -**/ -STATIC -BOOLEAN -EFIAPI -IsPciDisplay ( - IN EFI_HANDLE Handle, - IN CONST CHAR16 *ReportText - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 Pci; - - Status = gBS->HandleProtocol (Handle, &gEfiPciIoProtocolGuid, - (VOID**)&PciIo); - if (EFI_ERROR (Status)) { - // - // This is not an error worth reporting. - // - return FALSE; - } - - Status = 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, asking - 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 = 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 (); - // - // Locate the PCI root bridges and make the PCI bus driver connect each, - // non-recursively. This will produce a number of child handles with PciIo on - // them. - // - FilterAndProcess (&gEfiPciRootBridgeIoProtocolGuid, NULL, Connect); - - // - // Find all display class PCI devices (using the handles from the previous - // 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; + // + // Defer this call to PlatformBootManagerAfterConsole () so that devices + // managed by drivers that were loaded via Driver#### options are covered + // as well. + // + EfiBootManagerConnectVideoController (NULL); + FirmwareVerLength = StrLen (PcdGetPtr (PcdFirmwareVersionString)); // -- 2.20.1