Skip to content

Commit

Permalink
Add code to run BPM update procedure from nvdimm_update.C
Browse files Browse the repository at this point in the history
Adds the necessary code to hook the existing BPM update code into
istep 21. The BPM update will be called in nvdimm_update.C
after the nvdimm updates have occurred.

Change-Id: If968313433bfdfbbbb929874de6eb0bf4d21b241
RTC: 212448
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/79640
Reviewed-by: Christian R Geddes <crgeddes@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: Roland Veloz <rveloz@us.ibm.com>
Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
  • Loading branch information
MRaybuck authored and dcrowell77 committed Aug 19, 2019
1 parent d577988 commit 56a3ce9
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 21 deletions.
130 changes: 127 additions & 3 deletions src/usr/isteps/nvdimm/bpm_update.C
Expand Up @@ -255,6 +255,130 @@ void longSleep(uint8_t const i_sleepInSeconds)
} while (iterations > 0);
}

void runBpmUpdates(bpmList_t * const i_16gb_BPMs,
bpmList_t * const i_32gb_BPMs,
BpmFirmwareLidImage * const i_16gb_fwImage,
BpmFirmwareLidImage * const i_32gb_fwImage,
BpmConfigLidImage * const i_16gb_configImage,
BpmConfigLidImage * const i_32gb_configImage)
{

assert( (i_16gb_BPMs == nullptr)
|| i_16gb_BPMs->empty()
|| ((i_16gb_fwImage != nullptr) && (i_16gb_configImage != nullptr)),
"BPM::runBpmUpdates(): Update images for 16gb BPMs was nullptr and "
"there are 16gb BPMs in the system to may require updates.");
assert( (i_32gb_BPMs == nullptr)
|| i_32gb_BPMs->empty()
|| ((i_32gb_fwImage != nullptr) && (i_32gb_configImage != nullptr)),
"BPM::runBpmUpdates(): Update images for 32gb BPMs was nullptr and "
"there are 32gb BPMs in the system to may require updates.");

errlHndl_t errl = nullptr;

do {
// @TODO RTC 212448 Enable updates once everything works
break;

if ( (i_16gb_BPMs != nullptr)
&& (i_16gb_fwImage != nullptr)
&& (i_16gb_configImage != nullptr))
{
TRACFCOMP(g_trac_bpm,
"Check/update %d BPMs on 16GB_TYPE NVDIMMs",
i_16gb_BPMs->size());

for(auto& bpm : *i_16gb_BPMs)
{
errl = bpm.runUpdate(*i_16gb_fwImage, *i_16gb_configImage);
if (errl != nullptr)
{
uint32_t nvdimmHuid = TARGETING::get_huid(bpm.getNvdimm());
if (bpm.attemptAnotherUpdate())
{
TRACFCOMP(g_trac_bpm, ERR_MRK
"An error occurred during a 16GB_TYPE BPM "
"update for NVDIMM 0x%.8X. "
"Commit and try again.",
nvdimmHuid);
ERRORLOG::errlCommit(errl, BPM_COMP_ID);

errl = bpm.runUpdate(*i_16gb_fwImage,
*i_16gb_configImage);
if (errl != nullptr)
{
TRACFCOMP(g_trac_bpm, ERR_MRK
"Another error occurred while attempting "
"to update the same 16GB_TYPE BPM for "
"NVDIMM 0x%.8X. Commit and move onto the "
"next BPM",
nvdimmHuid);
}
}
else
{
TRACFCOMP(g_trac_bpm, ERR_MRK
"An error occurred during a 16GB_TYPE BPM "
"update for NVDIMM 0x%.8X. "
"Commit and move onto the next BPM",
nvdimmHuid);
}
ERRORLOG::errlCommit(errl, BPM_COMP_ID);
}
}
}

if ( (i_32gb_BPMs != nullptr)
&& (i_32gb_fwImage != nullptr)
&& (i_32gb_configImage != nullptr))
{
TRACFCOMP(g_trac_bpm,
"Check/update %d BPMs on 32GB_TYPE NVDIMMs",
i_32gb_BPMs->size());

for(auto& bpm : *i_32gb_BPMs)
{
errl = bpm.runUpdate(*i_32gb_fwImage, *i_32gb_configImage);
if (errl != nullptr)
{
uint32_t nvdimmHuid = TARGETING::get_huid(bpm.getNvdimm());
if (bpm.attemptAnotherUpdate())
{
TRACFCOMP(g_trac_bpm, ERR_MRK
"An error occurred during a 32GB_TYPE BPM "
"update for NVDIMM 0x%.8X. "
"Commit and try again.",
nvdimmHuid);
ERRORLOG::errlCommit(errl, BPM_COMP_ID);

errl = bpm.runUpdate(*i_32gb_fwImage,
*i_32gb_configImage);
if (errl != nullptr)
{
TRACFCOMP(g_trac_bpm, ERR_MRK
"Another error occurred while attempting "
"to update the same 32GB_TYPE BPM for "
"NVDIMM 0x%.8X. Commit and move onto the "
"next BPM",
nvdimmHuid);
}
}
else
{
TRACFCOMP(g_trac_bpm, ERR_MRK
"An error occurred during a 32GB_TYPE BPM "
"update for NVDIMM 0x%.8X. "
"Commit and move onto the next BPM",
nvdimmHuid);
}
ERRORLOG::errlCommit(errl, BPM_COMP_ID);
}
}
}
} while(0);
}


