Re: [edk2] [PATCH v5 07/13] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox
Please add some comments above "if" to explain why the it's only skipped in S3 boot. With the updated comments, Reviewed-by: Ray Ni > +if ((BootMode == BOOT_ON_S3_RESUME) && > +(NvmeS3SkipThisController (DevicePath, DevicePathLength))) { > + DEBUG (( > +DEBUG_ERROR, "%a: Controller %d is skipped during S3.\n", > +__FUNCTION__, Controller > +)); > + Controller++; > + continue; > +} ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v5 07/13] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox
Hi Hao, > -Original Message- > From: Wu, Hao A > Sent: Friday, February 15, 2019 2:24 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Wang, Jian J ; > Ni, Ray ; Dong, Eric > Subject: [PATCH v5 07/13] 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 | 36 +++ > MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c | 53 + > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c | 20 > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 114 > > 5 files changed, 230 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 92c3854c6e..e2a693abe8 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > @@ -267,6 +267,26 @@ NvmePeimEndOfPei ( >); > > /** > + Get the size of the current device path instance. > + > + @param[in] DevicePath A pointer to the > EFI_DEVICE_PATH_PROTOCOL > + structure. > + @param[out] InstanceSize The size of the current device path > instance. > + @param[out] EntireDevicePathEndIndicate whether the instance is the > last > + one in the device path strucure. > + > + @retval EFI_SUCCESSThe size of the current device path instance is > fetched. > + @retval Others Fails to get the size of the current device path > instance. > + > +**/ > +EFI_STATUS > +GetDevicePathInstanceSize ( > + IN EFI_DEVICE_PATH_PROTOCOL*DevicePath, > + OUT UINTN *InstanceSize, > + OUT BOOLEAN *EntireDevicePathEnd > + ); > + > +/** >Check the validity of the device path of a NVM Express host controller. > >@param[in] DevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL > @@ -309,4 +329,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/DevicePath.c > b/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c > index 5dab447f09..ed05d7a2be 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c > @@ -89,6 +89,59 @@ NextDevicePathNode ( > } > > /** > + Get the size of the current device path instance. > + > + @param[in] DevicePath A pointer to the > EFI_DEVICE_PATH_PROTOCOL > + structure. > + @param[out] InstanceSize The size of the current device path > instance. > + @param[out] EntireDevicePathEndIndicate whether the instance is the > last > +
[edk2] [PATCH v5 07/13] 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 | 36 +++ MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c | 53 + MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c | 20 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 114 5 files changed, 230 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 92c3854c6e..e2a693abe8 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h @@ -267,6 +267,26 @@ NvmePeimEndOfPei ( ); /** + Get the size of the current device path instance. + + @param[in] DevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL + structure. + @param[out] InstanceSize The size of the current device path instance. + @param[out] EntireDevicePathEndIndicate whether the instance is the last + one in the device path strucure. + + @retval EFI_SUCCESSThe size of the current device path instance is fetched. + @retval Others Fails to get the size of the current device path instance. + +**/ +EFI_STATUS +GetDevicePathInstanceSize ( + IN EFI_DEVICE_PATH_PROTOCOL*DevicePath, + OUT UINTN *InstanceSize, + OUT BOOLEAN *EntireDevicePathEnd + ); + +/** Check the validity of the device path of a NVM Express host controller. @param[in] DevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL @@ -309,4 +329,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/DevicePath.c b/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c index 5dab447f09..ed05d7a2be 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c @@ -89,6 +89,59 @@ NextDevicePathNode ( } /** + Get the size of the current device path instance. + + @param[in] DevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL + structure. + @param[out] InstanceSize The size of the current device path instance. + @param[out] EntireDevicePathEndIndicate whether the instance is the last + one in the device path strucure. + + @retval EFI_SUCCESSThe size of the current device path instance is fetched. + @retval Others Fails to get the size of the current device path instance. + +**/ +EFI_STATUS +GetDevicePathInstanceSize ( + IN EFI_DEVICE_PATH_PROTOCOL*DevicePath, + OUT UINTN *InstanceSize, + OUT BOOLEAN *EntireDevicePathEnd + ) +{ + EFI_DEVICE_PATH_PROTOCOL*Walker; + + if (DevicePath == NULL || InstanceSize == NULL