Skip to content

Commit

Permalink
Improve WR_VREF shmoo algorithm in p9c training_adv
Browse files Browse the repository at this point in the history
Change-Id: I0f07072b4e5e078c8ea3845abbf8933a03a8bf62
CQ:SW439234
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/60047
Dev-Ready: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
Reviewed-by: ANDRE A. MARIN <aamarin@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/60056
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>
Disable-CI: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
  • Loading branch information
stermole authored and crgeddes committed Jul 27, 2018
1 parent 832ce22 commit 85a561d
Show file tree
Hide file tree
Showing 9 changed files with 676 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ enum consts : size_t
BITS_PER_PORT = (LANES_PER_BLOCK * DP18_INSTANCES),

DATA_BYTES_PER_PORT = 8,
SP_BYTES_PER_PORT = 2,
SP_ECC_BYTES_PER_PORT = 2,
SP_ECC_BYTES_PER_PORT_ISDIMM = 1,

MAX_DRAMS_PER_RANK_X8 = DATA_BYTES_PER_PORT + SP_ECC_BYTES_PER_PORT,
MAX_DRAMS_PER_RANK_X4 = MAX_DRAMS_PER_RANK_X8 * MAX_NIBBLES_PER_BYTE,
MAX_DRAMS_PER_RANK_X8_ISDIMM = DATA_BYTES_PER_PORT + SP_ECC_BYTES_PER_PORT_ISDIMM,
MAX_DRAMS_PER_RANK_X4_ISDIMM = MAX_DRAMS_PER_RANK_X8_ISDIMM * MAX_NIBBLES_PER_BYTE,

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1148,18 +1148,7 @@ extern "C" {
}

uint8_t num_ranks_array[MAX_PORTS_PER_MBA][MAX_DIMM_PER_PORT] = {0}; //[port][dimm]
uint8_t dram_stack[MAX_PORTS_PER_MBA][MAX_DIMM_PER_PORT] = {0};

FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CEN_EFF_STACK_TYPE, i_target, dram_stack));

if(dram_stack[0][0] == fapi2::ENUM_ATTR_CEN_EFF_STACK_TYPE_STACK_3DS)
{
FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CEN_EFF_NUM_RANKS_PER_DIMM, i_target, num_ranks_array));
}
else
{
FAPI_ATTR_GET(fapi2::ATTR_CEN_EFF_NUM_MASTER_RANKS_PER_DIMM, i_target, num_ranks_array);
}
FAPI_ATTR_GET(fapi2::ATTR_CEN_EFF_NUM_MASTER_RANKS_PER_DIMM, i_target, num_ranks_array);

//loops through all DIMMs all Ranks
for(uint8_t l_dimm = 0; l_dimm < MAX_DIMM_PER_PORT; l_dimm++)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* Contributors Listed Below - COPYRIGHT 2016,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -40,6 +40,7 @@
// Includes
//----------------------------------------------------------------------
#include <fapi2.H>
#include <dimmConsts.H>
#include <p9c_mss_shmoo_common.H>
typedef fapi2::ReturnCode (*p9c_mss_draminit_training_advanced_FP_t)(const fapi2::Target<fapi2::TARGET_TYPE_MBA>&);

Expand All @@ -57,6 +58,40 @@ enum shmoo_param
RCV_IMP = 0x20
};

/// @brief Struct to contain WR_VREF shmoo test data map keys
struct dram_key
{
uint8_t port;
uint8_t dimm;
uint8_t rank;
uint8_t nibble;

///
/// @brief dram_key less than operator (for use in std::map)
/// @param[in] k the dram_key to compare against
/// @return true if this dram_key is less than the given one, false otherwise
///
bool operator<(const dram_key& k) const
{
if (port != k.port)
{
return (port < k.port);
}

if (dimm != k.dimm)
{
return (dimm < k.dimm);
}

if (rank != k.rank)
{
return (rank < k.rank);
}

return (nibble < k.nibble);
}
};

