From 55de7473be4c94d2c213ff69dd12d0a426477aff Mon Sep 17 00:00:00 2001 From: Brian Silver Date: Thu, 30 Jun 2016 14:19:50 -0500 Subject: Change procedures to support unpopulated MC Change-Id: Iddd15d19fc1b55d3f42cba14d76459a3ce71a37e Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/26498 Tested-by: Jenkins Server Tested-by: Hostboot CI Reviewed-by: Louis Stermole Reviewed-by: STEPHEN GLANCY Reviewed-by: Joseph J. McGill Reviewed-by: Jennifer A. Stofer Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/26501 Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell --- .../procedures/hwp/memory/lib/utils/conversions.H | 8 ++++---- .../p9/procedures/hwp/memory/lib/utils/count_dimm.H | 1 + .../p9/procedures/hwp/memory/p9_mss_ddr_phy_reset.C | 9 +++++++++ .../hwp/memory/p9_mss_draminit_training.C | 9 +++++++++ .../chips/p9/procedures/hwp/memory/p9_mss_freq.C | 21 +++++++++++++-------- .../p9/procedures/hwp/memory/p9_mss_freq_system.C | 18 ++++++++++++++++++ .../chips/p9/procedures/hwp/memory/p9_mss_memdiag.C | 9 +++++++++ .../p9/procedures/hwp/memory/p9_mss_scominit.C | 13 +++++++++++++ .../chips/p9/procedures/hwp/memory/p9_mss_scrub.C | 10 ++++++++++ .../procedures/hwp/memory/tests/mss_memdiags_ut.C | 9 +++++++++ 10 files changed, 95 insertions(+), 12 deletions(-) diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H b/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H index b801ccf0b..c219b956f 100644 --- a/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H +++ b/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H @@ -92,7 +92,7 @@ inline T freq_to_ps(const T i_transfer_rate) T l_dimm_freq = i_transfer_rate / 2; // ps per clock (note value is rounded down) - return CONVERT_PS_IN_A_US / l_dimm_freq; + return CONVERT_PS_IN_A_US / ((l_dimm_freq == 0) ? 1 : l_dimm_freq); } /// @@ -107,7 +107,7 @@ inline T ps_to_freq(const T i_time_in_ps) // reverse of freq_to_ps function, solving for freq // since running at DDR, data is transferred on both rising & falling edges // hence the 2X factor - return (2 * CONVERT_PS_IN_A_US) / i_time_in_ps; + return (2 * CONVERT_PS_IN_A_US) / ((i_time_in_ps == 0) ? 1 : i_time_in_ps); } /// @@ -140,7 +140,7 @@ inline uint64_t ps_to_cycles(const fapi2::Target& i_target, const uint64_t i_ // Hoping the compiler figures out how to do these together. l_divisor = freq_to_ps(l_freq); - l_quotient = i_ps / l_divisor; + l_quotient = i_ps / ((l_divisor == 0) ? 1 : l_divisor); l_remainder = i_ps % l_divisor; // Make sure we add a cycle if there wasn't an even number of cycles in the input @@ -222,7 +222,7 @@ inline uint64_t cycles_to_time(const fapi2::Target& i_target, const uint64_t { // Hoping the compiler figures out how to do these together. uint64_t l_dividend = cycles_to_ps(i_target, i_cycles); - uint64_t l_quotient = l_dividend / D; + uint64_t l_quotient = l_dividend / ((D == 0) ? 1 : D); uint64_t l_remainder = l_dividend % D; // Make sure we add time if there wasn't an even number of cycles diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/utils/count_dimm.H b/src/import/chips/p9/procedures/hwp/memory/lib/utils/count_dimm.H index b77763b1e..66d926b21 100644 --- a/src/import/chips/p9/procedures/hwp/memory/lib/utils/count_dimm.H +++ b/src/import/chips/p9/procedures/hwp/memory/lib/utils/count_dimm.H @@ -32,6 +32,7 @@ #include #include +#include namespace mss { diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_ddr_phy_reset.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_ddr_phy_reset.C index 57822a0ca..e3d47546c 100644 --- a/src/import/chips/p9/procedures/hwp/memory/p9_mss_ddr_phy_reset.C +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_ddr_phy_reset.C @@ -34,6 +34,7 @@ #include #include +#include using fapi2::TARGET_TYPE_MCBIST; @@ -49,6 +50,14 @@ extern "C" { FAPI_INF("********* %s start *********", __func__); + // If there are no DIMM we don't need to bother. In fact, we can't as we didn't setup + // attributes for the PHY, etc. + if (mss::count_dimm(i_target) == 0) + { + FAPI_INF("... skipping ddr_phy_reset %s - no DIMM ...", mss::c_str(i_target)); + return fapi2::FAPI2_RC_SUCCESS; + } + // Initialize via scoms. Could be put in to p9_mss_scominit.C if that ever exists BRS. FAPI_TRY( mss::phy_scominit(i_target) ); diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_draminit_training.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_draminit_training.C index 0cbb14324..411bc39fa 100644 --- a/src/import/chips/p9/procedures/hwp/memory/p9_mss_draminit_training.C +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_draminit_training.C @@ -31,6 +31,7 @@ #include #include +#include using fapi2::TARGET_TYPE_MCBIST; using fapi2::TARGET_TYPE_MCA; @@ -50,6 +51,14 @@ extern "C" FAPI_INF("Start draminit training"); + // If there are no DIMM we don't need to bother. In fact, we can't as we didn't setup + // attributes for the PHY, etc. + if (mss::count_dimm(i_target) == 0) + { + FAPI_INF("... skipping draminit_training %s - no DIMM ...", mss::c_str(i_target)); + return fapi2::FAPI2_RC_SUCCESS; + } + uint8_t l_reset_disable = 0; FAPI_TRY( mss::mrw_draminit_reset_disable(l_reset_disable) ); diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq.C index 3b0fc2eb2..292e0b0e1 100644 --- a/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq.C +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_freq.C @@ -81,8 +81,12 @@ extern "C" "Failed check for freq_override()"); #endif - // Default values for initialization as well as empty dimm list case - uint64_t l_min_dimm_freq = 0; + // We set this to a non-0 so we avoid divide-by-zero errors in the conversions which + // go from clocks to time (and vice versa.) We have other bugs if there was really + // no mt/s determined and there really is a DIMM installed, so this is ok. + // We pick the maximum frequency supported by the system as the default. + // TK remove this when we can ask the MRW for the fastest the system supports + uint64_t l_min_dimm_freq = fapi2::ENUM_ATTR_MSS_FREQ_MT2666; uint64_t l_desired_cas_latency = 0; if(l_cas_latency.iv_dimm_list_empty) @@ -109,14 +113,15 @@ extern "C" FAPI_INF("Selected DIMM speed from supported speeds: %d", l_min_dimm_freq); - // Set attributes - FAPI_TRY(mss::set_freq_attrs(i_target, l_min_dimm_freq), - "Failed set_freq_attrs()"); - - FAPI_TRY(mss::set_CL_attr(i_target, l_desired_cas_latency ), - "Failed set_CL_attr()"); }// end else + // Set attributes + FAPI_TRY(mss::set_freq_attrs(i_target, l_min_dimm_freq), + "Failed set_freq_attrs()"); + + FAPI_TRY(mss::set_CL_attr(i_target, l_desired_cas_latency ), + "Failed set_CL_attr()"); + FAPI_INF( "Final Chosen Frequency: %d", l_min_dimm_freq); FAPI_INF( "Final Chosen CL: %d", l_desired_cas_latency); 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 index 652749e06..128bd1498 100644 --- 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 @@ -34,6 +34,7 @@ #include #include +#include #include using fapi2::TARGET_TYPE_SYSTEM; @@ -52,6 +53,23 @@ extern "C" { FAPI_INF("----- In p9_mss_freq_system ----"); + // If there are no DIMM we don't need to bother. In fact, we can't as we didn't setup + // attributes for the PHY, etc. If there is even one DIMM on any of this list of MCBIST, + // we do the right thing. + uint64_t l_dimm_count = 0; + std::for_each( i_targets.begin(), i_targets.end(), + [&l_dimm_count](const fapi2::Target& i_target) + { + l_dimm_count += mss::count_dimm(i_target); + } + ); + + if (l_dimm_count == 0) + { + FAPI_INF("... skipping freq_system - no DIMM ..."); + return fapi2::FAPI2_RC_SUCCESS; + } + std::map< fapi2::Target, uint64_t > l_freq_map; uint32_t l_nest_freq = 0; uint8_t l_required_sync_mode = 0; diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_memdiag.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_memdiag.C index 0b35ed2bf..83f4f4376 100644 --- a/src/import/chips/p9/procedures/hwp/memory/p9_mss_memdiag.C +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_memdiag.C @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -50,6 +51,14 @@ extern "C" { FAPI_INF("Start memdiag"); + // If there are no DIMM we don't need to bother. In fact, we can't as we didn't setup + // attributes for the PHY, etc. + if (mss::count_dimm(i_target) == 0) + { + FAPI_INF("... skipping mem_diags %s - no DIMM ...", mss::c_str(i_target)); + return fapi2::FAPI2_RC_SUCCESS; + } + // Unmask the memdiags FIR FAPI_TRY( mss::unmask_memdiags_errors(i_target) ); diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C index 964937c53..54571201a 100644 --- a/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C @@ -32,6 +32,7 @@ #include #include #include +#include using fapi2::TARGET_TYPE_MCA; using fapi2::TARGET_TYPE_MCBIST; @@ -50,8 +51,20 @@ fapi2::ReturnCode p9_mss_scominit( const fapi2::Target& i_ta fapi2::ReturnCode l_rc; fapi2::Target FAPI_SYSTEM; + if (mss::count_dimm(i_target) == 0) + { + FAPI_INF("... skipping mss_scominit %s - no DIMM ...", mss::c_str(i_target)); + return fapi2::FAPI2_RC_SUCCESS; + } + for (auto l_mca_target : l_mca_targets ) { + if (mss::count_dimm(l_mca_target) == 0) + { + FAPI_INF("... skipping mca_scominit %s - no DIMM ...", mss::c_str(l_mca_target)); + continue; + } + FAPI_EXEC_HWP(l_rc, p9_mca_scom, l_mca_target, i_target, l_mca_target.getParent(), FAPI_SYSTEM ); diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_scrub.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_scrub.C index 5b131da65..a77004bd6 100644 --- a/src/import/chips/p9/procedures/hwp/memory/p9_mss_scrub.C +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_scrub.C @@ -36,6 +36,7 @@ #include #include #include +#include using fapi2::TARGET_TYPE_MCBIST; using fapi2::TARGET_TYPE_MCA; @@ -53,6 +54,15 @@ fapi2::ReturnCode p9_mss_scrub( const fapi2::Target& i_targe // If we're running in the simulator, we want to only touch the addresses which training touched uint8_t is_sim = 0; + + // If there are no DIMM we don't need to bother. In fact, we can't as we didn't setup + // attributes for the PHY, etc. + if (mss::count_dimm(i_target) == 0) + { + FAPI_INF("... skipping scrub for %s - no DIMM ...", mss::c_str(i_target)); + return fapi2::FAPI2_RC_SUCCESS; + } + FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_IS_SIMULATION, fapi2::Target(), is_sim) ); if (is_sim) diff --git a/src/import/chips/p9/procedures/hwp/memory/tests/mss_memdiags_ut.C b/src/import/chips/p9/procedures/hwp/memory/tests/mss_memdiags_ut.C index afd81a6bd..21e40a214 100644 --- a/src/import/chips/p9/procedures/hwp/memory/tests/mss_memdiags_ut.C +++ b/src/import/chips/p9/procedures/hwp/memory/tests/mss_memdiags_ut.C @@ -40,6 +40,7 @@ #include #include +#include #include using fapi2::FAPI2_RC_SUCCESS; @@ -266,6 +267,14 @@ TEST_CASE_METHOD(mss::test::mcbist_target_test_fixture, "memdiags", "[memdiags]" } } + + // If there are no DIMM we don't need to bother. + if (mss::count_dimm(i_target) == 0) + { + return 0; + } + + // Note that the testing of the memdiags operations leverages the helper directly // is it is more flexible allowing better control over simulation environments. SECTION("Test sf_init") -- cgit v1.2.1