From a69715d78e44ca4d69009bdd829a8ed778bcd845 Mon Sep 17 00:00:00 2001 From: Louis Stermole Date: Wed, 4 Dec 2019 11:33:19 -0500 Subject: Add p9a_mss_utils_to_throttle Also move some shared code into gen_throttle.H Change-Id: I74ada8a0ee99db511813e04a58f434d779a90930 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/88093 Reviewed-by: Mark Pizzutillo Tested-by: FSP CI Jenkins Tested-by: Jenkins Server Tested-by: Hostboot CI Tested-by: HWSV CI Reviewed-by: STEPHEN GLANCY Reviewed-by: Michael D Pardeik Reviewed-by: Jennifer A Stofer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/88121 Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Daniel M Crowell --- .../hwp/memory/p9_mss_utils_to_throttle.C | 85 ++++++++-------------- 1 file changed, 32 insertions(+), 53 deletions(-) (limited to 'src/import/chips/p9/procedures') diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_utils_to_throttle.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_utils_to_throttle.C index 8efba3f4b..01bd44749 100644 --- a/src/import/chips/p9/procedures/hwp/memory/p9_mss_utils_to_throttle.C +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_utils_to_throttle.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2019 */ +/* Contributors Listed Below - COPYRIGHT 2015,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -72,6 +72,8 @@ extern "C" /// fapi2::ReturnCode p9_mss_utils_to_throttle( const std::vector< fapi2::Target >& i_targets ) { + constexpr uint64_t l_min_util = mss::power_thermal::throttle_traits::MIN_UTIL; + FAPI_INF("Entering p9_mss_utils_to_throttle"); std::vector< fapi2::Target > l_exceeded_power; @@ -88,20 +90,24 @@ extern "C" uint32_t l_max_databus_util = {}; uint32_t l_dram_clocks = 0; uint16_t l_safemode_throttle_per_port = 0; - double l_calc_util_safemode = 0; + uint32_t l_calc_util = 0; uint16_t l_n_port[mss::PORTS_PER_MCS] = {}; uint16_t l_n_slot[mss::PORTS_PER_MCS] = {}; uint32_t l_max_power[mss::PORTS_PER_MCS] = {}; - FAPI_TRY( mss::mrw_mem_m_dram_clocks(l_dram_clocks) ); + FAPI_TRY(mss::mrw_mem_m_dram_clocks(l_dram_clocks) ); //Util attribute set by OCC - FAPI_TRY( mss::databus_util(l_mcs, l_input_databus_util) ); - FAPI_TRY( mss::mrw_max_dram_databus_util(l_max_databus_util)); + FAPI_TRY(mss::databus_util(l_mcs, l_input_databus_util) ); + FAPI_TRY(mss::mrw_max_dram_databus_util(l_max_databus_util)); + FAPI_TRY(mss::mrw_safemode_mem_throttled_n_commands_per_port(l_safemode_throttle_per_port)); for( const auto& l_mca : mss::find_targets(l_mcs) ) { + fapi2::ReturnCode l_rc; + bool l_safemode = false; + FAPI_INF("Input databus utilization for %s is %d", mss::c_str(l_mca), l_input_databus_util[mss::index(l_mca)]); @@ -114,58 +120,31 @@ extern "C" } // If input utilization is zero, use mrw safemode throttle values for utilization - bool l_safemode = false; - - if (l_input_databus_util[l_port_num] == 0) - { - FAPI_TRY(mss::mrw_safemode_mem_throttled_n_commands_per_port(l_safemode_throttle_per_port), - "Error in getting safemode throttles" ); - FAPI_TRY( mss::power_thermal::calc_util_from_throttles(l_safemode_throttle_per_port, l_dram_clocks, - l_calc_util_safemode), - "%s Error calculating utilization from safemode throttle %d and mem clocks %d", - mss::c_str(l_mca), - l_safemode_throttle_per_port, - l_dram_clocks); - FAPI_INF( "%s Safemode throttles being used since input util is zero: Using N=%d, Utilization %f", - mss::c_str(l_mca), - l_safemode_throttle_per_port, - l_calc_util_safemode); - l_safemode = true; - l_input_databus_util[l_port_num] = l_calc_util_safemode; - } - - using TT = mss::power_thermal::throttle_traits<>; - const uint64_t l_min_util = TT::MIN_UTIL; - //Make sure MIN_UTIL <= input_utilization <= max_utilization - const uint32_t l_databus_util = ( l_input_databus_util[l_port_num] >= l_min_util) ? - std::min(l_input_databus_util[l_port_num], l_max_databus_util) - : l_min_util; + // else make sure we're within our maximum utilization limit + FAPI_TRY(mss::power_thermal::calc_utilization(l_mca, + l_input_databus_util[l_port_num], + l_dram_clocks, + l_safemode_throttle_per_port, + l_max_databus_util, + l_calc_util, + l_util_error, + l_safemode)); // Error if utilization is less than MIN_UTIL // Don't exit, let HWP finish and return error at end - if (l_input_databus_util[l_port_num] < l_min_util) - { - FAPI_ASSERT_NOEXIT( false, - fapi2::MSS_MIN_UTILIZATION_ERROR() - .set_INPUT_UTIL_VALUE(l_input_databus_util[l_port_num]) - .set_MIN_UTIL_VALUE(l_min_util), - "%s Input utilization (%d) less than minimum utilization allowed (%d)", - mss::c_str(l_mca), l_input_databus_util[l_port_num], l_min_util); - l_util_error = true; - } - - //Make a throttle object in order to calculate the port power - fapi2::ReturnCode l_rc; - - mss::power_thermal::throttle<> l_throttle (l_mca, l_rc); - FAPI_TRY(l_rc, "Error calculating mss::power_thermal::throttle constructor in p9_mss_utils_to_throttles"); + FAPI_ASSERT_NOEXIT(!l_util_error, + fapi2::MSS_MIN_UTILIZATION_ERROR() + .set_INPUT_UTIL_VALUE(l_input_databus_util[l_port_num]) + .set_MIN_UTIL_VALUE(l_min_util), + "%s Input utilization (%d) less than minimum utilization allowed (%d)", + mss::c_str(l_mca), l_input_databus_util[l_port_num], l_min_util); - FAPI_INF( "%s MRW dram clock window: %d, databus utilization: %d", - mss::c_str(l_mca), - l_dram_clocks, - l_databus_util); + // Make a throttle object in order to calculate the port power + mss::power_thermal::throttle l_throttle (l_mca, l_rc); + FAPI_TRY(l_rc, "%s Error calculating mss::power_thermal::throttle constructor in p9_mss_utils_to_throttles", + mss::c_str(l_mca)); - FAPI_TRY( l_throttle.calc_slots_and_power(l_databus_util)); + FAPI_TRY( l_throttle.calc_slots_and_power(l_calc_util)); FAPI_INF( "%s Calculated N commands per port %d, per slot %d, commands per dram clock window %d, maxpower is %d", mss::c_str(l_mca), @@ -197,7 +176,7 @@ extern "C" // Return a failing RC code if we had any input utilization values less than MIN_UTIL if (l_util_error) { - fapi2::current_err = fapi2::FAPI2_RC_FALSE; + fapi2::current_err = fapi2::RC_MSS_MIN_UTILIZATION_ERROR; } fapi_try_exit: -- cgit v1.2.1