extern "C"
{
///
Expand Down Expand Up @@ -151,13 +186,16 @@ extern "C"
/// @param[out] o_left_margin returns left margin delay (setup) in ps
/// @param[out] o_right_margin returns right margin delay (hold) in ps
/// @param[in] i_shmoo_param Shmoo
/// @param[in] i_pda_nibble_table
/// @param[in] i_pda_nibble_table table of Vref values and measured margins (hence the last [2] array parameter)
/// @return FAPI2_RC_SUCCESS iff successful
///
fapi2::ReturnCode delay_shmoo_ddr4_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target_mba, const uint8_t i_port,
fapi2::ReturnCode delay_shmoo_ddr4_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target_mba,
const uint8_t i_port,
const shmoo_type_t i_shmoo_type_valid,
uint32_t* o_left_margin, uint32_t* o_right_margin,
const uint32_t i_shmoo_param, uint32_t i_pda_nibble_table[2][2][4][16][2]);
uint32_t* o_left_margin,
uint32_t* o_right_margin,
const uint32_t i_shmoo_param,
uint32_t (&i_pda_nibble_table)[MAX_PORTS_PER_MBA][MAX_DIMM_PER_PORT][MAX_RANKS_PER_DIMM][MAX_DRAMS_PER_RANK_X4][2]);
///
/// @brief Finds better timing margin and returns the index
/// @param[in] i_shmoo_param_valid PARAM_NONE, DRV_IMP, SLEW_RATE, WR_VREF, RD_VREF, RCV_IMP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4436,7 +4436,7 @@ extern "C"
/// @return FAPI2_RC_SUCCESS iff successful
///
fapi2::ReturnCode generic_shmoo::get_nibble_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
uint32_t pda_nibble_table[MAX_PORTS_PER_MBA][MAX_DIMM_PER_PORT][MAX_RANKS_PER_DIMM][16][2])
uint32_t (&pda_nibble_table)[MAX_PORTS_PER_MBA][MAX_DIMM_PER_PORT][MAX_RANKS_PER_DIMM][MAX_DRAMS_PER_RANK_X4][2])
{
uint8_t l_dimm = 0;
uint8_t num_ranks_per_dimm[MAX_PORTS_PER_MBA][MAX_DIMM_PER_PORT] = {0};
Expand All @@ -4450,7 +4450,7 @@ extern "C"
{
for(uint8_t l_dq = 0; l_dq < 4; l_dq++)
{
for(uint8_t l_n = 0; l_n < 16; l_n++)
for(uint8_t l_n = 0; l_n < (iv_MAX_BYTES * MAX_NIBBLES_PER_BYTE); l_n++)
{
pda_nibble_table[l_p][l_dimm][l_rnk][l_n][0] = iv_vref_mul;

Expand Down Expand Up @@ -4841,3 +4841,68 @@ extern "C"
}

}//Extern C

///
/// @brief helper function for testing ternary search
/// @param[in] i_results map of test results that have been found so far
/// @param[in,out] io_low_bound lower search boundary's vref value
/// @param[in,out] io_high_bound higher search boundary's vref value
/// @param[out] o_test_vref next Vref value to test
/// @param[out] o_complete true if the search is complete, false otherwise
/// @return FAPI2_RC_SUCCESS if no errors encountered
///
fapi2::ReturnCode ternary_search_helper(const std::map<uint8_t, uint32_t>& i_results,
uint8_t& io_low_bound,
uint8_t& io_high_bound,
uint8_t& o_test_vref,
bool& o_complete)
{
// This value is for termination of the search algorithm.
// When the search range gets below this, the answer is the average of the high/low bounds
constexpr uint8_t MIN_BOUNDS = 3;

while(true)
{
// First calculate the next step value (how much to move bound on end with lowest margin)
const uint32_t l_step = (io_high_bound - io_low_bound) / 3;

// See if we've already got results for each test point
auto l_low_margin_it = i_results.find(io_low_bound + l_step);
auto l_high_margin_it = i_results.find(io_high_bound - l_step);

// If we don't have results for the next test points, return the next value to test
if (l_low_margin_it == i_results.end())
{
o_test_vref = io_low_bound + l_step;
o_complete = false;
return fapi2::FAPI2_RC_SUCCESS;
}

if (l_high_margin_it == i_results.end())
{
o_test_vref = io_high_bound - l_step;
o_complete = false;
return fapi2::FAPI2_RC_SUCCESS;
}

// Next, move in low or high bound, depending on which test point had the lowest margin
if (l_low_margin_it->second < l_high_margin_it->second)
{
io_low_bound += l_step;
}
else
{
io_high_bound -= l_step;
}

// If we're at our minimum search range, return the average of the bounds
if ((io_high_bound - io_low_bound) < MIN_BOUNDS)
{
o_test_vref = (io_high_bound + io_low_bound) / 2;
o_complete = true;
return fapi2::FAPI2_RC_SUCCESS;
}

// If not, loop around and continue the search
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define SHMOO_DEBUG2 0
#include <p9c_mss_shmoo_common.H>
#include <p9c_mss_mcbist.H>
#include <map>

///
/// @brief MSS Generic Shmoo Class.. Inherits from PHY access class and the knob abstraction
Expand Down Expand Up @@ -414,7 +415,7 @@ class generic_shmoo
/// @return FAPI2_RC_SUCCESS iff successful
///
fapi2::ReturnCode get_nibble_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
uint32_t pda_nibble_table[2][2][4][16][2]);
uint32_t (&pda_nibble_table)[MAX_PORTS_PER_MBA][MAX_DIMM_PER_PORT][MAX_RANKS_PER_DIMM][MAX_DRAMS_PER_RANK_X4][2]);

///
/// @brief used to find right and left bound
Expand All @@ -439,4 +440,22 @@ class generic_shmoo
fapi2::ReturnCode print_report2(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

};

// Below are various training_advanced helper functions, placed here so they can be unit tested in p9c_mss_generic_shmoo_ut.C

///
/// @brief helper function for testing ternary search
/// @param[in] i_results map of test results that have been found so far
/// @param[in,out] io_low_bound lower search boundary's vref value
/// @param[in,out] io_high_bound higher search boundary's vref value
/// @param[out] o_test_vref next Vref value to test
/// @param[out] o_complete true if the search is complete, false otherwise
/// @return FAPI2_RC_SUCCESS if no errors encountered
///
fapi2::ReturnCode ternary_search_helper(const std::map<uint8_t, uint32_t>& i_results,
uint8_t& io_low_bound,
uint8_t& io_high_bound,
uint8_t& o_test_vref,
bool& o_complete);

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ extern "C"
uint8_t l_attr_eff_dimm_type_u8 = 0;
uint8_t l_dqBitmap[DIMM_DQ_RANK_BITMAP_SIZE] = {0};
uint8_t l_dq[DATA_BYTES_PER_PORT] = { 0 };
uint8_t l_sp[SP_BYTES_PER_PORT] = { 0 };
uint8_t l_sp[SP_ECC_BYTES_PER_PORT] = { 0 };
uint16_t l_index0 = 0;
uint8_t l_index_sp = 0;
uint16_t l_sp_isdimm = 0xff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,32 @@ Set by: PLL settings written by Dave Cadigan</description>
<attribute>
<id>ATTR_CEN_MSS_VREF_CAL_CNTL</id>
<targetType>TARGET_TYPE_MEMBUF_CHIP</targetType>
<description>Training Control over IPL - ENUM - 0x00=DISABLE /Skip V-ref Train; 0x01=DRAM - Enable V-Ref Train DRAM Level; 0x02=RANK Level Training; 0x03=Box shmoo;
<description>Training Control over IPL - ENUM - 0x00=DISABLE /Skip V-ref Train; 0x01=P8_DRAM - Enable V-Ref Train DRAM Level (P8 algorithm); 0x02=P8_RANK Level Training (P8 algorithm); 0x03=Box shmoo; 0x04=Ternary shmoo
Default Value = 0x03 for box shmoo on all platforms
</description>
<valueType>uint8</valueType>
<enum>DISABLE = 0, DRAM = 1, RANK = 2, BOX = 3</enum>
<enum>DISABLE = 0, P8_DRAM = 1, P8_RANK = 2, BOX = 3, TERNARY = 4</enum>
<default>3</default>
<platInit/>
<odmVisable/>
<odmChangeable/>
<persistRuntime/>
</attribute>

<attribute>
<id>ATTR_CEN_MSS_VREF_CAL_DELTA_FROM_NOMINAL</id>
<targetType>TARGET_TYPE_MBA</targetType>
<description>Controls search boundaries for WR_VREF Ternary shmoo. Value is a delta of register ticks from nominal
Default Value = 0x08 (taken from characterization values), Max value = 0x19
</description>
<valueType>uint8</valueType>
<default>0x08</default>
<platInit/>
<odmVisable/>
<odmChangeable/>
<persistRuntime/>
</attribute>

<!--
<attribute>
<id>ATTR_CEN_MSS_DIMM_MFG_ID_CODE</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- -->
<!-- OpenPOWER HostBoot Project -->
<!-- -->
<!-- Contributors Listed Below - COPYRIGHT 2016,2017 -->
<!-- Contributors Listed Below - COPYRIGHT 2016,2018 -->
<!-- [+] International Business Machines Corp. -->
<!-- -->
<!-- -->
Expand Down Expand Up @@ -101,4 +101,20 @@
</callout>
</hwpError>

<hwpError>
<rc>RC_CEN_MSS_WR_VREF_CAL_DELTA_INVALID_VALUE</rc>
<description>
The attribute ATTR_CEN_MSS_VREF_CAL_DELTA_FROM_NOMINAL was overridden
with an invalid value
</description>
<ffdc>MBA_TARGET</ffdc>
<ffdc>DELTA_VALUE</ffdc>
<ffdc>NOMINAL_VREF</ffdc>
<ffdc>DELTA_MAX</ffdc>
<callout>
<procedure>CODE</procedure>
<priority>HIGH</priority>
</callout>
</hwpError>

</hwpErrors>

0 comments on commit 85a561d

Please sign in to comment.