diff options
Diffstat (limited to 'src/usr/isteps/istepHelperFuncs.H')
-rw-r--r-- | src/usr/isteps/istepHelperFuncs.H | 204 |
1 files changed, 114 insertions, 90 deletions
diff --git a/src/usr/isteps/istepHelperFuncs.H b/src/usr/isteps/istepHelperFuncs.H index 6b877fe19..1f6a5c8dd 100644 --- a/src/usr/isteps/istepHelperFuncs.H +++ b/src/usr/isteps/istepHelperFuncs.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015 */ +/* Contributors Listed Below - COPYRIGHT 2015,2016 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -31,6 +31,12 @@ #include <targeting/common/utilFilter.H> #include <attributetraits.H> #include <attributeenums.H> +#include <initservice/isteps_trace.H> +#include <fapi2.H> + +// fapi2 HWP invoker +#include <fapi2/plat_hwp_invoker.H> + /** * @brief Enum specifying what attributes should be used to set the * memory _EFF_CONFIG attributes @@ -42,6 +48,15 @@ enum EFF_CONFIG_ATTRIBUTES_BASE POST_DRAM_INIT = 0x01, ///< Use POST_DRAM_INIT attributes if non-zero }; +/** + * @brief Enum for per-domain control of different voltages + */ +enum MSS_PROGRAM_TYPE +{ + POWERON = 0, // domain is programmed as part of regular power on sequence + STATIC = 1, // domain needs to be programmed, no special computation needed + DYNAMIC = 2, // domain needs to be programmed, uses dynamic vid logic +}; // // Helper function to set _EFF_CONFIG attributes for HWPs @@ -51,73 +66,72 @@ void set_eff_config_attrs_helper( const EFF_CONFIG_ATTRIBUTES_BASE i_base, /** - * @brief Compares two memory buffer targets based on the voltage domain ID for + * @brief Compares two mcbist targets based on the voltage domain ID for * the voltage domain given by the template parameter. Used for sorting - * memory buffer targets within containers. API should be called in well + * mcbist targets within containers. API should be called in well * controlled conditions where the input restrictions can be guaranteed. * - * @param[in] i_pMembufLhs - * Left hand side memory buffer target. Must be a memory buffer target, + * @param[in] i_pMcbistLhs + * Left hand side mcbist target. Must be a mcbist target, * and must not be NULL. These conditions are not enforced internally. * - * @param[in] i_pMembufRhs - * Right hand side memory buffer target. Must be a memory buffer target, + * @param[in] i_pMcbistRhs + * Right hand side mcbist target. Must be a mcbist target, * and must not be NULL. These conditions are not enforced internally. * * @tparam VOLTAGE_DOMAIN_ID_ATTR * Attribute corresponding to voltage domain to compare * - * @return Bool indicating whether LHS memory buffer target's voltage domain ID - * for the specified domain logically precedes the RHS memory buffer + * @return Bool indicating whether LHS mcbist target's voltage domain ID + * for the specified domain logically precedes the RHS mcbist * target's voltage domain ID for the same domain */ template < const TARGETING::ATTRIBUTE_ID VOLTAGE_DOMAIN_ID_ATTR> -bool _compareMembufWrtVoltageDomain( - TARGETING::Target* i_pMembufLhs, - TARGETING::Target* i_pMembufRhs) +bool _compareMcbistWrtVoltageDomain( + TARGETING::Target* i_pMcbistLhs, + TARGETING::Target* i_pMcbistRhs) { typename TARGETING::AttributeTraits< VOLTAGE_DOMAIN_ID_ATTR >::Type - lhsDomain = i_pMembufLhs->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(); + lhsDomain = i_pMcbistLhs->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(); typename TARGETING::AttributeTraits< VOLTAGE_DOMAIN_ID_ATTR >::Type - rhsDomain = i_pMembufRhs->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(); + rhsDomain = i_pMcbistRhs->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(); return lhsDomain < rhsDomain; } + + //****************************************************************************** -// setMemoryVoltageDomainOffsetVoltage +// computeDynamicMemoryVoltage //****************************************************************************** // TODO via RTC: 110777 -// Optimize setMemoryVoltageDomainOffsetVoltage into templated and non-templated +// Optimize computeDynamicMemoryVoltage into templated and non-templated // pieces to reduce code size -/* - * TODO: RTC:133830 Re-enable this function, the following ATTRs don't seem to - * exist currently. -template< const ATTRIBUTE_ID OFFSET_DISABLEMENT_ATTR, - const ATTRIBUTE_ID OFFSET_VOLTAGE_ATTR, - const ATTRIBUTE_ID VOLTAGE_DOMAIN_ID_ATTR > -errlHndl_t setMemoryVoltageDomainOffsetVoltage() +template< const TARGETING::ATTRIBUTE_ID OFFSET_DISABLEMENT_ATTR, + const TARGETING::ATTRIBUTE_ID VOLTAGE_DOMAIN_ID_ATTR > +errlHndl_t computeDynamicMemoryVoltage() { - TRACDCOMP(ISTEPS_TRACE::g_trac_isteps_trace, - "setMemoryVoltageDomainOffsetVoltage enter"); + TRACDCOMP(ISTEPS_TRACE::g_trac_isteps_trace, + "computeDynamicMemoryVoltage enter"); - errlHndl_t pError = NULL; - - do { + errlHndl_t pError = NULL; + do + { TARGETING::Target* pSysTarget = NULL; TARGETING::targetService().getTopLevelTarget(pSysTarget); - assert(pSysTarget != NULL,"setMemoryVoltageDomainOffsetVoltage: " - "System target was NULL."); + assert(pSysTarget != NULL, + "computeDynamicMemoryVoltage: System target was NULL."); - typename AttributeTraits< OFFSET_DISABLEMENT_ATTR >::Type - disableOffsetVoltage = + typename TARGETING::AttributeTraits< OFFSET_DISABLEMENT_ATTR >::Type + domainProgram = pSysTarget->getAttr< OFFSET_DISABLEMENT_ATTR >(); - if(disableOffsetVoltage) + + if(domainProgram != MSS_PROGRAM_TYPE::DYNAMIC) { TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "INFO: Offset voltage processing disabled for domain type 0x%08X.", + "INFO: Dynamic offset voltage processing disabled for domain type 0x%08X.", OFFSET_DISABLEMENT_ATTR); break; } @@ -126,7 +140,7 @@ errlHndl_t setMemoryVoltageDomainOffsetVoltage() "INFO: Offset voltage processing enabled for domain type 0x%08X.", OFFSET_DISABLEMENT_ATTR); - typedef fapi::ReturnCode (*pOffsetFn_t)(std::vector<fapi::Target>&); + typedef fapi2::ReturnCode (*pOffsetFn_t)(std::vector<fapi2::Target<fapi2::TARGET_TYPE_MCS>>&); struct { @@ -136,17 +150,18 @@ errlHndl_t setMemoryVoltageDomainOffsetVoltage() bool callIfAllNonFunc; } fnMap[] = { - +/* TODO: RTC 157349 -- These HWPs don't exist yet {TARGETING::ATTR_AVDD_ID, - mss_volt_avdd_offset,"mss_volt_avdd_offset", true}, + p9_mss_dynamic_vid_avdd,"p9_mss_dynamic_vid_avdd", true}, {TARGETING::ATTR_VDD_ID , - mss_volt_vdd_offset ,"mss_volt_vdd_offset", true}, + p9_mss_dynamic_vid_vdd ,"p9_mss_dynamic_vid_vdd", true}, {TARGETING::ATTR_VCS_ID , - mss_volt_vcs_offset ,"mss_volt_vcs_offset", true}, - {TARGETING::ATTR_VMEM_ID, - mss_volt_vddr_offset,"mss_volt_vddr_offset", false}, + p9_mss_dynamic_vcs_avdd ,"p9_mss_dynamic_vcs_avdd", true}, + {TARGETING::ATTR_VDDR_ID, + p9_mss_dynamic_vid_vddr,"p9_mss_dynamic_vid_vddr", false}, {TARGETING::ATTR_VPP_ID , - mss_volt_vpp_offset ,"mss_volt_vpp_offset", false} + p9_mss_dynamic_vid_vpp ,"p9_mss_dynamic_vid_vpp", false} +*/ }; size_t recordIndex = 0; @@ -159,33 +174,29 @@ errlHndl_t setMemoryVoltageDomainOffsetVoltage() } } - if(recordIndex >= records) - { - assert(recordIndex < records, - "Code bug! Called setMemoryVoltageDomainOffsetVoltage " - "using unsupported voltage offset attribute type of 0x%08X.", - VOLTAGE_DOMAIN_ID_ATTR); - break; - } + assert(recordIndex < records, + "Code bug! Called computeDynamicMemoryVoltage " + "using unsupported voltage offset attribute type of 0x%08X.", + VOLTAGE_DOMAIN_ID_ATTR); - TARGETING::TargetHandleList membufTargetList; + TARGETING::TargetHandleList l_mcbistTargetList; - // Must pull ALL present memory buffers (not just functional) for these + // Must pull ALL present mcbist (not just functional) for these // computations - getChipResources(membufTargetList, TYPE_MEMBUF, - TARGETING::UTIL_FILTER_PRESENT); + getAllChiplets(l_mcbistTargetList, TARGETING::TYPE_MCBIST, false); - std::sort(membufTargetList.begin(), membufTargetList.end(), - _compareMembufWrtVoltageDomain< VOLTAGE_DOMAIN_ID_ATTR >); + // sort the mcbist targets based on domain id + std::sort(l_mcbistTargetList.begin(), l_mcbistTargetList.end(), + _compareMcbistWrtVoltageDomain< VOLTAGE_DOMAIN_ID_ATTR >); - std::vector<fapi::Target> membufFapiTargetsList; - typename AttributeTraits< VOLTAGE_DOMAIN_ID_ATTR >::Type lastDomainId + std::vector<fapi2::Target<fapi2::TARGET_TYPE_MCS>> l_mcsFapiTargetsList; + typename TARGETING::AttributeTraits< VOLTAGE_DOMAIN_ID_ATTR >::Type lastDomainId = 0; - if(!membufTargetList.empty()) + if(!l_mcbistTargetList.empty()) { lastDomainId = - (*membufTargetList.begin())->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(); + (*l_mcbistTargetList.begin())->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(); } // O(n) algorithm to execute HWPs on groups of memory buffers. As the @@ -201,37 +212,39 @@ errlHndl_t setMemoryVoltageDomainOffsetVoltage() // Prevent running the HWP on the first target. Var is used to push us // through the loop after we exhausted all the targets - bool last = membufTargetList.empty(); - for (TargetHandleList::const_iterator - ppPresentMembuf = membufTargetList.begin(); - ((ppPresentMembuf != membufTargetList.end()) || (last == false)); - ++ppPresentMembuf) + bool last = l_mcbistTargetList.empty(); + for (TARGETING::TargetHandleList::const_iterator + ppPresentMcbist = l_mcbistTargetList.begin(); + ((ppPresentMcbist != l_mcbistTargetList.end()) || (last == false)); + ++ppPresentMcbist) { // If no valid target to process, this is our last time through the loop - last = (ppPresentMembuf == membufTargetList.end()); + last = (ppPresentMcbist == l_mcbistTargetList.end()); - typename AttributeTraits< VOLTAGE_DOMAIN_ID_ATTR >::Type + typename TARGETING::AttributeTraits< VOLTAGE_DOMAIN_ID_ATTR >::Type currentDomainId = last ? lastDomainId : - (*ppPresentMembuf)->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(); + (*ppPresentMcbist)->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(); // Invoke the HWP if the domain ID in the sorted list change relative to // prior entry or this is our final time through the loop (and there is // a list entry to process) - if( ( (currentDomainId != lastDomainId) + if( ( (currentDomainId != lastDomainId) || (last)) - && (!membufFapiTargetsList.empty()) ) + && (!l_mcsFapiTargetsList.empty()) ) { - // Skip HWP if this domain has all deconfigured membufs and the + // Skip HWP if this domain has all deconfigured mcs and the // domain rule specifies not running the HWP for that case bool invokeHwp = true; if(fnMap[recordIndex].callIfAllNonFunc == false) { invokeHwp = false; TARGETING::PredicateIsFunctional funcPred; - std::vector<fapi::Target>::const_iterator pFapiTarget = - membufFapiTargetsList.begin(); - for(;pFapiTarget != membufFapiTargetsList.end();++pFapiTarget) + std::vector<fapi2::Target<fapi2::TARGET_TYPE_MCS>>::const_iterator + pFapiTarget = l_mcsFapiTargetsList.begin(); + + for(;pFapiTarget != l_mcsFapiTargetsList.end();++pFapiTarget) { + // Is there a functional mcs target? if(funcPred( reinterpret_cast<const TARGETING::Target*>( pFapiTarget->get()))) @@ -249,10 +262,12 @@ errlHndl_t setMemoryVoltageDomainOffsetVoltage() fnMap[recordIndex].fnName, VOLTAGE_DOMAIN_ID_ATTR, lastDomainId); + // HWP should set up ATTR_MSS_VOLT_<domain>_OFFSET_MILLIVOLTS + // for MCBIST targets associated with the mcs list FAPI_INVOKE_HWP( pError, fnMap[recordIndex].fn, - membufFapiTargetsList); + l_mcsFapiTargetsList); if (pError) { @@ -271,33 +286,41 @@ errlHndl_t setMemoryVoltageDomainOffsetVoltage() { TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "INFO not invoking %s on domain type 0x%08X, ID 0x%08X " - "since domain has no functional memory buffers.", + "since domain has no functional mcbist.", fnMap[recordIndex].fnName, VOLTAGE_DOMAIN_ID_ATTR, lastDomainId); } - membufFapiTargetsList.clear(); + l_mcsFapiTargetsList.clear(); lastDomainId = currentDomainId; } - // If not the last time through loop, there is a new target to - // accumulate + // If not the last time through loop, there is a new target + // to accumulate if(!last) { - const TARGETING::Target* pPresentMembuf = *ppPresentMembuf; + const TARGETING::Target* pPresentMcbist = *ppPresentMcbist; TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "===== add to fapi::Target vector attr type=0x%08X, " "id=0x%08X, target HUID=0x%08X", VOLTAGE_DOMAIN_ID_ATTR, - pPresentMembuf->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(), - TARGETING::get_huid(pPresentMembuf)); + pPresentMcbist->getAttr<VOLTAGE_DOMAIN_ID_ATTR>(), + TARGETING::get_huid(pPresentMcbist)); + + fapi2::Target<fapi2::TARGET_TYPE_MCBIST> mcbistFapiTarget( + (const_cast<TARGETING::Target*>(pPresentMcbist)) ); - fapi::Target membufFapiTarget(fapi::TARGET_TYPE_MEMBUF_CHIP, - (const_cast<TARGETING::Target*>(pPresentMembuf)) ); + // Get the mcs targets under this current mcbist target + std::vector<fapi2::Target<fapi2::TARGET_TYPE_MCS>> l_childMCSs = + mcbistFapiTarget.getChildren<fapi2::TARGET_TYPE_MCS>(fapi2::TARGET_STATE_PRESENT); - membufFapiTargetsList.push_back(membufFapiTarget); + // append this mcs target list to the overall mcs target list + // for that particular domain + l_mcsFapiTargetsList.insert( l_mcsFapiTargetsList.end(), + l_childMCSs.begin(), + l_childMCSs.end() ); } // Otherwise need to bail, lest we increment the iterator again, which // is undefined @@ -312,12 +335,13 @@ errlHndl_t setMemoryVoltageDomainOffsetVoltage() break; } - } while(0); + } while(0); - TRACDCOMP(ISTEPS_TRACE::g_trac_isteps_trace, - "setMemoryVoltageDomainOffsetVoltage exit"); + TRACDCOMP(ISTEPS_TRACE::g_trac_isteps_trace, + "computeDynamicMemoryVoltage exit"); - return pError; + return pError; } -*/ + + #endif |