On 23 August 2018 at 17:07, Ming Huang <ming.huang@linaro.org> wrote:
>
> This patch is relative to D06 SasDxe driver. The SasDxe set a
> variable to notice this libray. Here Wait for all disk ready
> for 15S at most.
>
> D06:
> For using straight-through hard disk backboard, some disk need
> 15 seconds to ready. Actually, wait less 15 seconds here(minus
> the time from end of SAS driver to here).
> For using expander backboard, wait less 6 seconds here(minus
> the time from end of SAS driver to here).
>
> D03/D05:
> As Sas driver don't install PLATFORM_SAS_NOTIFY Protocol, D03/D05
> will skip waiting here.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ming Huang <ming.huang@linaro.org>
> ---
>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  4 +++
>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c               | 37 ++++++++++++++++++++
>  2 files changed, 41 insertions(+)
>
> diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> index 7a53befc44..415f8ee36e 100644
> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> @@ -36,6 +36,7 @@
>  [Packages]
>    MdeModulePkg/MdeModulePkg.dec
>    MdePkg/MdePkg.dec
> +  Silicon/Hisilicon/HisiliconNonOsi.dec
>    Silicon/Hisilicon/HisiPkg.dec
>
>  [LibraryClasses]
> @@ -49,6 +50,7 @@
>    MemoryAllocationLib
>    PcdLib
>    PrintLib
> +  TimerLib
>    UefiBootManagerLib
>    UefiBootServicesTableLib
>    UefiLib
> @@ -67,8 +69,10 @@
>  [Guids]
>    gEfiEndOfDxeEventGroupGuid
>    gEfiTtyTermGuid
> +  gOemConfigGuid

This patch still adds a dependency on this guid, but it is not introduced until 14/31, so it breaks the build at 10,11,12,13/31.
Also, it is not required for this patch. So introduce it only with the code that first uses it.

/
    Leif

>
>  [Protocols]
>    gEfiGenericMemTestProtocolGuid
>    gEfiLoadedImageProtocolGuid
>    gEsrtManagementProtocolGuid
> +  gPlatformSasNotifyProtocolGuid
> diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
> index aa6db929ca..77295d0111 100644
> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -20,6 +20,7 @@
>  #include <Library/BmcConfigBootLib.h>
>  #include <Library/DevicePathLib.h>
>  #include <Library/PcdLib.h>
> +#include <Library/TimerLib.h>
>  #include <Library/UefiBootManagerLib.h>
>  #include <Library/UefiLib.h>
>  #include <Protocol/DevicePath.h>
> @@ -29,6 +30,7 @@
>  #include <Protocol/LoadedImage.h>
>  #include <Protocol/PciIo.h>
>  #include <Protocol/PciRootBridgeIo.h>
> +#include <Protocol/PlatformSasNotify.h>
>  #include <Guid/EventGroup.h>
>  #include <Guid/TtyTerm.h>
>
> @@ -554,6 +556,40 @@ PlatformBootManagerBeforeConsole (
>    PlatformRegisterOptionsAndKeys ();
>  }
>
> +STATIC
> +VOID
> +WaitForDiskReady (
> +  VOID
> +  )
> +{
> +  EFI_STATUS                Status;
> +  UINT32                    Index;
> +  PLATFORM_SAS_NOTIFY       *SasNotify;
> +
> +  Status = gBS->LocateProtocol (
> +                  &gPlatformSasNotifyProtocolGuid,
> +                  NULL,
> +                  (VOID **)&SasNotify);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_INFO, "Locate SasPlatformNotify:%r\n", Status));
> +    return;
> +  }
> +
> +  // Wait for 30 seconds at most.
> +  for (Index = 0; Index < 30; Index++) {
> +    Status = gBS->CheckEvent (SasNotify->WaitDiskEvent);
> +    if (!EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_INFO, "WaitDiskEvent is signaled.\n"));
> +      EfiBootManagerConnectAll ();
> +      break;
> +    }
> +    DEBUG ((DEBUG_ERROR, "%a", Index == 0 ? "Wait for disk." : "."));
> +    MicroSecondDelay (1000 * 1000);
> +  }
> +
> +  return;
> +}
> +
>  /**
>    Do the platform specific action after the console is ready
>    Possible things that can be done in PlatformBootManagerAfterConsole:
> @@ -583,6 +619,7 @@ PlatformBootManagerAfterConsole (
>    // Connect the rest of the devices.
>    //
>    EfiBootManagerConnectAll ();
> +  WaitForDiskReady ();
>
>    //
>    // Enumerate all possible boot options.
> --
> 2.18.0
>