X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FStatusCode%2FDxe%2FDataHubStatusCodeWorker.c;fp=IntelFrameworkModulePkg%2FUniversal%2FStatusCode%2FDxe%2FDataHubStatusCodeWorker.c;h=c14dfc8d33c2d0b4239bffd22e8cdb1810234f69;hp=70f41e9923e4e2d41a402f8e8b9d8cc980a169c1;hb=df809f3d34b15185ed4c1d264116ab6448c38dbf;hpb=8edf7e980a26115a65711e587c3ddac5d84e354e diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c index 70f41e9923..c14dfc8d33 100644 --- a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c +++ b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c @@ -22,6 +22,8 @@ LIST_ENTRY mRecordsFifo = INITIALIZE_LIST_HEAD_VARIABLE STATIC LIST_ENTRY mRecordsBuffer = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer); STATIC +UINT32 mLogDataHubStatus = 0; +STATIC EFI_EVENT mLogDataHubEvent; // // Cache data hub protocol. @@ -59,6 +61,9 @@ AcquireRecordBuffer ( Record = _CR (Node, DATAHUB_STATUSCODE_RECORD, Node); } else { if (CurrentTpl > TPL_NOTIFY) { + // + // Memory management should work at <=TPL_NOTIFY + // gBS->RestoreTPL (CurrentTpl); return NULL; } @@ -108,10 +113,9 @@ RetrieveRecord ( if (!IsListEmpty (&mRecordsFifo)) { Node = GetFirstNode (&mRecordsFifo); Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE); + ASSERT (NULL != Record); RemoveEntryList (&Record->Node); - InsertTailList (&mRecordsBuffer, &Record->Node); - Record->Signature = 0; RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data; } @@ -120,6 +124,34 @@ RetrieveRecord ( return RecordData; } +/** + Release Records to FIFO. + + @param RecordData Point to the record buffer allocated + from AcquireRecordBuffer. + +**/ +STATIC +VOID +ReleaseRecord ( + DATA_HUB_STATUS_CODE_DATA_RECORD *RecordData + ) +{ + DATAHUB_STATUSCODE_RECORD *Record; + EFI_TPL CurrentTpl; + + Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE); + ASSERT (NULL != Record); + + CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); + + InsertTailList (&mRecordsBuffer, &Record->Node); + Record->Signature = 0; + + gBS->RestoreTPL (CurrentTpl); +} + + /** Report status code into DataHub. @@ -166,6 +198,15 @@ DataHubStatusCodeReportWorker ( CHAR8 *Format; UINTN CharCount; + + // + // Use atom operation to avoid the reentant of report. + // If current status is not zero, then the function is reentrancy. + // + if (1 == InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 0)) { + return EFI_DEVICE_ERROR; + } + // // See whether in runtime phase or not. // @@ -245,6 +286,14 @@ LogDataHubEventCallBack ( UINT32 Size; UINT64 DataRecordClass; + // + // Use atom operation to avoid the reentant of report. + // If current status is not zero, then the function is reentrancy. + // + if (1 == InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 1)) { + return; + } + // // Log DataRecord in Data Hub. // Journal records fifo to find all record entry. @@ -288,7 +337,13 @@ LogDataHubEventCallBack ( Size ); + ReleaseRecord (Record); } + + // + // Restore the nest status of report + // + InterlockedCompareExchange32 (&mLogDataHubStatus, 1, 0); }