@@ -4739,7 +4739,6 @@ DebugWriteSpiImageToFile(
47394739 EFI_FILE_HANDLE FileHandle = NULL ;
47404740 CHAR16 * FileNameFconfig = NULL ;
47414741
4742-
47434742 FileHandle = NULL ;
47444743 FileNameFconfig = CatSPrint (NULL , L"new_spi_w_merged_fconfig_0x%04x.bin" , DimmHandle );
47454744
@@ -4844,6 +4843,7 @@ RecoverDimmFw(
48444843 * pNvmStatus = NVM_ERR_SPD_NOT_ACCESSIBLE ;
48454844 goto Finish ;
48464845 }
4846+
48474847 if (DeviceId != SPD_DEVICE_ID_DCPM_GEN1 ) {
48484848 NVDIMM_ERR ("Incompatible hardware revision 0x%x" , DeviceId );
48494849 * pNvmStatus = NVM_ERR_INCOMPATIBLE_HARDWARE_REVISION ;
@@ -4889,8 +4889,7 @@ RecoverDimmFw(
48894889 // dimm back to a good state after testing.
48904890 // TODO: Needed for validation only! We do not need this after product PRQ and will
48914891 // probably confuse people
4892- CHECK_RESULT (DebugWriteSpiImageToFile (pWorkingDirectory , pCurrentDimm -> DeviceHandle .AsUint32 ,
4893- pNewSpiImageBuffer , ImageBufferSize ), Finish );
4892+ DebugWriteSpiImageToFile (pWorkingDirectory , pCurrentDimm -> DeviceHandle .AsUint32 , pNewSpiImageBuffer , ImageBufferSize );
48944893 ///////////////////////////////////////////////////
48954894
48964895 CHECK_RESULT (SpiEraseChip (pCurrentDimm , pCommandStatus ), Finish );
@@ -4957,6 +4956,8 @@ UpdateFw(
49574956 UINTN TempBuffSize = 0 ;
49584957 NVM_STATUS NvmStatus = NVM_ERR_OPERATION_NOT_STARTED ;
49594958 BOOLEAN ValidImage = TRUE;
4959+ BOOLEAN * pDimmsCanBeRecovered = NULL ;
4960+ UINT32 DimmsToRecover = 0 ;
49604961
49614962 ZeroMem (pDimms , sizeof (pDimms ));
49624963
@@ -5008,6 +5009,14 @@ UpdateFw(
50085009 goto Finish ;
50095010 }
50105011
5012+ if (pFwImageInfo != NULL ) {
5013+ pFwImageInfo -> Date = pFileHeader -> Date ;
5014+ pFwImageInfo -> ImageVersion = pFileHeader -> ImageVersion ;
5015+ pFwImageInfo -> FirmwareType = pFileHeader -> ImageType ;
5016+ pFwImageInfo -> ModuleVendor = pFileHeader -> ModuleVendor ;
5017+ pFwImageInfo -> Size = pFileHeader -> Size ;
5018+ }
5019+
50115020 TempReturnCode = OpenFile (pFileName , & FileHandle , pWorkingDirectory , FALSE);
50125021 TempReturnCode = GetFileSize (FileHandle , & BuffSize );
50135022
@@ -5030,10 +5039,14 @@ UpdateFw(
50305039 }
50315040
50325041 // don't update, just get image information
5033- if (pFwImageInfo == NULL ) {
5042+ if (TRUE == Examine ) {
50345043 goto Finish ;
50355044 }
5045+
5046+ pDimmsCanBeRecovered = AllocatePool (sizeof (BOOLEAN ) * DimmsNum );
5047+
50365048 for (Index = 0 ; Index < DimmsNum ; Index ++ ) {
5049+ pDimmsCanBeRecovered [Index ] = FALSE;
50375050 if (Recovery && FlashSPI ) {
50385051 // We will only be able to flash spi if we can access the
50395052 // spi interface over smbus
@@ -5046,6 +5059,8 @@ UpdateFw(
50465059 if (EFI_ERROR (TempReturnCode )) {
50475060 SetObjStatusForDimm (pCommandStatus , pDimms [Index ], NVM_ERR_RECOVERY_ACCESS_NOT_ENABLED );
50485061 } else {
5062+ pDimmsCanBeRecovered [Index ] = TRUE;
5063+ DimmsToRecover ++ ;
50495064 SetObjStatusForDimm (pCommandStatus , pDimms [Index ], NVM_SUCCESS_IMAGE_EXAMINE_OK );
50505065 }
50515066 } else {
@@ -5065,21 +5080,27 @@ UpdateFw(
50655080 }
50665081 }
50675082 } else {
5083+ pDimmsCanBeRecovered [Index ] = TRUE;
5084+ DimmsToRecover ++ ;
50685085 SetObjStatusForDimm (pCommandStatus , pDimms [Index ], NVM_SUCCESS_IMAGE_EXAMINE_OK );
50695086 }
50705087 }
50715088 }
50725089
5073- pFwImageInfo -> Date = pFileHeader -> Date ;
5074- pFwImageInfo -> ImageVersion = pFileHeader -> ImageVersion ;
5075- pFwImageInfo -> FirmwareType = pFileHeader -> ImageType ;
5076- pFwImageInfo -> ModuleVendor = pFileHeader -> ModuleVendor ;
5077- pFwImageInfo -> Size = pFileHeader -> Size ;
5090+ if ( DimmsToRecover == 0 ) {
5091+ Print ( L"There are no DIMMs which can be updated\n" ) ;
5092+ ResetCmdStatus ( pCommandStatus , NVM_ERR_GENERAL_DEV_FAILURE ) ;
5093+ goto Finish ;
5094+ }
50785095
50795096 ReturnCode = EFI_SUCCESS ;
50805097 if (!Examine && ValidImage ) {
50815098 // upload FW image to all specified DIMMs
50825099 for (Index = 0 ; Index < DimmsNum ; Index ++ ) {
5100+ if (pDimmsCanBeRecovered [Index ] == FALSE) {
5101+ continue ;
5102+ }
5103+
50835104 if (Recovery && FlashSPI ) {
50845105 ReturnCode = RecoverDimmFw (pDimms [Index ]-> DeviceHandle .AsUint32 ,
50855106 pImageBuffer , BuffSize , pWorkingDirectory , & NvmStatus , pCommandStatus );
@@ -5089,8 +5110,21 @@ UpdateFw(
50895110 ReturnCode = UpdateDimmFw (pDimms [Index ]-> DimmID , pImageBuffer , BuffSize , Force , & NvmStatus );
50905111 }
50915112
5092- SetObjStatusForDimm (pCommandStatus , pDimms [Index ], NvmStatus );
5113+ if (EFI_ERROR (ReturnCode )) {
5114+ if (NvmStatus == NVM_SUCCESS ) {
5115+ SetObjStatusForDimm (pCommandStatus , pDimms [Index ], NVM_ERR_OPERATION_FAILED );
5116+ }
5117+ else
5118+ {
5119+ SetObjStatusForDimm (pCommandStatus , pDimms [Index ], NvmStatus );
5120+ }
5121+ }
5122+ else
5123+ {
5124+ SetObjStatusForDimm (pCommandStatus , pDimms [Index ], NvmStatus );
5125+ }
50935126 }
5127+
50945128 SetCmdStatus (pCommandStatus , NVM_SUCCESS );
50955129 }
50965130
@@ -5101,6 +5135,7 @@ UpdateFw(
51015135 FREE_POOL_SAFE (pFileHeader );
51025136 FREE_POOL_SAFE (pImageBuffer );
51035137 FREE_POOL_SAFE (pErrorMessage );
5138+ FREE_POOL_SAFE (pDimmsCanBeRecovered );
51045139 NVDIMM_EXIT_I64 (ReturnCode );
51055140 return ReturnCode ;
51065141}
0 commit comments