// =============================================================================
// BpmFirmwareLidImage Class Functions
// =============================================================================
Expand All @@ -263,6 +387,8 @@ BpmFirmwareLidImage::BpmFirmwareLidImage(void * const i_lidImageAddr,
size_t i_size)
: iv_lidImage(i_lidImageAddr), iv_lidImageSize(i_size)
{
assert(i_lidImageAddr != nullptr,
"BPM::BpmFirmwareLidImage(): Provided LID image must not be nullptr");
}

uint16_t BpmFirmwareLidImage::getVersion() const
Expand Down Expand Up @@ -701,8 +827,7 @@ errlHndl_t Bpm::runUpdate(BpmFirmwareLidImage i_fwImage,
"Firmware version on the BPM matches the version in the "
"image. Skipping update.");

// @TODO RTC 212448: disable forced updates.
//break;
break;
}

// Depending on the BSL version a CRC check may be necessary
Expand Down Expand Up @@ -790,7 +915,6 @@ errlHndl_t Bpm::runUpdate(BpmFirmwareLidImage i_fwImage,
errl = checkFirmwareCrc();
if (errl != nullptr)
{
// @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 Down
78 changes: 60 additions & 18 deletions src/usr/isteps/nvdimm/nvdimm_update.C
Expand Up @@ -26,13 +26,15 @@
#include "nvdimm.H"
#include <isteps/nvdimm/nvdimm.H>
#include <isteps/nvdimm/nvdimmreasoncodes.H>
#include "bpm_update.H"

#include <initservice/istepdispatcherif.H> // sendProgressCode
#include <util/utilmclmgr.H> // secure LID manager
#include <errl/errlmanager.H>
#include <devicefw/userif.H>
#include <vpd/spdenums.H>
#include <sys/time.h>
#include <vector>

// Unique tracing for nvdimm update process
const char NVDIMM_UPD[] = "NVDIMM_UPD";
Expand Down Expand Up @@ -1894,12 +1896,15 @@ bool NvdimmsUpdate::runUpdate(void)
// List of each installed NVDIMM type
std::vector<NvdimmInstalledImage*> v_NVDIMM_16GB_list;
std::vector<NvdimmInstalledImage*> v_NVDIMM_32GB_list;
BPM::bpmList_t NVDIMM_BPM_16GB_list;
BPM::bpmList_t NVDIMM_BPM_32GB_list;

// Build up installed NVDIMM image lists
for (auto l_nvdimm : iv_nvdimmList)
{
NvdimmInstalledImage * l_installed_image =
new NvdimmInstalledImage(l_nvdimm);

l_err = l_installed_image->getType(l_installed_type);
if (l_err)
{
Expand All @@ -1924,13 +1929,20 @@ bool NvdimmsUpdate::runUpdate(void)
"0x%.8X NVDIMM is SMART_NVDIMM_16GB_TYPE",
get_huid(l_nvdimm));
v_NVDIMM_16GB_list.push_back(l_installed_image);

BPM::Bpm l_16gbBpm(l_nvdimm);
NVDIMM_BPM_16GB_list.push_back(l_16gbBpm);

}
else if (l_installed_type == SMART_NVDIMM_32GB_TYPE)
{
TRACFCOMP(g_trac_nvdimm_upd, "NvdimmsUpdate::runUpdate() - "
"0x%.8X NVDIMM is SMART_NVDIMM_32GB_TYPE",
get_huid(l_nvdimm));
v_NVDIMM_32GB_list.push_back(l_installed_image);

BPM::Bpm l_32gbBpm(l_nvdimm);
NVDIMM_BPM_32GB_list.push_back(l_32gbBpm);
}
else
{
Expand Down Expand Up @@ -1976,12 +1988,14 @@ bool NvdimmsUpdate::runUpdate(void)
}

do {
// First check that updatable NVDIMMs exist on the system
if ((v_NVDIMM_16GB_list.size() == 0) &&
(v_NVDIMM_32GB_list.size() == 0))
// First check that updatable NVDIMMs or BPMs exist on the system
if ( (v_NVDIMM_16GB_list.size() == 0)
&& (v_NVDIMM_32GB_list.size() == 0)
&& (NVDIMM_BPM_16GB_list.size() == 0)
&& (NVDIMM_BPM_32GB_list.size() == 0))
{
TRACFCOMP(g_trac_nvdimm_upd, "NvdimmsUpdate::runUpdate() - "
"No updatable NVDIMMs present on the system");
"No updatable NVDIMMs or BPMs present on the system");
break;
}

Expand All @@ -2000,8 +2014,17 @@ bool NvdimmsUpdate::runUpdate(void)
break;
}

for(const auto& lid : info.lidIds)
// Both the config and firmware images are needed to perform an
// update on a BPM. So, get pointers to each in the CompInfo
// struct's vector of LID IDs.
MCL::LidInfo * bpm_16gb_fw = nullptr;
MCL::LidInfo * bpm_16gb_config = nullptr;
MCL::LidInfo * bpm_32gb_fw = nullptr;
MCL::LidInfo * bpm_32gb_config = nullptr;

for(auto& lid : info.lidIds)
{

TRACFCOMP(g_trac_nvdimm,"LID ID=0x%08X, size=%d, vAddr=%p",
lid.id, lid.size, lid.vAddr);

Expand Down Expand Up @@ -2031,21 +2054,21 @@ bool NvdimmsUpdate::runUpdate(void)
v_NVDIMM_32GB_list);
}
}
else if (( lid.id == NVDIMM_32GB_BPM_FW_LIDID)
|| (lid.id == NVDIMM_32GB_BPM_CONFIG_LIDID))
else if (lid.id == NVDIMM_32GB_BPM_FW_LIDID)
{
bpm_32gb_fw = &lid;
}
else if (lid.id == NVDIMM_32GB_BPM_CONFIG_LIDID)
{
TRACFCOMP(g_trac_nvdimm,
"Check/Update %d 32GB_TYPE NVDIMMs' BPM",
v_NVDIMM_32GB_list.size());
//@TODO RTC 212448 Add calls into bpm_update.C code.
bpm_32gb_config = &lid;
}
else if (( lid.id == NVDIMM_16GB_BPM_FW_LIDID)
|| (lid.id == NVDIMM_16GB_BPM_CONFIG_LIDID))
else if (lid.id == NVDIMM_16GB_BPM_FW_LIDID)
{
TRACFCOMP(g_trac_nvdimm,
"Check/Update %d 16GB_TYPE NVDIMMs' BPM",
v_NVDIMM_16GB_list.size());
//@TODO RTC 212448 Add calls into bpm_update.C code.
bpm_16gb_fw = &lid;
}
else if (lid.id == NVDIMM_16GB_BPM_CONFIG_LIDID)
{
bpm_16gb_config = &lid;
}
else if (lid.id != NVDIMM_SIGNATURE_LIDID)
{
Expand All @@ -2056,7 +2079,26 @@ bool NvdimmsUpdate::runUpdate(void)
}
}

// @TODO RTC 212448 Add call to perform BPM updates
// Run BPM updates on NVDIMMs
BPM::BpmFirmwareLidImage fwImage_16gb(bpm_16gb_fw->vAddr,
bpm_16gb_fw->size);

BPM::BpmFirmwareLidImage fwImage_32gb(bpm_32gb_fw->vAddr,
bpm_32gb_fw->size);

BPM::BpmConfigLidImage configImage_16gb(bpm_16gb_config->vAddr,
bpm_16gb_config->size);

BPM::BpmConfigLidImage configImage_32gb(bpm_32gb_config->vAddr,
bpm_32gb_config->size);

BPM::runBpmUpdates(&NVDIMM_BPM_16GB_list,
&NVDIMM_BPM_32GB_list,
&fwImage_16gb,
&fwImage_32gb,
&configImage_16gb,
&configImage_32gb);

// Destructor automatically unloads the NVDIMM flash binary
}
else
Expand Down

0 comments on commit 56a3ce9

Please sign in to comment.