[PATCH] MdeModulePkg PCD: Reinstall PCD service PPIS when memory available


Dandan Bi
 

Hi Greg,

I have added all the R-B for this patch and create a pull request for it.
https://github.com/tianocore/edk2/pull/1898



Thanks,
Dandan

-----Original Message-----
From: Yeh, GregX <gregx.yeh@intel.com>
Sent: Thursday, August 12, 2021 3:22 PM
To: devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
Bi, Dandan <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH] MdeModulePkg PCD: Reinstall PCD service PPIS when
memory available

https://bugzilla.tianocore.org/show_bug.cgi?id=3525

After PciSegmentLib using Dynamic PCD for Pcie base address such long delay
found in FSP. The root cause is some of the PCD service PPIs not shadowed
to memory and flash cache may have been disabled in NotifyPhase stage.
Solution is to shadow all PCD service PPIs to memory.

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
---
MdeModulePkg/Universal/PCD/Pei/Pcd.c | 71
+++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
index 9c6346924f..f31e0be35f 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
@@ -1,7 +1,7 @@
/** @file All Pcd Ppi services are implemented here. -Copyright (c) 2006 -
2018, Intel Corporation. All rights reserved.<BR>+Copyright (c) 2006 - 2021,
Intel Corporation. All rights reserved.<BR> (C) Copyright 2016 Hewlett
Packard Enterprise Development LP<BR> SPDX-License-Identifier: BSD-2-
Clause-Patent @@ -339,6 +339,75 @@ PcdPeimInit (
{ EFI_STATUS Status; + Status = PeiServicesRegisterForShadow
(FileHandle);+ if (Status == EFI_ALREADY_STARTED) {+ //+ // This is now
starting in memory, the second time starting.+ //+
EFI_PEI_PPI_DESCRIPTOR *OldPpiList;+ EFI_PEI_PPI_DESCRIPTOR
*OldPpiList2;+ VOID *Ppi;+ VOID *Ppi2;++ OldPpiList = NULL;+ Status =
PeiServicesLocatePpi (+ &gPcdPpiGuid,+ 0,+
&OldPpiList,+ &Ppi+ );+ ASSERT_EFI_ERROR (Status);++ if
(OldPpiList != NULL) {+ Status = PeiServicesReInstallPpi (OldPpiList,
&mPpiList[0]);+ ASSERT_EFI_ERROR (Status);+ }++ OldPpiList2 = NULL;+
Status = PeiServicesLocatePpi (+ &gGetPcdInfoPpiGuid,+ 0,+
&OldPpiList2,+ &Ppi2+ );+ ASSERT_EFI_ERROR (Status);++ if
(OldPpiList2 != NULL) {+ Status = PeiServicesReInstallPpi (OldPpiList2,
&mPpiList2[0]);+ ASSERT_EFI_ERROR (Status);+ }++ OldPpiList = NULL;+
Status = PeiServicesLocatePpi (+ &gEfiPeiPcdPpiGuid,+ 0,+
&OldPpiList,+ &Ppi+ );+ ASSERT_EFI_ERROR (Status);++ if
(OldPpiList != NULL) {+ Status = PeiServicesReInstallPpi (OldPpiList,
&mPpiList[1]);+ ASSERT_EFI_ERROR (Status);+ }++ OldPpiList2 = NULL;+
Status = PeiServicesLocatePpi (+ &gEfiGetPcdInfoPpiGuid,+ 0,+
&OldPpiList2,+ &Ppi2+ );+ ASSERT_EFI_ERROR (Status);++ if
(OldPpiList2 != NULL) {+ Status = PeiServicesReInstallPpi (OldPpiList2,
&mPpiList2[1]);+ ASSERT_EFI_ERROR (Status);+ }++ return Status;+ }+
BuildPcdDatabase (FileHandle); //--
2.32.0.windows.1


GregX Yeh
 

https://bugzilla.tianocore.org/show_bug.cgi?id=3D3525

After PciSegmentLib using Dynamic PCD for Pcie base address such
long delay found in FSP. The root cause is some of the PCD service
PPIs not shadowed to memory and flash cache may have been disabled
in NotifyPhase stage. Solution is to shadow all PCD service PPIs
to memory.

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
---
MdeModulePkg/Universal/PCD/Pei/Pcd.c | 71 +++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c b/MdeModulePkg/Universal/=
PCD/Pei/Pcd.c
index 9c6346924f..f31e0be35f 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
@@ -1,7 +1,7 @@
/** @file=0D
All Pcd Ppi services are implemented here.=0D
=0D
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>=0D
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
@@ -339,6 +339,75 @@ PcdPeimInit (
{=0D
EFI_STATUS Status;=0D
=0D
+ Status =3D PeiServicesRegisterForShadow (FileHandle);=0D
+ if (Status =3D=3D EFI_ALREADY_STARTED) {=0D
+ //=0D
+ // This is now starting in memory, the second time starting.=0D
+ //=0D
+ EFI_PEI_PPI_DESCRIPTOR *OldPpiList;=0D
+ EFI_PEI_PPI_DESCRIPTOR *OldPpiList2;=0D
+ VOID *Ppi;=0D
+ VOID *Ppi2;=0D
+=0D
+ OldPpiList =3D NULL;=0D
+ Status =3D PeiServicesLocatePpi (=0D
+ &gPcdPpiGuid,=0D
+ 0,=0D
+ &OldPpiList,=0D
+ &Ppi=0D
+ );=0D
+ ASSERT_EFI_ERROR (Status);=0D
+=0D
+ if (OldPpiList !=3D NULL) {=0D
+ Status =3D PeiServicesReInstallPpi (OldPpiList, &mPpiList[0]);=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ }=0D
+=0D
+ OldPpiList2 =3D NULL;=0D
+ Status =3D PeiServicesLocatePpi (=0D
+ &gGetPcdInfoPpiGuid,=0D
+ 0,=0D
+ &OldPpiList2,=0D
+ &Ppi2=0D
+ );=0D
+ ASSERT_EFI_ERROR (Status);=0D
+=0D
+ if (OldPpiList2 !=3D NULL) {=0D
+ Status =3D PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[0]);=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ }=0D
+=0D
+ OldPpiList =3D NULL;=0D
+ Status =3D PeiServicesLocatePpi (=0D
+ &gEfiPeiPcdPpiGuid,=0D
+ 0,=0D
+ &OldPpiList,=0D
+ &Ppi=0D
+ );=0D
+ ASSERT_EFI_ERROR (Status);=0D
+=0D
+ if (OldPpiList !=3D NULL) {=0D
+ Status =3D PeiServicesReInstallPpi (OldPpiList, &mPpiList[1]);=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ }=0D
+=0D
+ OldPpiList2 =3D NULL;=0D
+ Status =3D PeiServicesLocatePpi (=0D
+ &gEfiGetPcdInfoPpiGuid,=0D
+ 0,=0D
+ &OldPpiList2,=0D
+ &Ppi2=0D
+ );=0D
+ ASSERT_EFI_ERROR (Status);=0D
+=0D
+ if (OldPpiList2 !=3D NULL) {=0D
+ Status =3D PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[1]);=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ }=0D
+=0D
+ return Status;=0D
+ }=0D
+=0D
BuildPcdDatabase (FileHandle);=0D
=0D
//=0D
--=20
2.32.0.windows.1