From 4be1e20c81e2eabc72c36c190a6de543932c8e8d Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 8 Apr 2020 10:12:11 +0200 Subject: Silicon/SynQuacer/PlatformDxe: defer device registration until EndOfDxe 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 Reviewed-by: Leif Lindholm --- .../SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 37 ++++++++++++++++------ .../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 b6e2789c..09200a91 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 57f2d071..157f914e 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf @@ -57,6 +57,7 @@ [Guids] g96BoardsI2c0MasterGuid gEdkiiPlatformHasAcpiGuid + gEfiEndOfDxeEventGroupGuid gEfiHiiPlatformSetupFormsetGuid gFdtTableGuid gNetsecNonDiscoverableDeviceGuid -- cgit v1.2.3