Re: [edk2] [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox
> -Original Message- > From: Ni, Ray > Sent: Thursday, January 31, 2019 11:45 AM > To: Wu, Hao A; edk2-devel@lists.01.org > Cc: Wang, Jian J; Dong, Eric > Subject: RE: [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume > S3StorageDeviceInitList LockBox > > > > > -Original Message- > > From: Wu, Hao A > > Sent: Thursday, January 31, 2019 10:49 AM > > To: edk2-devel@lists.01.org > > Cc: Wu, Hao A ; Wang, Jian J ; > > Ni, Ray ; Dong, Eric > > Subject: [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume > > S3StorageDeviceInitList LockBox > > > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > > > For the NvmExpressPei driver, this commit will update the driver to consume > > the S3StorageDeviceInitList LockBox in S3 phase. The purpose is to perform > > an on-demand (partial) NVM Express device enumeration/initialization to > > benefit the S3 resume performance. > > > > Cc: Jian J Wang > > Cc: Ray Ni > > Cc: Eric Dong > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Hao Wu > > --- > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf | 8 +- > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h | 16 +++ > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c | 20 > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 106 > > > > 4 files changed, 149 insertions(+), 1 deletion(-) > > > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > index 0666e5892b..22b703e971 100644 > > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > @@ -40,6 +40,7 @@ > >NvmExpressPeiHci.h > >NvmExpressPeiPassThru.c > >NvmExpressPeiPassThru.h > > + NvmExpressPeiS3.c > >NvmExpressPeiStorageSecurity.c > >NvmExpressPeiStorageSecurity.h > > > > @@ -54,6 +55,7 @@ > >BaseMemoryLib > >IoLib > >TimerLib > > + LockBoxLib > >PeimEntryPoint > > > > [Ppis] > > @@ -64,9 +66,13 @@ > >gEfiPeiVirtualBlockIo2PpiGuid ## SOMETIMES_PRODUCES > >gEdkiiPeiStorageSecurityCommandPpiGuid ## SOMETIMES_PRODUCES > > > > +[Guids] > > + gS3StorageDeviceInitListGuid ## SOMETIMES_CONSUMES ## > > UNDEFINED > > + > > [Depex] > >gEfiPeiMemoryDiscoveredPpiGuid AND > > - gEdkiiPeiNvmExpressHostControllerPpiGuid > > + gEdkiiPeiNvmExpressHostControllerPpiGuid AND > > + gEfiPeiMasterBootModePpiGuid > > > > [UserExtensions.TianoCore."ExtraFiles"] > >NvmExpressPeiExtra.uni > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > index 7047c4f3ff..6f01413e6d 100644 > > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > @@ -332,4 +332,20 @@ NvmeBuildDevicePath ( > >OUT EFI_DEVICE_PATH_PROTOCOL**DevicePath > >); > > > > +/** > > + Determine if a specific NVM Express controller can be skipped for S3 > > phase. > > + > > + @param[in] HcDevicePath Device path of the controller. > > + @param[in] HcDevicePathLengthLength of the device path specified by > > +HcDevicePath. > > + > > + @retvalThe number of ports that need to be enumerated. > > + > > +**/ > > +BOOLEAN > > +NvmeS3SkipThisController ( > > + IN EFI_DEVICE_PATH_PROTOCOL*HcDevicePath, > > + IN UINTN HcDevicePathLength > > + ); > > + > > #endif > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c > > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c > > index 96622e6fd5..43b2dfc3e7 100644 > > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c > > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c > > @@ -213,6 +213,7 @@ NvmExpressPeimEntry ( > >) > > { > >EFI_STATUS Status; > > + EFI_BOOT_MODEBootMode; > >EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI*NvmeHcPpi; > >UINT8Controller; > >UINTNMmioBase; > > @@ -224,6 +225,15 @@ NvmExpressPeimEntry ( > >DEBUG ((DEBUG_INFO, "%a: Enters.\n", __FUNCTION__)); > > > >// > > + // Get the current boot mode. > > + // > > + Status = PeiServicesGetBootMode (); if (EFI_ERROR (Status)) > > + { > > +DEBUG ((DEBUG_ERROR, "%a: Fail to get the current boot mode.\n", > > __FUNCTION__)); > > +return Status; > > + } > > + > > + // > >// Locate the NVME host controller PPI > >// > >Status = PeiServicesLocatePpi ( > > @@ -279,6 +289,16 @@ NvmExpressPeimEntry ( > >continue; > > } > > > > +if ((BootMode == BOOT_ON_S3_RESUME) && > > +(NvmeS3SkipThisController (DevicePath, DevicePathLength))) { > > + DEBUG (( > > +DEBUG_ERROR, "%a: Controller %d is
Re: [edk2] [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox
> -Original Message- > From: Wu, Hao A > Sent: Thursday, January 31, 2019 10:49 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Wang, Jian J ; > Ni, Ray ; Dong, Eric > Subject: [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume > S3StorageDeviceInitList LockBox > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > For the NvmExpressPei driver, this commit will update the driver to consume > the S3StorageDeviceInitList LockBox in S3 phase. The purpose is to perform > an on-demand (partial) NVM Express device enumeration/initialization to > benefit the S3 resume performance. > > Cc: Jian J Wang > Cc: Ray Ni > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > --- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf | 8 +- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h | 16 +++ > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c | 20 > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 106 > > 4 files changed, 149 insertions(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > index 0666e5892b..22b703e971 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > @@ -40,6 +40,7 @@ >NvmExpressPeiHci.h >NvmExpressPeiPassThru.c >NvmExpressPeiPassThru.h > + NvmExpressPeiS3.c >NvmExpressPeiStorageSecurity.c >NvmExpressPeiStorageSecurity.h > > @@ -54,6 +55,7 @@ >BaseMemoryLib >IoLib >TimerLib > + LockBoxLib >PeimEntryPoint > > [Ppis] > @@ -64,9 +66,13 @@ >gEfiPeiVirtualBlockIo2PpiGuid ## SOMETIMES_PRODUCES >gEdkiiPeiStorageSecurityCommandPpiGuid ## SOMETIMES_PRODUCES > > +[Guids] > + gS3StorageDeviceInitListGuid ## SOMETIMES_CONSUMES ## > UNDEFINED > + > [Depex] >gEfiPeiMemoryDiscoveredPpiGuid AND > - gEdkiiPeiNvmExpressHostControllerPpiGuid > + gEdkiiPeiNvmExpressHostControllerPpiGuid AND > + gEfiPeiMasterBootModePpiGuid > > [UserExtensions.TianoCore."ExtraFiles"] >NvmExpressPeiExtra.uni > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > index 7047c4f3ff..6f01413e6d 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > @@ -332,4 +332,20 @@ NvmeBuildDevicePath ( >OUT EFI_DEVICE_PATH_PROTOCOL**DevicePath >); > > +/** > + Determine if a specific NVM Express controller can be skipped for S3 phase. > + > + @param[in] HcDevicePath Device path of the controller. > + @param[in] HcDevicePathLengthLength of the device path specified by > +HcDevicePath. > + > + @retvalThe number of ports that need to be enumerated. > + > +**/ > +BOOLEAN > +NvmeS3SkipThisController ( > + IN EFI_DEVICE_PATH_PROTOCOL*HcDevicePath, > + IN UINTN HcDevicePathLength > + ); > + > #endif > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c > index 96622e6fd5..43b2dfc3e7 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c > @@ -213,6 +213,7 @@ NvmExpressPeimEntry ( >) > { >EFI_STATUS Status; > + EFI_BOOT_MODEBootMode; >EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI*NvmeHcPpi; >UINT8Controller; >UINTNMmioBase; > @@ -224,6 +225,15 @@ NvmExpressPeimEntry ( >DEBUG ((DEBUG_INFO, "%a: Enters.\n", __FUNCTION__)); > >// > + // Get the current boot mode. > + // > + Status = PeiServicesGetBootMode (); if (EFI_ERROR (Status)) > + { > +DEBUG ((DEBUG_ERROR, "%a: Fail to get the current boot mode.\n", > __FUNCTION__)); > +return Status; > + } > + > + // >// Locate the NVME host controller PPI >// >Status = PeiServicesLocatePpi ( > @@ -279,6 +289,16 @@ NvmExpressPeimEntry ( >continue; > } > > +if ((BootMode == BOOT_ON_S3_RESUME) && > +(NvmeS3SkipThisController (DevicePath, DevicePathLength))) { > + DEBUG (( > +DEBUG_ERROR, "%a: Controller %d is skipped during S3.\n", > +__FUNCTION__, Controller > +)); > + Controller++; > + continue; > +} > + > // > // Memory allocation for controller private data > // > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c > new file mode 100644 > index 00..afcf5f6c0a > --- /dev/null > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c > @@ -0,0 +1,106 @@ > +/** @file > + The NvmExpressPei driver
[edk2] [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 For the NvmExpressPei driver, this commit will update the driver to consume the S3StorageDeviceInitList LockBox in S3 phase. The purpose is to perform an on-demand (partial) NVM Express device enumeration/initialization to benefit the S3 resume performance. Cc: Jian J Wang Cc: Ray Ni Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu --- MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf | 8 +- MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h | 16 +++ MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c | 20 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 106 4 files changed, 149 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf index 0666e5892b..22b703e971 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf @@ -40,6 +40,7 @@ NvmExpressPeiHci.h NvmExpressPeiPassThru.c NvmExpressPeiPassThru.h + NvmExpressPeiS3.c NvmExpressPeiStorageSecurity.c NvmExpressPeiStorageSecurity.h @@ -54,6 +55,7 @@ BaseMemoryLib IoLib TimerLib + LockBoxLib PeimEntryPoint [Ppis] @@ -64,9 +66,13 @@ gEfiPeiVirtualBlockIo2PpiGuid ## SOMETIMES_PRODUCES gEdkiiPeiStorageSecurityCommandPpiGuid ## SOMETIMES_PRODUCES +[Guids] + gS3StorageDeviceInitListGuid ## SOMETIMES_CONSUMES ## UNDEFINED + [Depex] gEfiPeiMemoryDiscoveredPpiGuid AND - gEdkiiPeiNvmExpressHostControllerPpiGuid + gEdkiiPeiNvmExpressHostControllerPpiGuid AND + gEfiPeiMasterBootModePpiGuid [UserExtensions.TianoCore."ExtraFiles"] NvmExpressPeiExtra.uni diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h index 7047c4f3ff..6f01413e6d 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h @@ -332,4 +332,20 @@ NvmeBuildDevicePath ( OUT EFI_DEVICE_PATH_PROTOCOL**DevicePath ); +/** + Determine if a specific NVM Express controller can be skipped for S3 phase. + + @param[in] HcDevicePath Device path of the controller. + @param[in] HcDevicePathLengthLength of the device path specified by +HcDevicePath. + + @retvalThe number of ports that need to be enumerated. + +**/ +BOOLEAN +NvmeS3SkipThisController ( + IN EFI_DEVICE_PATH_PROTOCOL*HcDevicePath, + IN UINTN HcDevicePathLength + ); + #endif diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c index 96622e6fd5..43b2dfc3e7 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c @@ -213,6 +213,7 @@ NvmExpressPeimEntry ( ) { EFI_STATUS Status; + EFI_BOOT_MODEBootMode; EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI*NvmeHcPpi; UINT8Controller; UINTNMmioBase; @@ -224,6 +225,15 @@ NvmExpressPeimEntry ( DEBUG ((DEBUG_INFO, "%a: Enters.\n", __FUNCTION__)); // + // Get the current boot mode. + // + Status = PeiServicesGetBootMode (); + if (EFI_ERROR (Status)) { +DEBUG ((DEBUG_ERROR, "%a: Fail to get the current boot mode.\n", __FUNCTION__)); +return Status; + } + + // // Locate the NVME host controller PPI // Status = PeiServicesLocatePpi ( @@ -279,6 +289,16 @@ NvmExpressPeimEntry ( continue; } +if ((BootMode == BOOT_ON_S3_RESUME) && +(NvmeS3SkipThisController (DevicePath, DevicePathLength))) { + DEBUG (( +DEBUG_ERROR, "%a: Controller %d is skipped during S3.\n", +__FUNCTION__, Controller +)); + Controller++; + continue; +} + // // Memory allocation for controller private data // diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c new file mode 100644 index 00..afcf5f6c0a --- /dev/null +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c @@ -0,0 +1,106 @@ +/** @file + The NvmExpressPei driver is used to manage non-volatile memory subsystem + which follows NVM Express specification at PEI phase. + + Copyright (c) 2019, Intel Corporation. All rights reserved. + + This program and the accompanying materials + are licensed and made available under the terms and conditions + of the BSD License which accompanies this distribution. The + full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR