Skip to content

Commit

Permalink
Add multiple error handling to BPM update procedure
Browse files Browse the repository at this point in the history
There are a few function in bpm_update.C that can fail multiple times
due to attempts to recover the BPM and/or the update procedure. This
commit adds a helper function that will link errors together and commit
the extra ones right away.

Change-Id: I24bb0eb7d24ec96c49a16165349d6dd6230bae87
RTC:212447
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/81772
Reviewed-by: Christian R Geddes <crgeddes@us.ibm.com>
Reviewed-by: Roland Veloz <rveloz@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
  • Loading branch information
MRaybuck authored and dcrowell77 committed Aug 9, 2019
1 parent 3dc2377 commit 3c440fe
Showing 1 changed file with 54 additions and 12 deletions.
66 changes: 54 additions & 12 deletions src/usr/isteps/nvdimm/bpm_update.C
Expand Up @@ -28,6 +28,7 @@
#include "nvdimm_update.H"

#include <errl/hberrltypes.H>
#include <errl/errlmanager.H>
#include <endian.h>
#include <sys/time.h>
#include <hbotcompid.H>
Expand Down Expand Up @@ -182,6 +183,44 @@ bool isBslCommand(const uint8_t i_command)
return result;
}


/**
* @brief Helper function to handle two potential errors that might occur in a
* function that only returns a single error log. If the return error is
* not nullptr then the second error will be linked to it and committed.
* Otherwise, the return error will point to the second's error and the
* second error will point to nullptr.
*
* @param[in/out] io_returnErrl A pointer to the error that would be
* returned by the function that called
* this one. If nullptr, then it will be
* set point to the secondary error and
* that error will become nullptr.
*
* @param[in/out] io_secondErrl The secondary error that occurred which
* in addition to the usual returned error.
*/
void handleMultipleErrors(errlHndl_t& io_returnErrl, errlHndl_t& io_secondErrl)
{
if (io_returnErrl != nullptr)
{
io_secondErrl->plid(io_returnErrl->plid());
TRACFCOMP(g_trac_bpm, "Committing second error eid=0x%X with plid of "
"returned error: 0x%X",
io_secondErrl->eid(),
io_returnErrl->plid());
io_secondErrl->collectTrace(BPM_COMP_NAME);
ERRORLOG::errlCommit(io_secondErrl, BPM_COMP_ID);
}
else
{
io_returnErrl = io_secondErrl;
io_secondErrl = nullptr;
}


}

/**
* @brief Helper function to extract the Segement ID from the segment code.
*
Expand Down Expand Up @@ -751,7 +790,7 @@ errlHndl_t Bpm::runUpdate(BpmFirmwareLidImage i_fwImage,
errl = checkFirmwareCrc();
if (errl != nullptr)
{
// @TODO RTC 212447: Add support for multiple update attempts.
// @TODO RTC 212448: Add support for multiple update attempts.
TRACFCOMP(g_trac_bpm, "Bpm:: runUpdate(): "
"Final CRC check failed. Attempting update again...");
iv_attemptAnotherUpdate = !iv_attemptAnotherUpdate;
Expand All @@ -760,14 +799,15 @@ errlHndl_t Bpm::runUpdate(BpmFirmwareLidImage i_fwImage,

} while(0);

do {
// Reset the device. This will exit BSL mode.
errlHndl_t exitErrl = resetDevice();
if (exitErrl != nullptr)
{
TRACFCOMP(g_trac_bpm, ERR_MRK"Bpm::runUpdate(): "
"Failed to reset the device");
//@TODO RTC 212447 Do something with the error.
delete exitErrl;
handleMultipleErrors(errl, exitErrl);
break;
}

// Exit update mode
Expand All @@ -776,8 +816,8 @@ errlHndl_t Bpm::runUpdate(BpmFirmwareLidImage i_fwImage,
{
TRACFCOMP(g_trac_bpm, ERR_MRK"Bpm::runUpdate(): "
"Failed to exit update mode");
//@TODO RTC 212447 Do something with the error.
delete exitErrl;
handleMultipleErrors(errl, exitErrl);
break;
}

// To see the BPM firmware level updated we must reset the controller
Expand All @@ -788,8 +828,8 @@ errlHndl_t Bpm::runUpdate(BpmFirmwareLidImage i_fwImage,
{
TRACFCOMP(g_trac_bpm, ERR_MRK"Bpm::runUpdate(): "
"Could not reset NVDIMM Controller");
//@TODO RTC 212447: Do something with the error.
delete exitErrl;
handleMultipleErrors(errl, exitErrl);
break;
}

TRACFCOMP(g_trac_bpm, "Bpm::runUpdate(): "
Expand All @@ -802,8 +842,8 @@ errlHndl_t Bpm::runUpdate(BpmFirmwareLidImage i_fwImage,
{
TRACFCOMP(g_trac_bpm, ERR_MRK"Bpm::runUpdate(): "
"Could not determine firmware version on the BPM");
//@TODO RTC 212447 Do something with the error.
delete exitErrl;
handleMultipleErrors(errl, exitErrl);
break;
}

if (i_fwImage.getVersion() == bpmFwVersion)
Expand All @@ -813,6 +853,8 @@ errlHndl_t Bpm::runUpdate(BpmFirmwareLidImage i_fwImage,
"image. Update Successful.");
}

} while(0);

TRACFCOMP(g_trac_bpm, EXIT_MRK"Bpm::runUpdate(): "
"Concluding BPM Update for NVDIMM 0x%.8X",
TARGETING::get_huid(iv_nvdimm));
Expand Down Expand Up @@ -1943,7 +1985,7 @@ errlHndl_t Bpm::dumpSegment(uint16_t const i_segmentCode,
TRACFCOMP(g_trac_bpm, ERR_MRK"Bpm::dumpSegment(): "
"Failed to write DEFAULT_REG_PAGE low byte!! "
"NVDIMM will be stuck on this segment's page!!");
// @TODO RTC 212447 Do something with the error.
handleMultipleErrors(errl, closeSegmentErrl);
break;
}

Expand All @@ -1955,7 +1997,7 @@ errlHndl_t Bpm::dumpSegment(uint16_t const i_segmentCode,
TRACFCOMP(g_trac_bpm, ERR_MRK"Bpm::dumpSegment(): "
"Failed to write DEFAULT_REG_PAGE high byte!! "
"NVDIMM will be stuck on this segment's page!!");
// @TODO RTC 212447 Do something with the error.
handleMultipleErrors(errl, closeSegmentErrl);
break;
}

Expand All @@ -1972,7 +2014,7 @@ errlHndl_t Bpm::dumpSegment(uint16_t const i_segmentCode,
{
TRACFCOMP(g_trac_bpm, "Bpm::dumpSegment(): "
"Failed to write production magic numbers.");
// @TODO RTC 212447 Do something with the error.
handleMultipleErrors(errl, magicErrl);
}
}

Expand Down

0 comments on commit 3c440fe

Please sign in to comment.