Skip to content

Commit

Permalink
Minor changes for caching PCD
Browse files Browse the repository at this point in the history
Signed-off-by: Swetha Venkatachari Sundarajan <[email protected]>
Signed-off-by: Juston Li <[email protected]>
  • Loading branch information
swetha-intel authored and Juston Li committed Aug 27, 2018
1 parent 247ea32 commit 50b544e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
Binary file modified DcpmPkg/common/NvmStatus.uni
Binary file not shown.
Binary file modified DcpmPkg/driver/Core/Diagnostics/DiagnosticsMessages.uni
Binary file not shown.
42 changes: 31 additions & 11 deletions DcpmPkg/driver/Core/Dimm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1880,17 +1880,29 @@ FwCmdGetPlatformConfigData(
PcdSize = pDimm->PcdOemPartitionSize;
} else if (PartitionId == PCD_LSA_PARTITION_ID) {
PcdSize = pDimm->PcdLsaPartitionSize;
} else {
Rc = EFI_UNSUPPORTED;
goto Finish;
}

/*
* PcdSize is 0 if Media is disabled.
* PcdSize was retrieved at driver load time so it is possible that since load time there
* was a fatal media error that this would not catch. We would then be returning cached data
* from a media disabled DIMM instead of erroring out. This case is purposefully ignored.
*/
* PcdSize is 0 if Media is disabled.
* PcdSize was retrieved at driver load time so it is possible that since load time there
* was a fatal media error that this would not catch. We would then be returning cached data
* from a media disabled DIMM instead of erroring out.
* It could also be possbile that FW was busy during driver load time, so disable the cache.
*/
if (PcdSize == 0) {
Rc = EFI_NO_MEDIA;
goto Finish;
gPCDCacheEnabled = 0;
Rc = FwCmdGetPlatformConfigDataSize(pDimm, PartitionId, &PcdSize);
if (EFI_ERROR(Rc) || PcdSize == 0) {
NVDIMM_DBG("FW CMD Error: %d", Rc);
goto Finish;
} else if (PartitionId == PCD_OEM_PARTITION_ID){
pDimm->PcdOemPartitionSize = PcdSize;
} else if (PartitionId == PCD_LSA_PARTITION_ID) {
pDimm->PcdLsaPartitionSize = PcdSize;
}
}

*ppRawData = AllocateZeroPool(PcdSize);
Expand Down Expand Up @@ -1954,6 +1966,9 @@ FwCmdGetPlatformConfigData(
}
CopyMem_S(pBuffer + Offset, PcdSize - Offset, pFwCmd->OutPayload, PCD_GET_SMALL_PAYLOAD_DATA_SIZE);
}
#ifdef OS_BUILD
gPCDCacheEnabled = 1;
#endif
} else {
/** Get PCD by large payload in single call **/
pFwCmd->LargeOutputPayloadSize = PcdSize;
Expand All @@ -1975,6 +1990,9 @@ FwCmdGetPlatformConfigData(
}
goto Finish;
}
#ifdef OS_BUILD
gPCDCacheEnabled = 1;
#endif
}

if (gPCDCacheEnabled) {
Expand All @@ -1985,8 +2003,7 @@ FwCmdGetPlatformConfigData(
pDimm->pPcdLsa = AllocateZeroPool(pDimm->PcdLsaPartitionSize);
pTempCache = pDimm->pPcdLsa;
pTempCacheSz = pDimm->PcdLsaPartitionSize;
}
else if (PartitionId == PCD_OEM_PARTITION_ID) {
} else if (PartitionId == PCD_OEM_PARTITION_ID) {
pDimm->pPcdOem = AllocateZeroPool(pDimm->PcdOemPartitionSize);
pTempCache = pDimm->pPcdOem;
pTempCacheSz = pDimm->PcdOemPartitionSize;
Expand Down Expand Up @@ -2229,10 +2246,11 @@ FwCmdGetPcdSmallPayload(


/*
* PcdSize is 0 if Media is disabled.
* PcdSize is 0 if Media is disabled or FW is busy.
* PcdSize was retrieved at driver load time so it is possible that since load time there
* was a fatal media error that this would not catch. We would then be returning cached data
* from a media disabled DIMM instead of erroring out. This case is purposefully ignored.
* from a media disabled DIMM instead of erroring out.
* It could also be possbile that FW was busy during driver load time, so disable the cache.
*/
if (gPCDCacheEnabled && pDimm->PcdOemPartitionSize == 0) {
gPCDCacheEnabled = 0;
Expand Down Expand Up @@ -2353,13 +2371,15 @@ GetPcdOemConfigDataUsingSmallPayload(

// Get size of OEM Config Data
UINT32 OemDataSize = 0;
/*Instead of making one more Passthru call to get the PCD size, get it from the OemHeader*/
Rc = GetPcdOemDataSize(pOemHeader, &OemDataSize);
if (EFI_ERROR(Rc)) {
goto Finish;
}

// Ensure buffer size is rounded up to next PCD_GET_SMALL_PAYLOAD_DATA_SIZE boundary
UINT32 BufferSize = ((OemDataSize / PCD_GET_SMALL_PAYLOAD_DATA_SIZE) + 1) * PCD_GET_SMALL_PAYLOAD_DATA_SIZE;
pDimm->PcdOemPartitionSize = OemDataSize;
pBuffer = AllocateZeroPool(BufferSize);
if (pBuffer == NULL) {
NVDIMM_ERR("Can't allocate memory for PCD partition buffer (%d bytes)", BufferSize);
Expand Down

0 comments on commit 50b544e

Please sign in to comment.