From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.14908.1586362318310276384 for ; Wed, 08 Apr 2020 09:11:58 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) 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 CE39530E; Wed, 8 Apr 2020 09:11:57 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (unknown [10.37.8.121]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 921CC3F52E; Wed, 8 Apr 2020 09:11:56 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Samer.El-Haj-Mahmoud@arm.com, Ard Biesheuvel Subject: [PATCH edk2-platforms 1/2] Silicon/SynQuacer/PlatformDxe: defer device registration until EndOfDxe Date: Wed, 8 Apr 2020 18:11:37 +0200 Message-Id: <20200408161138.18289-2-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408161138.18289-1-ard.biesheuvel@arm.com> References: <20200408161138.18289-1-ard.biesheuvel@arm.com> EDK2 carries an interesting quirk which dates back to the EFI 1.02 days, where each protocol that is installed onto a handle during the execution of a DXE driver's entrypoint is connected immediately (in the UEFI driver model sense) after the entry point returns. This means that, depending on the order that these drivers happen to end up being dispatched, we may enter the BDS phase with the device's driver stack fully connected, even if the device in question is not being used to boot the machine. Given the substantial delays that this might incur, let's work around this 'feature' by deferring the registration of the network and eMMC controllers to an EndOfDxe event handler. Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 37 ++++++++++++++------ Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 1 + 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c index b6e2789cb9d2..09200a918009 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c @@ -301,6 +301,28 @@ InstallAcpiTables ( } } +STATIC +VOID +EFIAPI +RegisterDevices ( + EFI_EVENT Event, + VOID *Context + ) +{ + EFI_HANDLE Handle; + EFI_STATUS Status; + + Handle = NULL; + Status = RegisterDevice (&gNetsecNonDiscoverableDeviceGuid, mNetsecDesc, + &Handle); + ASSERT_EFI_ERROR (Status); + + if (mHiiSettings->EnableEmmc == EMMC_ENABLED) { + Status = RegisterEmmc (); + ASSERT_EFI_ERROR (Status); + } +} + EFI_STATUS EFIAPI PlatformDxeEntryPoint ( @@ -315,6 +337,7 @@ PlatformDxeEntryPoint ( EFI_ACPI_DESCRIPTION_HEADER *Ssdt; UINTN SsdtSize; UINTN Index; + EFI_EVENT EndOfDxeEvent; mHiiSettingsVal = PcdGet64 (PcdPlatformSettings); mHiiSettings = (SYNQUACER_PLATFORM_VARSTORE_DATA *)&mHiiSettingsVal; @@ -344,11 +367,6 @@ PlatformDxeEntryPoint ( } } - Handle = NULL; - Status = RegisterDevice (&gNetsecNonDiscoverableDeviceGuid, mNetsecDesc, - &Handle); - ASSERT_EFI_ERROR (Status); - Handle = NULL; Status = RegisterDevice (&gSynQuacerNonDiscoverableRuntimeI2cMasterGuid, mI2c0Desc, &Handle); @@ -387,11 +405,6 @@ PlatformDxeEntryPoint ( Status = EnableSettingsForm (); ASSERT_EFI_ERROR (Status); - if (mHiiSettings->EnableEmmc == EMMC_ENABLED) { - Status = RegisterEmmc (); - ASSERT_EFI_ERROR (Status); - } - if (mHiiSettings->AcpiPref == ACPIPREF_ACPI) { // // Load the SSDT tables from a raw section in this FFS file. @@ -431,5 +444,9 @@ PlatformDxeEntryPoint ( } } + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RegisterDevices, + NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; } diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf index 57f2d071c14e..157f914ea85d 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf @@ -57,6 +57,7 @@ [LibraryClasses] [Guids] g96BoardsI2c0MasterGuid gEdkiiPlatformHasAcpiGuid + gEfiEndOfDxeEventGroupGuid gEfiHiiPlatformSetupFormsetGuid gFdtTableGuid gNetsecNonDiscoverableDeviceGuid -- 2.17.1