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.web10.29782.1618218393228429718 for ; Mon, 12 Apr 2021 02:06:33 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: sunny.wang@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 DADDA1FB; Mon, 12 Apr 2021 02:06:31 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F3F343F694; Mon, 12 Apr 2021 02:06:29 -0700 (PDT) From: "Sunny Wang" To: devel@edk2.groups.io Cc: Sunny Wang , Samer El-Haj-Mahmoud , Jeremy Linton , Pete Batard , Ard Biesheuvel , Sunny Wang Subject: [PATCH 1/1] Platform/RaspberryPi: Setup option for disabling Fast Boot Date: Mon, 12 Apr 2021 17:05:45 +0800 Message-Id: <20210412090545.2130-1-Sunny.Wang@arm.com> X-Mailer: git-send-email 2.31.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable This is a fix for https://github.com/pftf/RPi4/issues/114. Changes: 1. Add a setup option called Boot Policy and consume the setting during boot to whether perform or skip ConnectAll. 2. The Default setting is set to Full discovery because it is not worth enabling Fast boot by default on RaspberryPi systems. Enabling it just saves boot time about 1 second, but caused a lot of issues. Testing Done: - Booted to Standalone UEFI shell on SD card and use drivers command to check the result with Fast Boot and Full discovery settings. Then, child/device handles are created as expected. Note and to-do items: - The root cause looks like that boot loaders and some tools like grub and iPXE haven't supported selective connect/Fast boot. However, system firmware should still provide a setup option for user to enable Fast boot with old version boot loaders and tools , which is why we proposed this change. We will also report this issue to boot loader and tool vendors/open source GitHubs. - We Will add more options for connecting specific type devices so that we can still have the shortest boot time for all use cases. Cc: Samer El-Haj-Mahmoud Cc: Jeremy Linton Cc: Pete Batard Cc: Ard Biesheuvel Signed-off-by: Sunny Wang --- .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 11 ++++++++++- .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 3 ++- .../Drivers/ConfigDxe/ConfigDxeHii.uni | 10 +++++++++- .../Drivers/ConfigDxe/ConfigDxeHii.vfr | 15 ++++++++++++++- Platform/RaspberryPi/Include/ConfigVars.h | 12 +++++++++++- .../Library/PlatformBootManagerLib/PlatformBm.c | 16 ++++++++++++++-- .../PlatformBootManagerLib.inf | 1 + Platform/RaspberryPi/RPi3/RPi3.dsc | 10 +++++++++- Platform/RaspberryPi/RPi4/RPi4.dsc | 9 ++++++++- Platform/RaspberryPi/RaspberryPi.dec | 2 ++ 10 files changed, 80 insertions(+), 9 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 22f86d4d44..d3c5869949 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -1,6 +1,6 @@ /** @file=0D *=0D - * Copyright (c) 2019 - 2020, ARM Limited. All rights reserved.=0D + * Copyright (c) 2019 - 2021, ARM Limited. All rights reserved.=0D * Copyright (c) 2018 - 2020, Andrei Warkentin =0D *=0D * SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -281,6 +281,15 @@ SetupVariables ( );=0D }=0D =0D + Size =3D sizeof (UINT32);=0D + Status =3D gRT->GetVariable (L"BootPolicy",=0D + &gConfigDxeFormSetGuid,=0D + NULL, &Size, &Var32);=0D + if (EFI_ERROR (Status)) {=0D + Status =3D PcdSet32S (PcdBootPolicy, PcdGet32 (PcdBootPolicy));=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D +=0D Size =3D sizeof (UINT32);=0D Status =3D gRT->GetVariable (L"SdIsArasan",=0D &gConfigDxeFormSetGuid,=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platfor= m/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index d51e54e010..032e40b0c3 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -2,7 +2,7 @@ #=0D # Component description file for the RasbperryPi DXE platform config driv= er.=0D #=0D -# Copyright (c) 2019 - 2020, ARM Limited. All rights reserved.=0D +# Copyright (c) 2019 - 2021, ARM Limited. All rights reserved.=0D # Copyright (c) 2018 - 2020, Andrei Warkentin =0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -93,6 +93,7 @@ gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB=0D gRaspberryPiTokenSpaceGuid.PcdFanOnGpio=0D gRaspberryPiTokenSpaceGuid.PcdFanTemp=0D + gRaspberryPiTokenSpaceGuid.PcdBootPolicy=0D =0D [Depex]=0D gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni index 466fa852cb..7b14fdf39f 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -1,7 +1,7 @@ /** @file=0D *=0D * Copyright (c) 2018, Andrei Warkentin =0D - * Copyright (c) 2020, ARM Limited. All rights reserved.=0D + * Copyright (c) 2020 - 2021, ARM Limited. All rights reserved.=0D *=0D * SPDX-License-Identifier: BSD-2-Clause-Patent=0D *=0D @@ -60,6 +60,14 @@ #string STR_ADVANCED_ASSET_TAG_PROMPT #language en-US "Asset Tag"=0D #string STR_ADVANCED_ASSET_TAG_HELP #language en-US "Set the system Asse= t Tag"=0D =0D +#string STR_BOOT_POLICY_PROMPT #language en-US "Boot Policy"=0D +#string STR_BOOT_POLICY_HELP #language en-US "When Fast Boot is s= elected, only required devices will be discoverd for reducing "=0D + "the boot time."=0D + "When Full Discovery= is selected, all the devices will be discoverd for some "=0D + "scenarios such as s= ystem deployement and diagnostic tests"=0D +#string STR_FAST_BOOT #language en-US "Fast Boot"=0D +#string STR_FULL_DISCOVERY #language en-US "Full Discovery"=0D +=0D /*=0D * MMC/SD configuration.=0D */=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index cc7a09cfb7..5dc558ec08 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -1,7 +1,7 @@ /** @file=0D *=0D * Copyright (c) 2018 Andrei Warkentin =0D - * Copyright (c) 2020, ARM Limited. All rights reserved.=0D + * Copyright (c) 2020 - 2021, ARM Limited. All rights reserved.=0D *=0D * SPDX-License-Identifier: BSD-2-Clause-Patent=0D *=0D @@ -116,6 +116,11 @@ formset name =3D DisplayEnableSShot,=0D guid =3D CONFIGDXE_FORM_SET_GUID;=0D =0D + efivarstore BOOT_POLICY_VARSTORE_DATA,=0D + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE,=0D + name =3D BootPolicy,=0D + guid =3D CONFIGDXE_FORM_SET_GUID;=0D +=0D form formid =3D 1,=0D title =3D STRING_TOKEN(STR_FORM_SET_TITLE);=0D subtitle text =3D STRING_TOKEN(STR_NULL_STRING);=0D @@ -220,6 +225,14 @@ formset minsize =3D 0,=0D maxsize =3D ASSET_TAG_STR_MAX_LEN,=0D endstring;=0D +=0D + oneof varid =3D BootPolicy.BootPolicy,=0D + prompt =3D STRING_TOKEN(STR_BOOT_POLICY_PROMPT),=0D + help =3D STRING_TOKEN(STR_BOOT_POLICY_HELP),=0D + flags =3D NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,= =0D + option text =3D STRING_TOKEN(STR_FAST_BOOT ), value =3D FAST_B= OOT , flags =3D 0;=0D + option text =3D STRING_TOKEN(STR_FULL_DISCOVERY), value =3D FU= LL_DISCOVERY, flags =3D DEFAULT;=0D + endoneof;=0D endform;=0D =0D form formid =3D 0x1003,=0D diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/Raspberry= Pi/Include/ConfigVars.h index 142317985a..3347f899df 100644 --- a/Platform/RaspberryPi/Include/ConfigVars.h +++ b/Platform/RaspberryPi/Include/ConfigVars.h @@ -1,7 +1,7 @@ /** @file=0D *=0D * Copyright (c) 2020, Andrei Warkentin =0D - * Copyright (c) 2020, ARM Limited. All rights reserved.=0D + * Copyright (c) 2020 - 2021, ARM Limited. All rights reserved.=0D *=0D * SPDX-License-Identifier: BSD-2-Clause-Patent=0D *=0D @@ -143,4 +143,14 @@ typedef struct { UINT32 EnableDma;=0D } MMC_EMMC_DMA_VARSTORE_DATA;=0D =0D +#define FAST_BOOT 0=0D +#define FULL_DISCOVERY 1=0D +typedef struct {=0D + /*=0D + * 0 - Fast Boot=0D + * 1 - Full Discovrey (Connect All)=0D + */=0D + UINT32 BootPolicy;=0D +} BOOT_POLICY_VARSTORE_DATA;=0D +=0D #endif /* CONFIG_VARS_H */=0D diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm= .c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c index c2fc40b8ea..abbe4fb3d0 100644 --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c @@ -4,7 +4,7 @@ * Copyright (c) 2017-2018, Andrei Warkentin = =0D * Copyright (c) 2016, Linaro Ltd. All rights reserved.=0D * Copyright (c) 2015-2016, Red Hat, Inc.=0D - * Copyright (c) 2014-2020, ARM Ltd. All rights reserved.=0D + * Copyright (c) 2014-2021, ARM Ltd. All rights reserved.=0D * Copyright (c) 2004-2016, Intel Corporation. All rights reserved.=0D *=0D * SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -26,9 +26,11 @@ #include =0D #include =0D =0D +#include =0D +=0D #include "PlatformBm.h"=0D =0D -#define BOOT_PROMPT L"ESC (setup), F1 (shell), ENTER (boot)"=0D +#define BOOT_PROMPT L"ESC (setup), F1 (shell), ENTER (boot)\n"=0D =0D #define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >>= 8) }=0D =0D @@ -633,6 +635,16 @@ PlatformBootManagerAfterConsole ( Print (BOOT_PROMPT);=0D }=0D =0D + //=0D + // Connect the rest of the devices if the boot polcy is set to Full disc= overy=0D + //=0D + if (PcdGet32 (PcdBootPolicy) =3D=3D FULL_DISCOVERY) {=0D + DEBUG ((DEBUG_INFO, "Boot Policy is Full Discovery. Connect All device= s\n"));=0D + EfiBootManagerConnectAll ();=0D + } else if (PcdGet32 (PcdBootPolicy) =3D=3D FAST_BOOT) {=0D + DEBUG ((DEBUG_INFO, "Boot Policy is Fast Boot. Skip connecting all dev= ices\n"));=0D + }=0D +=0D Status =3D gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, (VOI= D**)&EsrtManagement);=0D if (!EFI_ERROR (Status)) {=0D EsrtManagement->SyncEsrtFmp ();=0D diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBo= otManagerLib.inf b/Platform/RaspberryPi/Library/PlatformBootManagerLib/Plat= formBootManagerLib.inf index 88f6f8fe09..fbf510ab96 100644 --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManag= erLib.inf +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManag= erLib.inf @@ -63,6 +63,7 @@ [Pcd]=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut=0D gRaspberryPiTokenSpaceGuid.PcdSdIsArasan=0D + gRaspberryPiTokenSpaceGuid.PcdBootPolicy=0D =0D [Guids]=0D gEfiFileInfoGuid=0D diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index 0961133ae9..ddb03e405f 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -1,6 +1,6 @@ # @file=0D #=0D -# Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.=0D +# Copyright (c) 2011 - 2021, ARM Limited. All rights reserved.=0D # Copyright (c) 2014, Linaro Limited. All rights reserved.=0D # Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.=0D # Copyright (c) 2017 - 2018, Andrei Warkentin =0D @@ -512,6 +512,14 @@ gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGu= id|0x0|0=0D gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormSetGuid|0= x0|0=0D =0D + #=0D + # Boot Policy=0D + # 0 - Fast Boot=0D + # 1 - Full Discovrey (Connect All)=0D + #=0D + gRaspberryPiTokenSpaceGuid.PcdBootPolicy|L"BootPolicy"|gConfigDxeFormSet= Guid|0x0|1=0D +=0D +=0D #=0D # Reset-related.=0D #=0D diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index ff802d8347..8ee1922a44 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -1,6 +1,6 @@ # @file=0D #=0D -# Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.=0D +# Copyright (c) 2011 - 2021, ARM Limited. All rights reserved.=0D # Copyright (c) 2017 - 2018, Andrei Warkentin =0D # Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.=0D # Copyright (c) 2014, Linaro Limited. All rights reserved.=0D @@ -528,6 +528,13 @@ gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGu= id|0x0|0=0D gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormSetGuid|0= x0|60=0D =0D + #=0D + # Boot Policy=0D + # 0 - Fast Boot=0D + # 1 - Full Discovrey (Connect All)=0D + #=0D + gRaspberryPiTokenSpaceGuid.PcdBootPolicy|L"BootPolicy"|gConfigDxeFormSet= Guid|0x0|1=0D +=0D #=0D # Reset-related.=0D #=0D diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/Ra= spberryPi.dec index 08135717ed..8eb1c2bac7 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -2,6 +2,7 @@ #=0D # Copyright (c) 2016, Linaro, Ltd. All rights reserved.=0D # Copyright (c) 2017-2018, Andrei Warkentin = =0D +# Copyright (c) 2021, ARM Limited. All rights reserved.=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -70,3 +71,4 @@ gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x0000001D=0D gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|0|UINT32|0x0000001E=0D gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F=0D + gRaspberryPiTokenSpaceGuid.PcdBootPolicy|0|UINT32|0x00000020=0D --=20 2.31.0.windows.1