diff options
Diffstat (limited to 'src/import/chips/p9')
6 files changed, 515 insertions, 0 deletions
diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/freq/sync.C b/src/import/chips/p9/procedures/hwp/memory/lib/freq/sync.C new file mode 100644 index 000000000..f3f1a3002 --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/memory/lib/freq/sync.C @@ -0,0 +1,200 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: chips/p9/procedures/hwp/memory/lib/freq/sync.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/// +/// @file sync.C +/// @brief Synchronous function implementations +/// +// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> +// *HWP HWP Backup: Brian Silver <bsilver@us.ibm.com> +// *HWP Team: Memory +// *HWP Level: 2 +// *HWP Consumed by: HB:FSP +#include <vector> +#include <map> + +#include <fapi2.H> +#include <mss.H> +#include <freq/sync.H> +#include <lib/utils/find.H> + +using fapi2::TARGET_TYPE_DIMM; +using fapi2::TARGET_TYPE_MCS; +using fapi2::TARGET_TYPE_MCBIST; +using fapi2::TARGET_TYPE_SYSTEM; + +namespace mss +{ + +/// +/// @brief Retrieves a mapping of MSS frequency values per mcbist target +/// @param[in] i_targets vector of controller targets +/// @param[out] o_freq_map dimm speed map <key, value> = (mcbist target, frequency) +/// @param[out] o_is_speed_equal true if all map dimm speeds are the same +/// @return FAPI2_RC_SUCCESS iff successful +/// +fapi2::ReturnCode dimm_speed_map(const std::vector< fapi2::Target<TARGET_TYPE_MCBIST> >& i_targets, + std::map< fapi2::Target<TARGET_TYPE_MCBIST>, uint64_t >& o_freq_map, + speed_equality& o_is_speed_equal) +{ + FAPI_INF("---- In dimm_speed_pairs ----"); + + if(i_targets.empty()) + { + FAPI_ERR("Empty target vector found when constructing dimm speed mapping!"); + return fapi2::FAPI2_RC_INVALID_PARAMETER; + } + + // Getting a sample freq value from an arbitrary target (first one) + // to compare against all other target freq values + uint64_t l_comparator = 0; + FAPI_TRY( mss::freq(i_targets[0], l_comparator), "Failed accessor to mss_freq" ); + + o_is_speed_equal = speed_equality::EQUAL_DIMM_SPEEDS; + + // Loop through all MCSBISTs and store dimm speeds + for (const auto& l_mcbist : i_targets) + { + uint64_t l_dimm_speed = 0; + FAPI_TRY( mss::freq(l_mcbist, l_dimm_speed), "Failed accessor to mss_freq" ); + + if(l_comparator != l_dimm_speed) + { + o_is_speed_equal = speed_equality::NOT_EQUAL_DIMM_SPEEDS; + } + + FAPI_INF("%s: Dimm speed %d MT/s", c_str(l_mcbist), l_dimm_speed); + o_freq_map.emplace( std::make_pair(l_mcbist, l_dimm_speed) ); + } + +fapi_try_exit: + return fapi2::current_err; +} + +/// +/// @brief Deconfigures MCS targets connected to MCBIST +/// @param[in] i_target the controller target +/// @param[in] i_dimm_speed dimm speed in MT/s +/// @param[in] i_nest_freq nest freq in MHz +/// @return true if hardware was deconfigured +/// +bool deconfigure(const fapi2::Target<TARGET_TYPE_MCBIST>& i_target, + const uint64_t i_dimm_speed, + const uint32_t i_nest_freq) +{ + FAPI_INF("---- In deconfigure ----"); + bool l_is_hw_deconfigured = false; + + // TODO - RTC 155347 fix dimm speed & nest comparison if needed + if(i_dimm_speed != i_nest_freq) + { + // Deconfigure MCSes + for( const auto& l_mcs : mss::find_targets<TARGET_TYPE_MCS>(i_target) ) + { + l_is_hw_deconfigured = true; + + PLAT_FAPI_ASSERT_NOEXIT(false, + fapi2::MSS_FREQ_NOT_EQUAL_NEST_FREQ() + .set_MSS_FREQ(i_dimm_speed) + .set_NEST_FREQ(i_nest_freq) + .set_MCS_TARGET(l_mcs), + "Deconfiguring %s", + mss::c_str(l_mcs) ); + }// end for + }// end if + + return l_is_hw_deconfigured; +} + +/// +/// @brief Selects synchronous mode and performs requirements enforced by ATTR_REQUIRED_SYNCH_MODE +/// @param[in] i_freq_map dimm speed mapping +/// @param[in] i_equal_dimm_speed tracks whether map has equal dimm speeds +/// @param[in] i_nest_freq nest frequency +/// @param[in] i_required_sync_mode system policy to enforce synchronous mode +/// @param[out] o_selected_sync_mode final synchronous mode +/// @return FAPI2_RC_SUCCESS iff successful +/// +fapi2::ReturnCode select_sync_mode(const std::map< fapi2::Target<TARGET_TYPE_MCBIST>, uint64_t >& i_freq_map, + const speed_equality i_equal_dimm_speed, + const uint32_t i_nest_freq, + const uint8_t i_required_sync_mode, + sync_mode& o_selected_sync_mode) +{ + FAPI_INF("---- In select_sync_mode ----"); + + // Implementing frequency handling discussion: + // https://w3-connections.ibm.com/forums/html/topic?id=1222318f-5992-4342-a858-b75594df1be3&ps= + // Summary: We will always use async mode if we don't see a perfect match of dimm frequencies that match the nest + switch(i_equal_dimm_speed) + { + case speed_equality::EQUAL_DIMM_SPEEDS: + + // Do not run synchronously, even if the frequencies match + if (i_required_sync_mode == fapi2::ENUM_ATTR_REQUIRED_SYNCH_MODE_NEVER) + { + o_selected_sync_mode = sync_mode::MC_NOT_IN_SYNC; + break; + } + + // Run synchronously if the dimm and nest freq matches + // Implicitly covers case when ATTR_REQUIRED_SYNCH_MODE is + // ALWAYS and UNDETERMINED + if( i_freq_map.begin()->second == i_nest_freq) + { + o_selected_sync_mode = sync_mode::MC_IN_SYNC; + } + else + { + o_selected_sync_mode = sync_mode::MC_NOT_IN_SYNC; + } + + break; + + case speed_equality::NOT_EQUAL_DIMM_SPEEDS: + + // Require matching frequencies and deconfigure memory that does not match the nest + if( i_required_sync_mode == fapi2::ENUM_ATTR_REQUIRED_SYNCH_MODE_ALWAYS ) + { + for(const auto& l_it : i_freq_map) + { + // This can be refactored to return info people might + // need. Until then this returns true if hw was deconfigured + // FFDC prints out location + deconfigure(l_it.first, l_it.second, i_nest_freq); + + }// end for + }// end if + + // Implicitly covers case when ATTR_REQUIRED_SYNCH_MODE is + // NEVER, ALWAYS, and UNDETERMINED + o_selected_sync_mode = sync_mode::MC_NOT_IN_SYNC; + + break; + + default: + FAPI_ERR("Invalid speed_equality parameter!"); + return fapi2::FAPI2_RC_INVALID_PARAMETER; + break; + }// end switch + + return fapi2::FAPI2_RC_SUCCESS; +} + +}// mss diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/freq/sync.H b/src/import/chips/p9/procedures/hwp/memory/lib/freq/sync.H new file mode 100644 index 000000000..5e11ad551 --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/memory/lib/freq/sync.H @@ -0,0 +1,91 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: chips/p9/procedures/hwp/memory/lib/freq/sync.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/// +/// @file synch.H +/// @brief Synchronous function implementations +/// +// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> +// *HWP HWP Backup: Brian Silver <bsilver@us.ibm.com> +// *HWP Team: Memory +// *HWP Level: 2 +// *HWP Consumed by: HB:FSP + +#ifndef _MSS_SYNC_H_ +#define _MSS_SYNC_H_ + +#include <map> +#include <vector> + +#include <fapi2.H> + +namespace mss +{ + +enum class speed_equality : uint8_t +{ + NOT_EQUAL_DIMM_SPEEDS = 0, + EQUAL_DIMM_SPEEDS = 1, +}; + +enum class sync_mode : uint8_t +{ + MC_NOT_IN_SYNC = 0, + MC_IN_SYNC = 1, +}; + +/// +/// @brief Retrieves a mapping of MSS frequency values per mcbist target +/// @param[in] i_targets vector of controller targets +/// @param[out] o_freq_map dimm speed map <key, value> = (mcbist target, frequency) +/// @param[out] o_is_speed_equal holds whether map dimm speed is equal +/// @return FAPI2_RC_SUCCESS iff successful +/// +fapi2::ReturnCode dimm_speed_map(const std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCBIST> >& i_targets, + std::map< fapi2::Target<fapi2::TARGET_TYPE_MCBIST>, uint64_t >& o_freq_map, + speed_equality& o_is_speed_equal); + +/// +/// @brief Helper function to deconfigure MCS targets connected to MCBIST +/// @param[in] i_target the controller target +/// @param[in] i_dimm_speed dimm speed in MT/s +/// @param[in] i_nest_freq nest freq in MHz +/// @return true if hardware was deconfigured +/// +bool deconfigure(const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& i_target, + const uint64_t i_dimm_speed, + const uint32_t i_nest_freq); + +/// +/// @brief Selects synchronous mode and performs requirements enforced by ATTR_REQUIRED_SYNCH_MODE +/// @param[in] i_freq_map dimm speed mapping +/// @param[in] i_equal_dimm_speed tracks whether map has equal dimm speeds +/// @param[in] i_nest_freq nest frequency +/// @param[in] i_required_sync_mode system policy to enforce synchronous mode +/// @param[out] o_selected_sync_mode final synchronous mode +/// @return FAPI2_RC_SUCCESS iff successful +/// +fapi2::ReturnCode select_sync_mode(const std::map< fapi2::Target<fapi2::TARGET_TYPE_MCBIST>, uint64_t >& i_freq_map, + const speed_equality i_equal_dimm_speed, + const uint32_t i_nest_freq, + const uint8_t i_required_sync_mode, + sync_mode& o_selected_sync_mode); + +}// mss + +#endif diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.C new file mode 100644 index 000000000..e27a06f97 --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.C @@ -0,0 +1,99 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: chips/p9/procedures/hwp/memory/p9_mss_freq_system.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2015,2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/// +/// @file p9_freq_system.C +/// @brief Sets synchronous mode an +/// +// *HWP HWP Owner: Andre A. Marin <aamarin@us.ibm.com> +// *HWP FW Owner: Brian Silver <bsilver@us.ibm.com> +// *HWP Team: Memory +// *HWP Level: 2 +// *HWP Consumed by: FSP:HB +#include <vector> +#include <map> + +#include <fapi2.H> +#include <mss.H> + +#include <p9_mss_freq_system.H> +#include <lib/utils/find.H> +#include <lib/freq/sync.H> + +using fapi2::TARGET_TYPE_SYSTEM; +using fapi2::TARGET_TYPE_PROC_CHIP; +using fapi2::TARGET_TYPE_MCBIST; +using fapi2::TARGET_TYPE_MCS; + +extern "C" +{ + /// + /// @brief Set synchronous mode + /// @param[in] i_targets vector of controllers (e.g., MCS) + /// @return FAPI2_RC_SUCCESS iff ok + /// + fapi2::ReturnCode p9_mss_freq_system( const std::vector< fapi2::Target<TARGET_TYPE_MCBIST> >& i_targets ) + { + FAPI_INF("----- In p9_mss_freq_system ----"); + + std::map< fapi2::Target<TARGET_TYPE_MCBIST>, uint64_t > l_freq_map; + uint32_t l_nest_freq = 0; + uint8_t l_required_sync_mode = 0; + mss::sync_mode l_mc_in_sync; + mss::speed_equality l_equal_dimm_speed; + + // Populate dimm speed map + FAPI_TRY( mss::dimm_speed_map(i_targets, l_freq_map, l_equal_dimm_speed), + "Failed to get dimm speed mapping" ); + + FAPI_INF("Dimm speed for all MCBISTs are the same : %s", + uint8_t(l_equal_dimm_speed) ? "true" : "false"); + + // Get nest freq && F/W attr that tells me if sync mode is required + // or if I have to figure that out + FAPI_TRY( mss::required_synch_mode(l_required_sync_mode) ); + FAPI_TRY( FAPI_ATTR_GET( fapi2::ATTR_FREQ_PB, fapi2::Target<TARGET_TYPE_SYSTEM>(), l_nest_freq) ); + + FAPI_INF("Retrieved req'd sync mode: %d and nest freq %d", l_required_sync_mode, l_nest_freq); + + // Select SYNCH mode + FAPI_TRY( mss::select_sync_mode(l_freq_map, + l_equal_dimm_speed, + l_nest_freq, + l_required_sync_mode, + l_mc_in_sync) ); + + FAPI_INF("Selected SYNC mode : %s", uint8_t(l_mc_in_sync) ? "MC in sync" : "MC NOT in sync"); + + // Set attribute + for(const auto& l_mcbist : i_targets) + { + const auto& l_proc_chip = mss::find_target<TARGET_TYPE_PROC_CHIP>(l_mcbist); + + // Cast converts enum class to uint8_t& expected for ATTR_SET + FAPI_TRY( FAPI_ATTR_SET( fapi2::ATTR_MC_SYNC_MODE, l_proc_chip, reinterpret_cast<uint8_t(&)>(l_mc_in_sync) ), + "Failed to set ATTR_MC_SYNC_MODE"); + } + + fapi_try_exit: + return fapi2::current_err; + + } // p9_freq_system + +} //extern "C" diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.H b/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.H new file mode 100644 index 000000000..974b6c53a --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.H @@ -0,0 +1,50 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: chips/p9/procedures/hwp/memory/p9_mss_freq_system.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2015,2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/// +/// @file p9_mss_freq_system.H +/// @brief Sets synchronous mode +/// +// *HWP HWP Owner: Andre A. Marin <aamarin@us.ibm.com> +// *HWP FW Owner: Brian Silver <bsilver@us.ibm.com> +// *HWP Team: Memory +// *HWP Level: 2 +// *HWP Consumed by: FSP:HB + +#ifndef FREQ_SYSTEM_H_ +#define FREQ_SYSTEM_H_ + +#include <fapi2.H> +#include <vector> + +typedef fapi2::ReturnCode (*p9_mss_freq_system_FP_t) (const std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCBIST> >&); + +extern "C" +{ + + /// + /// @brief Set synchronous mode + /// @param[in] i_target the controller (e.g., MCS) + /// @return FAPI2_RC_SUCCESS iff ok + /// + fapi2::ReturnCode p9_mss_freq_system( const std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCBIST> >& i_targets); + +} + +#endif diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.mk b/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.mk new file mode 100644 index 000000000..aaba7a88c --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq_system.mk @@ -0,0 +1,26 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: chips/p9/procedures/hwp/memory/p9_mss_freq_system.mk $ +# +# IBM CONFIDENTIAL +# +# EKB Project +# +# COPYRIGHT 2015,2016 +# [+] International Business Machines Corp. +# +# +# The source code for this program is not published or otherwise +# divested of its trade secrets, irrespective of what has been +# deposited with the U.S. Copyright Office. +# +# IBM_PROLOG_END_TAG + +# Include the macros and things for MSS procedures +-include 00common.mk + +PROCEDURE=p9_mss_freq_system +$(eval $(call ADD_MEMORY_INCDIRS,$(PROCEDURE))) +lib$(PROCEDURE)_DEPLIBS+=mss +$(call BUILD_PROCEDURE) diff --git a/src/import/chips/p9/procedures/xml/error_info/p9_memory_mss_general_errors.xml b/src/import/chips/p9/procedures/xml/error_info/p9_memory_mss_general_errors.xml new file mode 100644 index 000000000..d71def5bd --- /dev/null +++ b/src/import/chips/p9/procedures/xml/error_info/p9_memory_mss_general_errors.xml @@ -0,0 +1,49 @@ +<!-- IBM_PROLOG_BEGIN_TAG --> +<!-- This is an automatically generated prolog. --> +<!-- --> +<!-- $Source: chips/p9/procedures/xml/error_info/p9_memory_mss_general_errors.xml $ --> +<!-- --> +<!-- IBM CONFIDENTIAL --> +<!-- --> +<!-- EKB Project --> +<!-- --> +<!-- COPYRIGHT 2015,2016 --> +<!-- [+] International Business Machines Corp. --> +<!-- --> +<!-- --> +<!-- The source code for this program is not published or otherwise --> +<!-- divested of its trade secrets, irrespective of what has been --> +<!-- deposited with the U.S. Copyright Office. --> +<!-- --> +<!-- IBM_PROLOG_END_TAG --> + +<!-- --> +<!-- @file memory_mss_general_errors --> +<!-- @brief Error xml for timing.H --> +<!-- --> +<!-- *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> --> +<!-- *HWP HWP Backup: Brian Silver <bsilver@us.ibm.com> --> +<!-- *HWP Team: Memory --> +<!-- *HWP Level: 1 --> +<!-- *HWP Consumed by: HB:FSP --> +<!-- --> + +<hwpErrors> + + <hwpError> + <rc>RC_MSS_LOOKUP_FAILED</rc> + <description> + Conditional that tests whether a certain key value is located in a map (hence, lookup). + </description> + <ffdc>KEY</ffdc> + <ffdc>DATA</ffdc> + <callout> + <target>TARGET</target> + <priority>HIGH</priority> + </callout> + <deconfigure> + <target>TARGET</target> + </deconfigure> + </hwpError> + +</hwpErrors> |