Skip to content

Commit 28f61d1

Browse files
stermoledcrowell77
authored andcommitted
Add check in gen_throttle for divide by zero
Change-Id: I523217fd63e11c2f7c98fa35b56f8e1e96eb98bd CQ:SW497476 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/105557 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Reviewed-by: Mark Pizzutillo <mark.pizzutillo@ibm.com> Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com> Dev-Ready: Louis Stermole <stermole@us.ibm.com> Reviewed-by: Edgar R Cordero <ecordero@us.ibm.com> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/105570 Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
1 parent 10a6ca3 commit 28f61d1

File tree

2 files changed

+60
-34
lines changed

2 files changed

+60
-34
lines changed

src/import/generic/memory/lib/utils/power_thermal/gen_throttle.H

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ fapi2::ReturnCode calc_util_from_throttles(const uint16_t i_n_throttles,
151151
// Check for the minimum
152152
if(o_calc_util < TT::MIN_UTIL)
153153
{
154-
FAPI_INF("Calculated utilization (%f) is less than the minimum utilization: %lu. Setting to minimum value",
155-
o_calc_util, TT::MIN_UTIL);
154+
FAPI_INF("Calculated utilization (%lu) is less than the minimum utilization: %lu. Setting to minimum value",
155+
static_cast<uint64_t>(o_calc_util), TT::MIN_UTIL);
156156
o_calc_util = TT::MIN_UTIL;
157157
}
158158

159-
FAPI_INF("In calc_util_from_throttles, calculated %f for output utilization from throttles:%d, dram_clocks %d",
160-
o_calc_util, i_n_throttles, i_num_dram_clocks);
159+
FAPI_INF("In calc_util_from_throttles, calculated %lu for output utilization from throttles:%d, dram_clocks %d",
160+
static_cast<uint64_t>(o_calc_util), i_n_throttles, i_num_dram_clocks);
161161

162162
fapi_try_exit:
163163
return fapi2::current_err;
@@ -605,17 +605,18 @@ fapi2::ReturnCode throttle<MC, TT>::power_regulator_throttles ()
605605
"Failed to calculate the max and idle power for port %s",
606606
mss::c_str(iv_target));
607607

608-
FAPI_INF("POWER throttles: %s max port power is %f", mss::c_str(iv_target), l_port_power_calc_max);
608+
FAPI_INF("POWER throttles: %s max port power is %lu", mss::c_str(iv_target),
609+
static_cast<uint64_t>(l_port_power_calc_max));
609610

610611
//Calculate the power curve slope and intercept using the port's min and max power values
611612
FAPI_TRY(calc_power_curve(l_port_power_calc_idle,
612613
l_port_power_calc_max,
613614
l_port_power_slope,
614615
l_port_power_int),
615-
"Failed to calculate the power curve for port %s, calculated port power max is %f, idle is %f",
616+
"Failed to calculate the power curve for port %s, calculated port power max is %lu, idle is %lu",
616617
mss::c_str(iv_target),
617-
l_port_power_calc_max,
618-
l_port_power_calc_idle);
618+
static_cast<uint64_t>(l_port_power_calc_max),
619+
static_cast<uint64_t>(l_port_power_calc_idle));
619620

620621
FAPI_INF("%s POWER Port power limit is %d", mss::c_str(iv_target), iv_port_power_limit);
621622
//Calculate the port's utilization to get under watt target using the port's calculated slopes
@@ -624,13 +625,13 @@ fapi2::ReturnCode throttle<MC, TT>::power_regulator_throttles ()
624625
iv_port_power_limit,
625626
l_calc_util_port);
626627

627-
FAPI_INF("%s POWER calc util port is %f", mss::c_str(iv_target), l_calc_util_port);
628+
FAPI_INF("%s POWER calc util port is %lu", mss::c_str(iv_target), static_cast<uint64_t>(l_calc_util_port));
628629

629630
//Calculate the new slot values and the max power value for the port
630631
FAPI_TRY( calc_slots_and_power( l_calc_util_port),
631-
"%s Error calculating the final throttles and power values for target with passed in port utilization %f",
632+
"%s Error calculating the final throttles and power values for target with passed in port utilization %lu",
632633
mss::c_str(iv_target),
633-
l_calc_util_port);
634+
static_cast<uint64_t>(l_calc_util_port));
634635

635636
fapi_try_exit:
636637
return fapi2::current_err;
@@ -707,7 +708,8 @@ fapi2::ReturnCode throttle<MC, TT>::thermal_throttles ()
707708
iv_dimm_thermal_limit[l_pos],
708709
l_calc_util[l_pos]);
709710

