From 1eba8f47f718aa44800ed5be0f70b1cf795298c9 Mon Sep 17 00:00:00 2001 From: Brian Stegmiller Date: Tue, 5 Dec 2017 16:01:44 -0600 Subject: Avoid assert on invalid target types for PRD and HWP PLID association Change-Id: I576559dba463bdc884e7929f731e5a098c6f7749 CQ:SW409720 Backport: release-op910 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/50535 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: FSP CI Jenkins Reviewed-by: Zane C. Shelley Reviewed-by: Caleb N. Palmer Reviewed-by: Benjamin J. Weisenbeck Reviewed-by: Daniel M. Crowell --- src/include/usr/diag/attn/attnreasoncodes.H | 7 +- src/usr/diag/attn/ipl/attn.C | 121 ++++++++++++++++- src/usr/fapi2/plat_utils.C | 82 +++++++++++- src/usr/fapi2/test/fapi2VerifyPrdAttrTest.C | 198 +++++++++++++++++++++++++++- 4 files changed, 398 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/include/usr/diag/attn/attnreasoncodes.H b/src/include/usr/diag/attn/attnreasoncodes.H index 5510d719d..ce0cd9dde 100644 --- a/src/include/usr/diag/attn/attnreasoncodes.H +++ b/src/include/usr/diag/attn/attnreasoncodes.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -47,6 +47,7 @@ enum ModuleId { ATTN_INVALID_MODULE = 0x00, ATTN_TEST_FAKE_CALL_PRD = 0x01, // this is used in test code only. + ATTN_CHK_IPL_ATTNS_MODULE = 0x02 }; /** @@ -58,8 +59,10 @@ enum ModuleId enum ReasonCode { ATTN_INVALID_REASONCODE = ATTN_COMP_ID | 0x00, // Invalid Reasoncode - ATTN_TEST_ATTN_FAIL = ATTN_COMP_ID | 0x01, // this is used in + ATTN_TEST_ATTN_FAIL = ATTN_COMP_ID | 0x01, // this is used in // test code only. + ATTN_SEE_HW_ERROR = ATTN_COMP_ID | 0x02 // HW err with no gard + // so PLID still set }; } diff --git a/src/usr/diag/attn/ipl/attn.C b/src/usr/diag/attn/ipl/attn.C index b2b18e3cd..6b203c613 100644 --- a/src/usr/diag/attn/ipl/attn.C +++ b/src/usr/diag/attn/ipl/attn.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2016 */ +/* Contributors Listed Below - COPYRIGHT 2014,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -37,9 +37,11 @@ #include "common/attntarget.H" #include "common/attnproc.H" #include "common/attnmem.H" +#include "diag/attn/attnreasoncodes.H" #include #include #include +#include // Custom compile configs #include @@ -53,6 +55,7 @@ using namespace std; using namespace PRDF; using namespace TARGETING; using namespace Util; +using namespace ERRORLOG; namespace ATTN { @@ -92,13 +95,12 @@ errlHndl_t checkForIplAttentions() assert(l_sys != NULL); l_sys->tryGetAttr(l_useAllProcs); + getTargetService().masterProcChipTargetHandle( + l_MasterProcTarget); // Do we want to check ALL procs ? if (0 == l_useAllProcs) { - getTargetService().masterProcChipTargetHandle( - l_MasterProcTarget); - list.push_back(l_MasterProcTarget); } // end if just master proc else @@ -122,7 +124,116 @@ errlHndl_t checkForIplAttentions() tit = list.erase(tit); } - return 0; + // ==================================================================== + // PRD and HW procedures use an attribute to associate errors + // together. If we still see that 'active' when done checking + // attentions, we are suppose to build an error log with a + // matching PLID so the istep fails. Then hopefully people + // look at the other error log with the same PLID and not this + // one since that is the real error. + // ==================================================================== + // NOTE: There could be multiple PLIDs set on different targets + // So we may need to commit some elogs and pass back one. + // ==================================================================== + ATTR_MODEL_type l_model = l_MasterProcTarget->getAttr(); + errlHndl_t l_plidElog = NULL; + uint32_t l_plid = 0; + TARGETING::TYPE l_memType; + TargetHandleList l_allProcsList, l_memList; + + + // Setup appropriate memory type target + if ( MODEL_NIMBUS == l_model ) + { + l_memType = TYPE_MCA; + } // if NIMBUS + else if ( MODEL_CUMULUS == l_model ) + { + l_memType = TYPE_DMI; + } // if CUMULUS + else + { + ATTN_ERR("ChkForIplAttns Unknown PROC type - add support"); + assert(0); + } // UNKNOWN proc type + + + // This gets all PROCs whether functional or not + getTargetService().getAllChips(l_allProcsList, TYPE_PROC, false); + + // Loop thru all PROC targets + for ( auto l_procTarg : l_allProcsList ) + { + // check PROC target first for attribute + l_procTarg->tryGetAttr(l_plid); + + if (0 != l_plid) + { + ATTN_SLOW("checkForIplAttentions PROC plid found"); + + // If we had a prior ELOG, we need to commit it + // since we will be creating another one here. + if (NULL != l_plidElog) + { + errlCommit(l_plidElog, ATTN_COMP_ID); + } + + // Build elog with same PLID value + l_plidElog = new ErrlEntry( ERRL_SEV_UNRECOVERABLE, + ATTN_CHK_IPL_ATTNS_MODULE, + ATTN_SEE_HW_ERROR, + l_plid, TYPE_PROC + ); + + // Make sure PLID matches the HW error + l_plidElog->plid(l_plid); + + // clear attribute + l_plid = 0; + l_procTarg->trySetAttr(l_plid); + } // non-zero PLID in attribute + + + // Get the list of MEMORY related units (functional or not) + getChildChiplets(l_memList, l_procTarg, l_memType, false); + + for ( auto l_memTarg : l_memList ) + { + // check PROC target first for attribute + l_memTarg->tryGetAttr(l_plid); + + if (0 != l_plid) + { + ATTN_SLOW("checkForIplAttentions MEM plid found"); + + // If we had a prior ELOG, we need to commit it + // since we will be creating another one here. + if (NULL != l_plidElog) + { + errlCommit(l_plidElog, ATTN_COMP_ID); + } + + // Build elog with same PLID value + l_plidElog = new ErrlEntry( ERRL_SEV_UNRECOVERABLE, + ATTN_CHK_IPL_ATTNS_MODULE, + ATTN_SEE_HW_ERROR, + l_plid, l_memType + ); + + // Make sure PLID matches the HW error + l_plidElog->plid(l_plid); + + // clear attribute + l_plid = 0; + l_memTarg->trySetAttr(l_plid); + } // non-zero PLID in attribute + + } // end for on mem target + + } // end for loop on PROC targets + // ==================================================================== + + return l_plidElog; } #ifdef CONFIG_ENABLE_CHECKSTOP_ANALYSIS diff --git a/src/usr/fapi2/plat_utils.C b/src/usr/fapi2/plat_utils.C index 58c4da663..a1b95ec8f 100644 --- a/src/usr/fapi2/plat_utils.C +++ b/src/usr/fapi2/plat_utils.C @@ -1009,6 +1009,16 @@ void set_log_id( const Target& i_target, fapi2::ReturnCode& io_rc, fapi2::errlSeverity_t i_sev ) { + TARGETING::TYPE l_type; + TARGETING::TargetHandleList l_targList; + TARGETING::Target* l_attrTarget = NULL; // for setting attribute + + + // Need model for nimbus/cumulus checks + TARGETING::Target * l_masterProc; + TARGETING::targetService().masterProcChipTargetHandle(l_masterProc); + TARGETING::MODEL l_model = l_masterProc->getAttr(); + // Create elog for FAPI error createPlatLog( io_rc, i_sev ); @@ -1016,10 +1026,78 @@ void set_log_id( const Target& i_target, errlHndl_t l_pError = reinterpret_cast(io_rc.getPlatDataPtr()); uint32_t plid = ERRL_GETPLID_SAFE(l_pError); - // Connect the PLID to PRD log + // get target passed in TARGETING::Target* l_target = reinterpret_cast(i_target.get()); - l_target->setAttr( plid ); + + + // PRD only uses this for PROC and MCA/DMI targets + // so ensure we have one of those. + if (NULL != l_target) + { + if ( l_target->tryGetAttr(l_type) ) + { + switch (l_type) + { + case TARGETING::TYPE_PROC: + case TARGETING::TYPE_MCA: + case TARGETING::TYPE_DMI: + // Supported for these targets + l_attrTarget = l_target; + break; // proc/mca/dmi + + case TARGETING::TYPE_DIMM: + // Need parent MCA (or DMI) + if ( TARGETING::MODEL_NIMBUS == l_model ) + { // NIMBUS + getParentAffinityTargets( l_targList, l_target, + TARGETING::CLASS_UNIT, + TARGETING::TYPE_MCA ); + + if (1 == l_targList.size()) + { + l_attrTarget = l_targList[0]; + } // one parent found + + } + else if ( TARGETING::MODEL_CUMULUS == l_model ) + { // CUMULUS + getParentAffinityTargets( l_targList, l_target, + TARGETING::CLASS_UNIT, + TARGETING::TYPE_DMI ); + + if (1 == l_targList.size()) + { + l_attrTarget = l_targList[0]; + } // one parent found + } + else + { + // Unknown PROC type so don't do + // anything till we add support + FAPI_ERR("WARNING:set_log_id: UNKNOWN MODEL"); + Assert( TARGETING::MODEL_NIMBUS == l_model ); + } // end else new proc to work on + break; // dimm + + default: + // No idea what we have, + // so don't use it or it + // will explode on us. + break; + + } // end switch on type + + } // if got target type + + if (NULL != l_attrTarget) + { + // Connect the PLID to PRD log + l_attrTarget->trySetAttr( plid ); + } // attrTarget valid + + } // if valid target + } // end set_log_id diff --git a/src/usr/fapi2/test/fapi2VerifyPrdAttrTest.C b/src/usr/fapi2/test/fapi2VerifyPrdAttrTest.C index 4c62d2f03..6e4b7fff8 100644 --- a/src/usr/fapi2/test/fapi2VerifyPrdAttrTest.C +++ b/src/usr/fapi2/test/fapi2VerifyPrdAttrTest.C @@ -30,6 +30,7 @@ #include #include #include "fapi2TestUtils.H" +#include "diag/attn/attn.H" #include @@ -65,6 +66,10 @@ uint32_t verifyHwpPrdAssociaton() TARGETING::Target * l_masterProc; TARGETING::targetService().masterProcChipTargetHandle(l_masterProc); + + // ============================================================== + // PROCESSOR TARGET should be good + // ============================================================== // Using masterProc target as FAPI core target for test Target fapi2_coreTarget(l_masterProc); // We have to pass a FAPI RC so make one up @@ -89,7 +94,198 @@ uint32_t verifyHwpPrdAssociaton() TS_TRACE(" verifyHwpPrdAssociation GOOD on CORE"); } - FAPI_INF("...verifyHwpPrdAssociation completed: PLID:%08X", l_plid); + FAPI_INF("...verifyHwpPrdAssociation BaseDone: PLID:%08X", l_plid); + + + // ============================================================== + // Verify MCA target is good (we expect them) + // ============================================================== + TargetHandleList l_mcaList; + getChildAffinityTargets( l_mcaList, l_masterProc, + TARGETING::CLASS_UNIT, + TARGETING::TYPE_MCA ); + + if (l_mcaList.size() >= 1) + { + FAPI_INF("...verifyHwpPrdAssociation MCA :%d", + l_mcaList.size()); + + // Using masterProc target as FAPI core target for test + Target fapi2_mcaTarget(l_mcaList[0]); + // We have to pass a FAPI RC so make one up + l_fapiRc = verifyPrd_get_fapi2_error(); + + // Init the attribute so we know if it changes + l_mcaList[0]->setAttr( 0x87654321 ); + + // Create/commit elog associated with PRD PLID attribute + fapi2::log_related_error( fapi2_mcaTarget, l_fapiRc ); + + // Verify that PLID attribute changed + l_plid = l_mcaList[0]->getAttr(); + + if (0x87654321 == l_plid) + { // PLID did not change so routine failed somehow + TS_FAIL(" verifyHwpPrdAssociation MCA No PLID change:%08X", + l_plid); + l_rc = 1; + } + else + { // PLID was altered, so that is good + TS_TRACE(" verifyHwpPrdAssociation GOOD on MCA"); + } + + FAPI_INF("...verifyHwpPrdAssociation MCA done: PLID %08X", l_plid); + + // ============================================================== + // HW procedures might pass DIMM so verify that works + // ============================================================== + TargetHandleList l_dimmList; + getChildAffinityTargets( l_dimmList, l_mcaList[0], + TARGETING::CLASS_NA, + TARGETING::TYPE_DIMM ); + + if (l_dimmList.size() >= 1) + { + FAPI_INF("...verifyHwpPrdAssociation DIMM:%d", + l_dimmList.size() ); + + // Using masterProc target as FAPI core target for test + Target fapi2_dimmTarget(l_dimmList[0]); + // We have to pass a FAPI RC so make one up + l_fapiRc = verifyPrd_get_fapi2_error(); + + // Init the attribute so we know if it changes + l_mcaList[0]->setAttr( 0x33333333 ); + + // Create/commit elog associated with PRD PLID attribute + fapi2::log_related_error( fapi2_dimmTarget, l_fapiRc ); + + // Verify that PLID attribute changed + l_plid = l_mcaList[0]->getAttr(); + + if (0x33333333 == l_plid) + { // PLID did not change so routine failed somehow + TS_FAIL(" verifyHwpPrdAssociation DIMM No PLID change:%08X", + l_plid); + l_rc = 1; + } + else + { // PLID was altered, so that is good + TS_TRACE(" verifyHwpPrdAssociation GOOD on DIMM"); + } + + FAPI_INF("...verifyHwpPrdAssociation DIMM done: PLID %08X", l_plid); + } // end if any DIMMs + + } // end if any MCAs + + + // ============================================================== + // Verify target we don't do anything with ... TYPE_EQ + // ============================================================== + TargetHandleList l_eqList; + getChildAffinityTargets( l_eqList, l_masterProc, + TARGETING::CLASS_UNIT, + TARGETING::TYPE_EQ ); + + if (l_eqList.size() >= 1) + { + FAPI_INF("...verifyHwpPrdAssociation EQ :%d", + l_eqList.size()); + + // Using masterProc target as FAPI core target for test + Target fapi2_eqTarget(l_eqList[0]); + // We have to pass a FAPI RC so make one up + l_fapiRc = verifyPrd_get_fapi2_error(); + + + // We don't have an attribute for this target. Hence, + // we can't write/read this attribute, but I can at + // least run thru the code to ensure it doesn't crash + + // Create/commit elog associated with PRD PLID attribute + fapi2::log_related_error( fapi2_eqTarget, l_fapiRc ); + + // If we make it here, we didn't crash with bad target + TS_TRACE(" verifyHwpPrdAssociation GOOD on EQ (ignored)"); + + FAPI_INF("...verifyHwpPrdAssociation EQ done"); + + } // end if any EQ units + + +#if 0 + +/* Bit of a hassle to try calling ATTN code here ... + but would be nice to do final verification. + + fapi2Test.mk + but this pulls in more and more of attn code + + EXTRAINCDIR += ${ROOTPATH}/src/usr/diag/attn/ + EXTRAINCDIR += ${ROOTPATH}/src/usr/diag/attn/common + EXTRAINCDIR += ${ROOTPATH}/src/usr/diag/attn/ipl + EXTRAINCDIR += ${ROOTPATH}/src/include/usr/diag/ + + OBJS += attn.o attnsvc.o +*/ + + // ============================================================== + // We should have the PLID set on a PROC and MCA target by now + // so let's see if ATTN code will clear them and return an elog. + // ============================================================== + + errlHndl_t l_attnLog = ATTN::checkForIplAttentions(); + + if (NULL != l_attnLog) + { // we got elog as expected + TS_TRACE(" verifyHwpPrdAssociation chkIplAttns GOOD with ELOG"); + } + else + { // Why did we not get ELOG? Something wrong here + TS_FAIL(" verifyHwpPrdAssociation chkIplAttns FAIL -no ELOG"); + } + + // ---------------------------------------------------------- + // All targets should have been cleared too ... check that + // ---------------------------------------------------------- + // Verify that PROC target PLID attribute was cleared + l_plid = l_masterProc->getAttr(); + + if (0 != l_plid) + { // PLID should have been cleared + TS_FAIL(" verifyHwpPrdAssociation PROC PLID not cleared:%08X", + l_plid); + l_rc = 1; + } + else + { // PLID was altered, so that is good + TS_TRACE(" verifyHwpPrdAssociation PROC PLID cleared"); + } + + + // Verify that MCA target PLID attribute was cleared + if (l_mcaList.size() >= 1) + { + // Verify that PLID attribute changed + l_plid = l_mcaList[0]->getAttr(); + + if (0 != l_plid) + { // PLID should have been cleared + TS_FAIL(" verifyHwpPrdAssociation MCA PLID not cleared:%08X", + l_plid); + l_rc = 1; + } + else + { // PLID was altered, so that is good + TS_TRACE(" verifyHwpPrdAssociation MCA PLID cleared"); + } + } // end if any MCAs to check PLIDs on +#endif + + // asdf tests here + FAPI_INF("verifyHwpPrdAssociation completed"); return l_rc; } -- cgit v1.2.1