public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm@linaro.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: edk2-devel@lists.01.org, star.zeng@intel.com,
	jiewen.yao@intel.com, michael.d.kinney@intel.com
Subject: Re: [PATCH v3 3/4] ArmPkg/PlatformBootManagerLib: call ProcessCapsules() only once
Date: Tue, 12 Jun 2018 13:25:25 +0100	[thread overview]
Message-ID: <20180612122525.qys3u5rpnlpm2ttn@bivouac.eciton.net> (raw)
In-Reply-To: <20180612112329.664-4-ard.biesheuvel@linaro.org>

On Tue, Jun 12, 2018 at 01:23:28PM +0200, Ard Biesheuvel wrote:
> ARM platforms have no restriction on when a system firmware update
> capsule can be applied, and so it is not necessary to call
> ProcessCapsules() twice. So let's drop the first invocation that
> occurs before EndOfDxe, and rewrite the second call so that all
> capsule updates will be applied when the console is up and able to
> provide progress feedback.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

I thought I acked this one last time around? Perhaps you wanted it
again after the discussion. Anyway:
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

> ---
>  ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c               | 87 ++++++++++++++------
>  ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  1 +
>  2 files changed, 61 insertions(+), 27 deletions(-)
> 
> diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
> index 3456a71fbb9c..7c21cce5960b 100644
> --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -24,6 +24,7 @@
>  #include <Library/PcdLib.h>
>  #include <Library/UefiBootManagerLib.h>
>  #include <Library/UefiLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
>  #include <Protocol/DevicePath.h>
>  #include <Protocol/EsrtManagement.h>
>  #include <Protocol/GraphicsOutput.h>
> @@ -553,21 +554,6 @@ PlatformBootManagerBeforeConsole (
>    VOID
>    )
>  {
> -  EFI_STATUS                    Status;
> -  ESRT_MANAGEMENT_PROTOCOL      *EsrtManagement;
> -
> -  if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) {
> -    DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n"));
> -    Status = ProcessCapsules ();
> -    DEBUG ((DEBUG_INFO, "ProcessCapsules returned %r\n", Status));
> -  } else {
> -    Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,
> -                    (VOID **)&EsrtManagement);
> -    if (!EFI_ERROR (Status)) {
> -      EsrtManagement->SyncEsrtFmp ();
> -    }
> -  }
> -
>    //
>    // Signal EndOfDxe PI Event
>    //
> @@ -618,6 +604,57 @@ PlatformBootManagerBeforeConsole (
>    PlatformRegisterOptionsAndKeys ();
>  }
>  
> +STATIC
> +VOID
> +HandleCapsules (
> +  VOID
> +  )
> +{
> +  ESRT_MANAGEMENT_PROTOCOL    *EsrtManagement;
> +  EFI_PEI_HOB_POINTERS        HobPointer;
> +  EFI_CAPSULE_HEADER          *CapsuleHeader;
> +  BOOLEAN                     NeedReset;
> +  EFI_STATUS                  Status;
> +
> +  DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__));
> +
> +  Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,
> +                  (VOID **)&EsrtManagement);
> +  if (!EFI_ERROR (Status)) {
> +    EsrtManagement->SyncEsrtFmp ();
> +  }
> +
> +  //
> +  // Find all capsule images from hob
> +  //
> +  HobPointer.Raw = GetHobList ();
> +  NeedReset = FALSE;
> +  while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE,
> +                             HobPointer.Raw)) != NULL) {
> +    CapsuleHeader = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress;
> +
> +    Status = ProcessCapsuleImage (CapsuleHeader);
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_ERROR, "%a: failed to process capsule %p - %r\n",
> +        __FUNCTION__, CapsuleHeader, Status));
> +      return;
> +    }
> +    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_INITIATE_RESET) != 0) {
> +      NeedReset = TRUE;
> +    }
> +    HobPointer.Raw = GET_NEXT_HOB (HobPointer);
> +  }
> +
> +  if (NeedReset) {
> +      DEBUG ((DEBUG_WARN, "%a: capsule update successful, resetting ...\n",
> +        __FUNCTION__));
> +
> +      gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
> +      CpuDeadLoop();
> +  }
> +}
> +
> +
>  #define VERSION_STRING_PREFIX    L"Tianocore/EDK2 firmware version "
>  
>  /**
> @@ -637,7 +674,6 @@ PlatformBootManagerAfterConsole (
>    VOID
>    )
>  {
> -  ESRT_MANAGEMENT_PROTOCOL      *EsrtManagement;
>    EFI_STATUS                    Status;
>    EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
>    UINTN                         FirmwareVerLength;
> @@ -675,17 +711,14 @@ PlatformBootManagerAfterConsole (
>    //
>    EfiBootManagerConnectAll ();
>  
> -  Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,
> -                  (VOID **)&EsrtManagement);
> -  if (!EFI_ERROR (Status)) {
> -    EsrtManagement->SyncEsrtFmp ();
> -  }
> -
> -  if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) {
> -    DEBUG((DEBUG_INFO, "ProcessCapsules After EndOfDxe ......\n"));
> -    Status = ProcessCapsules ();
> -    DEBUG((DEBUG_INFO, "ProcessCapsules returned %r\n", Status));
> -  }
> +  //
> +  // On ARM, there is currently no reason to use the phased capsule
> +  // update approach where some capsules are dispatched before EndOfDxe
> +  // and some are dispatched after. So just handle all capsules here,
> +  // when the console is up and we can actually give the user some
> +  // feedback about what is going on.
> +  //
> +  HandleCapsules ();
>  
>    //
>    // Enumerate all possible boot options.
> diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> index e8cbb10dabdd..28d606d5c329 100644
> --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> @@ -55,6 +55,7 @@ [LibraryClasses]
>    UefiBootManagerLib
>    UefiBootServicesTableLib
>    UefiLib
> +  UefiRuntimeServicesTableLib
>  
>  [FeaturePcd]
>    gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
> -- 
> 2.17.1
> 


  reply	other threads:[~2018-06-12 12:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 11:23 [PATCH v3 0/4] MdeModulePkg ArmPkg: support for persistent capsules and progress reporting Ard Biesheuvel
2018-06-12 11:23 ` [PATCH v3 1/4] MdeModulePkg/CapsuleRuntimeDxe: clean the capsule payload to DRAM Ard Biesheuvel
2018-06-12 15:23   ` Yao, Jiewen
2018-06-12 15:24     ` Ard Biesheuvel
2018-06-12 16:27       ` Yao, Jiewen
2018-06-12 11:23 ` [PATCH v3 2/4] MdeModulePkg/DxeCapsuleLibFmp: pass progress callback only if it works Ard Biesheuvel
2018-06-12 11:23 ` [PATCH v3 3/4] ArmPkg/PlatformBootManagerLib: call ProcessCapsules() only once Ard Biesheuvel
2018-06-12 12:25   ` Leif Lindholm [this message]
2018-06-12 12:26     ` Ard Biesheuvel
2018-06-12 11:23 ` [PATCH v3 4/4] ArmPkg/ArmSmcPsciResetSystemLib: implement fallback for warm reboot Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180612122525.qys3u5rpnlpm2ttn@bivouac.eciton.net \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox