From 3faeb6dd6cbc8929ac94d92525d1d4f5dcfe9156 Mon Sep 17 00:00:00 2001 From: Dan Crowell Date: Thu, 17 Apr 2014 17:28:31 -0500 Subject: Set CMFSI fields correctly in the devtree for altmaster Change-Id: I4a36c70d36ec0603d053d5198a2aa78c07c63334 RTC: 35041 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/10626 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III --- src/include/usr/fsi/fsiif.H | 26 ++++++++++++++++++++++++++ src/usr/devtree/bld_devtree.C | 8 +++++--- src/usr/fsi/fsidd.C | 37 ++++++++++++++++++++++++++++++++++++- src/usr/fsi/fsidd.H | 15 +++++++++++++++ 4 files changed, 82 insertions(+), 4 deletions(-) diff --git a/src/include/usr/fsi/fsiif.H b/src/include/usr/fsi/fsiif.H index d5e0a6a38..14bb57da8 100644 --- a/src/include/usr/fsi/fsiif.H +++ b/src/include/usr/fsi/fsiif.H @@ -99,6 +99,32 @@ void getFsiFFDC( fsiFFDCType_t i_ffdc_type, */ errlHndl_t resetPib2Opb( TARGETING::Target* i_target ); +/** + * @brief Structure which defines info necessary to access a chip via FSI + */ +struct FsiLinkInfo_t +{ + TARGETING::Target* master; ///< FSI Master + TARGETING::FSI_MASTER_TYPE type; ///< Master or Cascaded Master + uint8_t link; ///< Which link is this chip hanging off of + uint8_t cascade; ///< Slave cascade position + uint8_t mPort; ///< FSI Master port (0=A,1=B) + + FsiLinkInfo_t() : + master(NULL), type(TARGETING::FSI_MASTER_TYPE_NO_MASTER), + link(0xFF), cascade(0), mPort(0) + {}; +}; + +/** + * @brief Retrieve some FSI attribute information + * + * @param[in] i_slave Slave Chip Target to query + * @param[out] o_info FSI Link Information + */ +void getFsiLinkInfo( TARGETING::Target* i_slave, + FsiLinkInfo_t& o_info ); + /** * FSI Slave Registers for P8 diff --git a/src/usr/devtree/bld_devtree.C b/src/usr/devtree/bld_devtree.C index d0d73e07d..ff1fa59c2 100644 --- a/src/usr/devtree/bld_devtree.C +++ b/src/usr/devtree/bld_devtree.C @@ -52,6 +52,7 @@ $ */ #include #include #include +#include trace_desc_t *g_trac_devtree = NULL; TRAC_INIT(&g_trac_devtree, "DEVTREE", 4096); @@ -844,7 +845,7 @@ errlHndl_t bld_fdt_mem(devTree * i_dt, bool i_smallTree) for ( size_t memb = 0; (!errhdl) && (memb < l_memBufList.size()); memb++ ) { - const TARGETING::Target * l_pMemB = l_memBufList[memb]; + TARGETING::Target * l_pMemB = l_memBufList[memb]; //Get MMIO Offset from parent MCS attribute. PredicateCTM l_mcs(CLASS_UNIT,TYPE_MCS, MODEL_NA); @@ -898,9 +899,10 @@ errlHndl_t bld_fdt_mem(devTree * i_dt, bool i_smallTree) i_dt->addPropertyCell32(membNode, "ibm,chip-id",l_cenId); //Add the CMFSI (which CMFSI 0 or 1) and port - //TODO RTC93298 make which CMFSI correct + FSI::FsiLinkInfo_t linkinfo; + FSI::getFsiLinkInfo( l_pMemB, linkinfo ); uint32_t cmfsiCells[2] = - {0,l_pMemB->getAttr()}; + {linkinfo.mPort,linkinfo.link}; i_dt->addPropertyCells32(membNode, "ibm,fsi-master-port", cmfsiCells, 2); } diff --git a/src/usr/fsi/fsidd.C b/src/usr/fsi/fsidd.C index 440b8ccd6..9ff9d304c 100644 --- a/src/usr/fsi/fsidd.C +++ b/src/usr/fsi/fsidd.C @@ -335,6 +335,15 @@ errlHndl_t resetPib2Opb( TARGETING::Target* i_target ) } +/** + * @brief Retrieve some FSI attribute information + */ +void getFsiLinkInfo( TARGETING::Target* i_slave, + FsiLinkInfo_t& o_info ) +{ + Singleton::instance().getFsiLinkInfo( i_slave, o_info ); +} + }; //end FSI namespace @@ -1010,6 +1019,8 @@ FsiDD::FsiDD() // add a dummy value to catch NULL FsiChipInfo_t info; iv_fsiInfoMap[NULL] = info; + + mutex_init(&iv_dataMutex); } /** @@ -2831,7 +2842,8 @@ FsiDD::FsiChipInfo_t FsiDD::getFsiInfo( TARGETING::Target* i_target ) { FsiChipInfo_t info; - //@fixme - Maps aren't threadsafe, fix when RTC:98898 is done + mutex_lock(&iv_dataMutex); + // Check if we have a cached version first std::map::iterator itr = iv_fsiInfoMap.find(i_target); @@ -2847,5 +2859,28 @@ FsiDD::FsiChipInfo_t FsiDD::getFsiInfo( TARGETING::Target* i_target ) iv_fsiInfoMap[i_target] = info; } + mutex_unlock(&iv_dataMutex); + return info; } + +/** + * @brief Retrieve some FSI attribute information + */ +void FsiDD::getFsiLinkInfo( TARGETING::Target* i_slave, + FSI::FsiLinkInfo_t& o_info ) +{ + FsiChipInfo_t info = getFsiInfo( i_slave ); + o_info.master = info.master; + o_info.type = info.type; + o_info.link = info.port; + o_info.cascade = info.cascade; + o_info.mPort = 0; + if( info.master + && (info.master != iv_master ) + && (getFsiInfo(info.master).flagbits.flipPort) ) + { + o_info.mPort = 1; + } +} + diff --git a/src/usr/fsi/fsidd.H b/src/usr/fsi/fsidd.H index b2f671f07..d0503857d 100644 --- a/src/usr/fsi/fsidd.H +++ b/src/usr/fsi/fsidd.H @@ -131,6 +131,16 @@ class FsiDD */ errlHndl_t resetPib2Opb( TARGETING::Target* i_target ); + /** + * @brief Retrieve some FSI attribute information + * + * @param[in] i_slave Slave Chip Target to query + * @param[out] o_info FSI Link Information + */ + void getFsiLinkInfo( TARGETING::Target* i_slave, + FSI::FsiLinkInfo_t& o_info ); + + protected: /** * @brief Constructor @@ -594,6 +604,11 @@ class FsiDD */ std::map iv_fsiInfoMap; + /** + * Mutex to protect the internal maps + */ + mutex_t iv_dataMutex; + private: // let my testcase poke around -- cgit v1.2.1