From 8147343269628e7bdab1ab25487e0ada3ace95e6 Mon Sep 17 00:00:00 2001 From: Glenn Miles Date: Fri, 22 Feb 2019 15:57:25 -0600 Subject: Use thread_local for globals that require it Change-Id: I84294a60c53da2501b7bb1b53fe84d9f9709f8b1 RTC:147599 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/72379 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Reviewed-by: Christian R. Geddes Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Nicholas E. Bofferding Reviewed-by: Daniel M. Crowell --- src/usr/fapi2/plat_utils.C | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) (limited to 'src/usr/fapi2/plat_utils.C') diff --git a/src/usr/fapi2/plat_utils.C b/src/usr/fapi2/plat_utils.C index ee1fde715..01eacb645 100644 --- a/src/usr/fapi2/plat_utils.C +++ b/src/usr/fapi2/plat_utils.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -70,11 +70,12 @@ TRAC_INIT(&g_fapiMfgTd, FAPI_MFG_TRACE_NAME, 4*KILOBYTE); namespace fapi2 { -//@fixme-RTC:147599 // Define global current_err -//thread_local ReturnCode current_err; +#ifndef PLAT_NO_THREAD_LOCAL_STORAGE +thread_local ReturnCode current_err; +#else ReturnCode current_err; - +#endif /// /// @brief Retrieve the ring data from the centaur hw image @@ -1516,35 +1517,15 @@ fapi2::ReturnCode platSpecialWakeup(const Target& i_target, return fapi_rc; } -//@fixme-RTC:147599-Remove when thread-local storage works right -/// -/// @brief Mutex to prevent multiple threads from running HWPs at the same time /// -mutex_t g_fapi2Mux = MUTEX_INITIALIZER; - -//@fixme-RTC:147599-Remove when thread-local storage works right +/// @brief Resets all HWP thread_local variables /// -/// @brief Lock or unlock the HWP futex -/// @param[i] i_lock true:lock the mutex, false:unlock -/// -void hwpLock( bool i_lock ) +void hwpResetGlobals(void) { - if( i_lock ) - { - mutex_lock(&g_fapi2Mux); - // Clear out all of our global (fake TLS) vars before we start - fapi2::current_err = fapi2::FAPI2_RC_SUCCESS; - fapi2::opMode = fapi2::NORMAL; - fapi2::setPIBErrorMask(0); - } - else - { - fapi2::current_err = fapi2::FAPI2_RC_SUCCESS; - fapi2::opMode = fapi2::NORMAL; - fapi2::setPIBErrorMask(0); - // Clear out all of our global (fake TLS) vars after we finish - mutex_unlock(&g_fapi2Mux); - } + // Reset all HWP thread_local vars + fapi2::current_err = fapi2::FAPI2_RC_SUCCESS; + fapi2::opMode = fapi2::NORMAL; + fapi2::setPIBErrorMask(0); } -- cgit v1.2.1