]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NvmExpressPei / NvmExpressPei.c
index bf33b4b9a03b9ff0b35b39c815513102761d3714..2dbf54fd3f0eaca88a0e43369339db7d6596bc43 100644 (file)
@@ -213,6 +213,7 @@ NvmExpressPeimEntry (
   )\r
 {\r
   EFI_STATUS                               Status;\r
+  EFI_BOOT_MODE                            BootMode;\r
   EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI    *NvmeHcPpi;\r
   UINT8                                    Controller;\r
   UINTN                                    MmioBase;\r
@@ -223,6 +224,15 @@ NvmExpressPeimEntry (
 \r
   DEBUG ((DEBUG_INFO, "%a: Enters.\n", __FUNCTION__));\r
 \r
+  //\r
+  // Get the current boot mode.\r
+  //\r
+  Status = PeiServicesGetBootMode (&BootMode);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "%a: Fail to get the current boot mode.\n", __FUNCTION__));\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Locate the NVME host controller PPI\r
   //\r
@@ -279,6 +289,22 @@ NvmExpressPeimEntry (
       continue;\r
     }\r
 \r
+    //\r
+    // For S3 resume performance consideration, not all NVM Express controllers\r
+    // will be initialized. The driver consumes the content within\r
+    // S3StorageDeviceInitList LockBox to see if a controller will be skipped\r
+    // during S3 resume.\r
+    //\r
+    if ((BootMode == BOOT_ON_S3_RESUME) &&\r
+        (NvmeS3SkipThisController (DevicePath, DevicePathLength))) {\r
+      DEBUG ((\r
+        DEBUG_ERROR, "%a: Controller %d is skipped during S3.\n",\r
+        __FUNCTION__, Controller\r
+        ));\r
+      Controller++;\r
+      continue;\r
+    }\r
+\r
     //\r
     // Memory allocation for controller private data\r
     //\r