diff mbox series

[edk2,edk2-platforms,v5,09/28] Silicon/Hisilicon/D06: Wait for all disk ready

Message ID 20180831132710.23055-10-ming.huang@linaro.org
State New
Headers show
Series Upload for D06 platform | expand

Commit Message

Ming Huang Aug. 31, 2018, 1:26 p.m. UTC
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 |  3 ++
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c               | 37 ++++++++++++++++++++
 2 files changed, 40 insertions(+)

-- 
2.18.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 7a53befc44..e9d649b0eb 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
@@ -72,3 +74,4 @@ 
   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.