Skip to content

Commit

Permalink
Adds plug rule for NVDIMM in specific DIMM slots
Browse files Browse the repository at this point in the history
NVDIMMs can only be plugged into specific slots on certain systems.
This code adds in plug rules to ensure that NVDIMM are only plugged into
slots that can support them.

Change-Id: Ie67bc57b6764df37d2478bb4de22cff1166a5469
Original-Change-Id: Ie54e46bbdf09236c8d6a431dcc41e19af54b9b34
RTC:186541
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/52946
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: ANDRE A. MARIN <aamarin@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66312
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Tested-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
sglancy6 authored and dcrowell77 committed Sep 19, 2018
1 parent bb0c112 commit 5e126f3
Showing 1 changed file with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/// @file plug_rules.C
/// @brief Enforcement of rules for plugging in DIMM
///
// *HWP HWP Owner: Jacob L Harvey <jlharvey@us.ibm.com>
// *HWP HWP Owner: Stephen Glancy <sglancy@us.ibm.com>
// *HWP HWP Backup: Andre Marin <aamarin@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 3
Expand Down Expand Up @@ -159,6 +159,63 @@ fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief Helper function to determine if a given DIMM slot can support an NVDIMM
/// @param[in] const ref to the DIMM target
/// @param[out] o_is_capable true if the DIMM slot is NVDIMM capable
/// @return bool FAPI2_RC_SUCCESS iff we pass without errors
///
fapi2::ReturnCode dimm_slot_is_nv_capable(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target,
bool& o_is_capable)
{
const auto l_pos = mss::pos(i_target);

fapi2::buffer<uint64_t> l_plug_rules_bitmap = 0;

FAPI_TRY( mss::mrw_nvdimm_plug_rules(l_plug_rules_bitmap) );

o_is_capable = l_plug_rules_bitmap.getBit(l_pos);

FAPI_INF("failed accessing ATTR_MSS_MRW_NVDIMM_PLUG_RULES: 0x%016lx %s capable (target: %s)",
l_plug_rules_bitmap, o_is_capable ? "is" : "isn't", mss::c_str(i_target));

fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief Enforces that NVDIMM are plugged in the proper location
/// @note NVDIMM can only be plugged in locations where the MRW attribute bitmap is set
/// @param[in] i_target the port
/// @param[in] i_kinds a vector of DIMM (sorted while processing)
/// @return fapi2::FAPI2_RC_SUCCESS if okay
/// @note Expects the kind array to represent the DIMM on the port.
///
fapi2::ReturnCode check_nvdimm(const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target,
const std::vector<dimm::kind>& i_kinds)
{
fapi2::current_err = fapi2::FAPI2_RC_SUCCESS;

// Note: NVDIMM + non-NVDIMM mixing is checked in check hybrid
for(const auto& l_kind : i_kinds)
{
bool l_nvdimm_supported = true;
FAPI_TRY(dimm_slot_is_nv_capable(l_kind.iv_target, l_nvdimm_supported));

// We're always good if NVDIMM is supported OR we're not an NVDIMM, otherwise, throw an error
FAPI_ASSERT( (l_nvdimm_supported) || (l_kind.iv_hybrid_memory_type != fapi2::ENUM_ATTR_EFF_HYBRID_MEMORY_TYPE_NVDIMM),
fapi2::MSS_PLUG_RULES_NVDIMM_PLUG_ERROR()
.set_DIMM_TARGET(l_kind.iv_target)
.set_DIMM_POS(mss::pos(l_kind.iv_target))
.set_MCA_TARGET(i_target),
"%s is an NVDIMM plugged into a DIMM slot where NVDIMM are not supported",
mss::c_str(l_kind.iv_target) );
}

fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief Enforce DRAM stack type checks
/// @note No 3DS and non-3DS DIMM's can mix
Expand Down Expand Up @@ -658,6 +715,9 @@ fapi2::ReturnCode plug_rule::enforce_plug_rules(const fapi2::Target<fapi2::TARGE
// Ensures that the port has a valid combination of hybrid DIMM
FAPI_TRY( plug_rule::check_hybrid(i_target, l_dimm_kinds) );

// Checks if NVDIMM are properly plugged for this system
FAPI_TRY( plug_rule::check_nvdimm(i_target, l_dimm_kinds) );

// Checks to see if any DIMM are LRDIMM
FAPI_TRY( plug_rule::code::check_lrdimm(l_dimm_kinds) );

Expand Down

0 comments on commit 5e126f3

Please sign in to comment.