710-
FAPI_INF("THERMAL throttles: %s dram databus utilization is %f", mss::c_str(l_dimm), l_calc_util[l_pos]);
711+
FAPI_INF("THERMAL throttles: %s dram databus utilization is %lu", mss::c_str(l_dimm),
712+
static_cast<uint64_t>(l_calc_util[l_pos]));
711713

712714
l_temp_n_slot = power_thermal::throttled_cmds (l_calc_util[l_pos], iv_m_clocks);
713715

@@ -773,11 +775,11 @@ fapi2::ReturnCode throttle<MC, TT>::calc_port_power(const double i_idle_util [TT
773775
{
774776
const auto l_pos = mss::index(l_dimm);
775777
//Printing as decimals because HB messes up floats
776-
FAPI_INF("%s max dram databus for DIMM in pos %d is %d, databus for idle is %d",
778+
FAPI_INF("%s max dram databus for DIMM in pos %d is %lu, databus for idle is %lu",
777779
mss::c_str(iv_target),
778780
l_pos,
779-
static_cast<uint64_t>( i_max_util[l_pos]),
780-
static_cast<uint64_t>( i_idle_util[l_pos]) );
781+
static_cast<uint64_t>(i_max_util[l_pos]),
782+
static_cast<uint64_t>(i_idle_util[l_pos]) );
781783
//Sum up the dimm's power to calculate the port power curve
782784
o_port_power_idle += calc_power(i_idle_util[l_pos], l_pos, l_rc);
783785
FAPI_TRY(l_rc, "calc_power failed");
@@ -835,9 +837,9 @@ fapi2::ReturnCode throttle<MC, TT>::calc_dimm_power(const double i_databus_idle,
835837
calc_power_uplift(iv_power_uplift_idle, o_dimm_power_idle[l_pos]);
836838
calc_power_uplift(iv_power_uplift, o_dimm_power_max[l_pos]);
837839

838-
FAPI_INF("Calc_dimm_power: dimm (%d) power max is %f, dimm slope %d, intercept %d for %s",
840+
FAPI_INF("Calc_dimm_power: dimm (%d) power max is %lu, dimm slope %d, intercept %d for %s",
839841
l_pos,
840-
o_dimm_power_max[l_pos],
842+
static_cast<uint64_t>(o_dimm_power_max[l_pos]),
841843
iv_pwr_slope[l_pos],
842844
iv_pwr_int[l_pos],
843845
mss::c_str(l_dimm));
@@ -876,11 +878,20 @@ fapi2::ReturnCode throttle<MC, TT>::calc_power_curve(const double i_power_idle,
876878
"Calculated zero for the divisor in calc_power_curve on target %s",
877879
mss::c_str(iv_target) );
878880

881+
FAPI_ASSERT (((i_power_max - i_power_idle) > 0),
882+
fapi2::MSS_CALC_POWER_CURVE_NEGATIVE_OR_ZERO_SLOPE()
883+
.set_PORT_TARGET(iv_target)
884+
.set_PORT_IDLE_POWER(i_power_idle)
885+
.set_PORT_MAX_UTIL_POWER(i_power_max)
886+
.set_RESULT(i_power_max - i_power_idle),
887+
"Calculated zero or negative value for the slope in calc_power_curve (%lu - %lu) on target %s",
888+
static_cast<uint64_t>(i_power_max), static_cast<uint64_t>(i_power_idle), mss::c_str(iv_target) );
889+
879890
o_slope = (i_power_max - i_power_idle) / l_divisor;
880891
o_int = i_power_idle - (o_slope * TT::IDLE_UTIL);
881-
FAPI_INF("Calc_power_curve: power idle is %f, max is %f, slope is %d, int is %d for %s",
882-
i_power_idle,
883-
i_power_max,
892+
FAPI_INF("Calc_power_curve: power idle is %lu, max is %lu, slope is %d, int is %d for %s",
893+
static_cast<uint64_t>(i_power_idle),
894+
static_cast<uint64_t>(i_power_max),
884895
o_slope,
885896
o_int,
886897
mss::c_str(iv_target));
@@ -916,8 +927,8 @@ void throttle<MC, TT>::calc_util_usage(const uint32_t i_slope,
916927
// Check for the minimum threshnold and update if need be
917928
if(o_util < TT::MIN_UTIL)
918929
{
919-
FAPI_INF("Calculated utilization (%f) is less than the minimum utilization: %lu. Setting to minimum value for %s",
920-
o_util,
930+
FAPI_INF("Calculated utilization (%lu) is less than the minimum utilization: %lu. Setting to minimum value for %s",
931+
static_cast<uint64_t>(o_util),
921932
TT::MIN_UTIL, mss::c_str(iv_target));
922933
o_util = TT::MIN_UTIL;
923934
}
@@ -955,10 +966,10 @@ fapi2::ReturnCode throttle<MC, TT>::calc_power_from_n (const uint16_t i_n_slot,
955966

956967
//Determine the utilization for each DIMM that will maximize the port power
957968
FAPI_TRY( calc_split_util(l_calc_util_slot, l_calc_util_port, l_calc_databus_port_max),
958-
"Error splitting the utilization for target %s with slot utilizatio %f and port util %f",
969+
"Error splitting the utilization for target %s with slot utilization %lu and port util %lu",
959970
mss::c_str(iv_target),
960-
l_calc_util_slot,
961-
l_calc_util_port);
971+
static_cast<uint64_t>(l_calc_util_slot),
972+
static_cast<uint64_t>(l_calc_util_port));
962973

963974
FAPI_TRY( calc_port_power(l_calc_databus_port_idle,
964975
l_calc_databus_port_max,
@@ -1051,9 +1062,9 @@ fapi2::ReturnCode throttle<MC, TT>::calc_split_util(
10511062
fapi2::MSS_SLOT_UTIL_EXCEEDS_PORT()
10521063
.set_SLOT_UTIL(i_util_slot)
10531064
.set_PORT_UTIL(i_util_port),
1054-
"The slot utilization (%f) exceeds the port's utilization (%f) for %s",
1055-
i_util_slot,
1056-
i_util_port,
1065+
"The slot utilization (%lu) exceeds the port's utilization (%lu) for %s",
1066+
static_cast<uint64_t>(i_util_slot),
1067+
static_cast<uint64_t>(i_util_port),
10571068
mss::c_str(iv_target));
10581069

10591070
if (l_count_dimms == 0)
@@ -1070,9 +1081,9 @@ fapi2::ReturnCode throttle<MC, TT>::calc_split_util(
10701081
//assumptions slot <= port, l_count_dimms <=2
10711082
if (i_util_slot * l_count_dimms > i_util_port)
10721083
{
1073-
FAPI_INF("i_util_slot is %f, i_util_port is %f, l_count_dimms is %d for %s",
1074-
i_util_slot,
1075-
i_util_port,
1084+
FAPI_INF("i_util_slot is %lu, i_util_port is %lu, l_count_dimms is %d for %s",
1085+
static_cast<uint64_t>(i_util_slot),
1086+
static_cast<uint64_t>(i_util_port),
10761087
l_count_dimms,
10771088
mss::c_str(iv_target));
10781089
const uint8_t l_high_pos = (iv_pwr_slope[0] >= iv_pwr_slope[1]) ? 0 : 1;
@@ -1087,12 +1098,12 @@ fapi2::ReturnCode throttle<MC, TT>::calc_split_util(
10871098
0
10881099
);
10891100

1090-
FAPI_INF("Split utilization for target %s, DIMM in %d gets %f, DIMM in %d gets %f",
1101+
FAPI_INF("Split utilization for target %s, DIMM in %d gets %lu, DIMM in %d gets %lu",
10911102
mss::c_str(iv_target),
10921103
l_high_pos,
1093-
o_util_dimm_max[l_high_pos],
1104+
static_cast<uint64_t>(o_util_dimm_max[l_high_pos]),
10941105
!l_high_pos,
1095-
o_util_dimm_max[!l_high_pos]);
1106+
static_cast<uint64_t>(o_util_dimm_max[!l_high_pos]));
10961107
}
10971108
else
10981109
{

src/import/generic/procedures/xml/error_info/generic_error.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,21 @@
953953
</callout>
954954
</hwpError>
955955

956+
<hwpError>
957+
<rc>RC_MSS_CALC_POWER_CURVE_NEGATIVE_OR_ZERO_SLOPE</rc>
958+
<description>
959+
Power curve slope equals 0 or is negative
960+
</description>
961+
<ffdc>PORT_TARGET</ffdc>
962+
<ffdc>PORT_IDLE_POWER</ffdc>
963+
<ffdc>PORT_MAX_UTIL_POWER</ffdc>
964+
<ffdc>RESULT</ffdc>
965+
<callout>
966+
<procedure>CODE</procedure>
967+
<priority>HIGH</priority>
968+
</callout>
969+
</hwpError>
970+
956971
<hwpError>
957972
<rc>RC_MSS_NO_PORT_POWER_LIMIT</rc>
958973
<description>

0 commit comments

Comments
 (0)