Reviewed-by: Liming Gao <liming....@intel.com>

-----Original Message-----
From: Zeng, Star 
Sent: Wednesday, June 03, 2015 6:26 PM
To: edk2-devel@lists.sourceforge.net
Cc: Gao, Liming
Subject: [PATCH] MdeModulePkg DxeSmmPerformanceLib: Cover no SMM performance 
data case.

1. Continue to get performance data by Performance Protocol when no SMM 
performance data found.
2. Not try to get SMM performance data again if no SMM performance handler 
found.
3. Correct typo 'totol' and 'guage' typo.

Cc: Liming Gao <liming....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.z...@intel.com>
---
 .../DxeSmmPerformanceLib/DxeSmmPerformanceLib.c    | 47 ++++++++++++++++++----
 1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c 
b/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
index 3c69cee..3c7cfc1 100644
--- a/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
+++ b/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
@@ -41,6 +41,9 @@ UINTN                           mGaugeNumberOfEntries = 0;
 GAUGE_DATA_ENTRY_EX             *mGaugeDataEx = NULL;
 UINTN                           mGaugeNumberOfEntriesEx = 0;
 
+BOOLEAN                         mNoSmmPerfHandler = FALSE;
+BOOLEAN                         mNoSmmPerfExHandler = FALSE;
+
 //
 // The cached Performance Protocol and PerformanceEx Protocol interface.
 //
@@ -372,7 +375,7 @@ GetByPerformanceProtocol (
                                   On exit, the key of the next performance log 
entry.
 
   @retval !NULL           Get all gauge data success.
-  @retval NULL            Get all guage data failed.
+  @retval NULL            Get all gauge data failed.
 **/
 GAUGE_DATA_ENTRY *
 EFIAPI
@@ -386,13 +389,21 @@ GetAllSmmGaugeData (
   UINTN                       CommSize;
   UINTN                       DataSize;
 
+  if (mNoSmmPerfHandler) {
+    //
+    // Not try to get the SMM gauge data again
+    // if no SMM Performance handler found.
+    //
+    return NULL;
+  }
+
   if (LogEntryKey != 0) {
     if (mGaugeData != NULL) {
       return mGaugeData;
     }
   } else {
     //
-    // Reget the SMM guage data at the first entry get.
+    // Reget the SMM gauge data at the first entry get.
     //
     if (mGaugeData != NULL) {
       FreePool (mGaugeData);
@@ -418,10 +429,13 @@ GetAllSmmGaugeData (
   CommSize = SMM_PERFORMANCE_COMMUNICATION_BUFFER_SIZE;
 
   //
-  // Get totol number of SMM gauge entries
+  // Get total number of SMM gauge entries
   //
   SmmPerfCommData->Function = SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER;
   Status = mSmmCommunication->Communicate (mSmmCommunication, 
mSmmPerformanceBuffer, &CommSize);
+  if (Status == EFI_NOT_FOUND) {
+    mNoSmmPerfHandler = TRUE;
+  }
   if (EFI_ERROR (Status) || EFI_ERROR (SmmPerfCommData->ReturnStatus) || 
SmmPerfCommData->NumberOfEntries == 0) {
     return NULL;
   }
@@ -459,7 +473,7 @@ GetAllSmmGaugeData (
                                   On exit, the key of the next performance log 
entry.
 
   @retval !NULL           Get all gauge data success.
-  @retval NULL            Get all guage data failed.
+  @retval NULL            Get all gauge data failed.
 **/
 GAUGE_DATA_ENTRY_EX *
 EFIAPI
@@ -473,13 +487,21 @@ GetAllSmmGaugeDataEx (
   UINTN                       CommSize;
   UINTN                       DataSize;
 
+  if (mNoSmmPerfExHandler) {
+    //
+    // Not try to get the SMM gauge data again
+    // if no SMM PerformanceEx handler found.
+    //
+    return NULL;
+  }
+
   if (LogEntryKey != 0) {
     if (mGaugeDataEx != NULL) {
       return mGaugeDataEx;
     }
   } else {
     //
-    // Reget the SMM guage data at the first entry get.
+    // Reget the SMM gauge data at the first entry get.
     //
     if (mGaugeDataEx != NULL) {
       FreePool (mGaugeDataEx);
@@ -505,10 +527,13 @@ GetAllSmmGaugeDataEx (
   CommSize = SMM_PERFORMANCE_COMMUNICATION_BUFFER_SIZE;
 
   //
-  // Get totol number of SMM gauge entries
+  // Get total number of SMM gauge entries
   //
   SmmPerfCommData->Function = SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER;
   Status = mSmmCommunication->Communicate (mSmmCommunication, 
mSmmPerformanceBuffer, &CommSize);
+  if (Status == EFI_NOT_FOUND) {
+    mNoSmmPerfExHandler = TRUE;
+  }
   if (EFI_ERROR (Status) || EFI_ERROR (SmmPerfCommData->ReturnStatus) || 
SmmPerfCommData->NumberOfEntries == 0) {
     return NULL;
   }
@@ -658,7 +683,15 @@ GetPerformanceMeasurementEx (
       GaugeData = (GAUGE_DATA_ENTRY_EX *) &mGaugeData[LogEntryKey++];
       *Identifier = 0;
     } else {
-      return 0;
+      return GetByPerformanceProtocol (
+               LogEntryKey,
+               Handle,
+               Token,
+               Module,
+               StartTimeStamp,
+               EndTimeStamp,
+               Identifier
+               );
     }
   }
 
--
1.9.5.msysgit.0


------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to