public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [PATCH v4 7/8] MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure
Date: Tue,  6 Feb 2018 16:44:46 +0800	[thread overview]
Message-ID: <1517906687-14916-8-git-send-email-dandan.bi@intel.com> (raw)
In-Reply-To: <1517906687-14916-1-git-send-email-dandan.bi@intel.com>

V3:
a. Remove unused definitions
b. Get records size form the records buffer when getting size action
is triggered.

V2:
Update FirmwarePerformanceSmm to receive the address
of performance records instead of records content.

Receive buffer address of Boot performance records
which are reported by SmmCorePerformanceLib.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../FirmwarePerformanceSmm.c                       | 35 ++++++----------------
 .../FirmwarePerformanceSmm.inf                     |  1 +
 2 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c
index c750331..d4ac849 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c
@@ -38,17 +38,16 @@
 #include <Library/MemoryAllocationLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/SynchronizationLib.h>
 #include <Library/SmmMemLib.h>
 
-#define EXTENSION_RECORD_SIZE     0x1000
+SMM_BOOT_PERFORMANCE_TABLE    *mSmmBootPerformanceTable = NULL;
 
 EFI_SMM_RSC_HANDLER_PROTOCOL  *mRscHandlerProtocol    = NULL;
 UINT64                        mSuspendStartTime       = 0;
 BOOLEAN                       mS3SuspendLockBoxSaved  = FALSE;
 UINT32                        mBootRecordSize = 0;
-UINT32                        mBootRecordMaxSize = 0;
 UINT8                         *mBootRecordBuffer = NULL;
 
 SPIN_LOCK                     mSmmFpdtLock;
 BOOLEAN                       mSmramIsOutOfResource = FALSE;
 
@@ -82,11 +81,10 @@ FpdtStatusCodeListenerSmm (
   )
 {
   EFI_STATUS                           Status;
   UINT64                               CurrentTime;
   EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD  S3SuspendRecord;
-  UINT8                                *NewRecordBuffer;
 
   //
   // Check whether status code is what we are interested in.
   //
   if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) {
@@ -94,36 +92,18 @@ FpdtStatusCodeListenerSmm (
   }
   
   //
   // Collect one or more Boot records in boot time
   //
-  if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) {
+  if (Data != NULL && CompareGuid (&Data->Type, &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) {
     AcquireSpinLock (&mSmmFpdtLock);
-    
-    if (mBootRecordSize + Data->Size > mBootRecordMaxSize) {
-      //
-      // Try to allocate big SMRAM data to store Boot record. 
-      //
-      if (mSmramIsOutOfResource) {
-        ReleaseSpinLock (&mSmmFpdtLock);
-        return EFI_OUT_OF_RESOURCES;
-      }
-      NewRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE, mBootRecordBuffer); 
-      if (NewRecordBuffer == NULL) {
-        ReleaseSpinLock (&mSmmFpdtLock);
-        mSmramIsOutOfResource = TRUE;
-        return EFI_OUT_OF_RESOURCES;
-      }
-      mBootRecordBuffer  = NewRecordBuffer;
-      mBootRecordMaxSize = mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE;
-    }
     //
-    // Save boot record into the temp memory space.
+    // Get the boot performance data.
     //
-    CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size);
-    mBootRecordSize += Data->Size;
-    
+    CopyMem (&mSmmBootPerformanceTable, Data + 1, Data->Size);
+    mBootRecordBuffer = ((UINT8 *) (mSmmBootPerformanceTable)) + sizeof (SMM_BOOT_PERFORMANCE_TABLE);
+
     ReleaseSpinLock (&mSmmFpdtLock);
     return EFI_SUCCESS;
   }
 
   if ((Value != PcdGet32 (PcdProgressCodeS3SuspendStart)) &&
@@ -237,10 +217,13 @@ FpdtSmiHandler (
 
   Status = EFI_SUCCESS;
 
   switch (SmmCommData->Function) {
     case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE :
+      if (mSmmBootPerformanceTable != NULL) {
+        mBootRecordSize = mSmmBootPerformanceTable->Header.Length - sizeof (SMM_BOOT_PERFORMANCE_TABLE);
+      }
       SmmCommData->BootRecordSize = mBootRecordSize;
       break;
 
     case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA :
       Status = EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf
index 724e7bc..cae0111 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf
@@ -58,10 +58,11 @@
 [Guids]
   ## SOMETIMES_PRODUCES   ## UNDEFINED # SaveLockBox
   ## PRODUCES             ## UNDEFINED # SmiHandlerRegister
   ## SOMETIMES_CONSUMES   ## UNDEFINED # StatusCode Data
   gEfiFirmwarePerformanceGuid
+  gEdkiiFpdtExtendedFirmwarePerformanceGuid  ## SOMETIMES_PRODUCES ## UNDEFINED # StatusCode Data
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendStart  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendEnd    ## CONSUMES
 
-- 
1.9.5.msysgit.1



  parent reply	other threads:[~2018-02-06  8:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06  8:44 [PATCH v4 0/8] Update EDKII Performance infrastructure based on ACPI FPDT table Dandan Bi
2018-02-06  8:44 ` [PATCH v4 1/8] MdeModulePkg:Add definitions for new Performance infrastructure Dandan Bi
2018-02-06  8:44 ` [PATCH v4 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase Dandan Bi
2018-02-06  8:44 ` [PATCH v4 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase Dandan Bi
2018-02-06  8:44 ` [PATCH v4 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase Dandan Bi
2018-02-06  8:44 ` [PATCH v4 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase Dandan Bi
2018-02-06  8:44 ` [PATCH v4 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure Dandan Bi
2018-02-06  8:44 ` Dandan Bi [this message]
2018-02-06  8:44 ` [PATCH v4 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table Dandan Bi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517906687-14916-8-git-send-email-dandan.bi@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox