From c50f586098a5208764c5cbee9b88f23a51d16f07 Mon Sep 17 00:00:00 2001 From: Dan Crowell Date: Fri, 6 Jan 2017 13:55:20 -0600 Subject: Enforce single-threaded rule for Hardware Procedures Because we aren't using read thread-local storage for the FAPI variables (opmode, piberrmask, current_err) we need to ensure that we never have multiple HWPs running at the same time. The external interface that we use in all cases is FAPI_INVOKE_HWP so that is where a mutex is placed. This change also uncovered a couple bugs in how we were executing some non-fapi HWPs in the SBE update code so I fixed those as well. Change-Id: Ie8817da62dd4e6bc9ed3ac2debf126f6d05c2b23 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34518 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Tested-by: Jenkins OP Build CI Reviewed-by: Christian R. Geddes Reviewed-by: Richard J. Knight Reviewed-by: Daniel M. Crowell --- src/include/usr/fapi2/hwp_executor.H | 5 +---- src/include/usr/fapi2/plat_hwp_invoker.H | 13 ++++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/include/usr/fapi2') diff --git a/src/include/usr/fapi2/hwp_executor.H b/src/include/usr/fapi2/hwp_executor.H index 6c2049595..6eea155c5 100644 --- a/src/include/usr/fapi2/hwp_executor.H +++ b/src/include/usr/fapi2/hwp_executor.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -45,9 +45,6 @@ * Call the HWP directly. */ #define FAPI_PLAT_EXEC_HWP(RC, FUNC, _args_...) \ - fapi2::current_err = fapi2::FAPI2_RC_SUCCESS;\ - fapi2::opMode = fapi2::NORMAL;\ - fapi2::setPIBErrorMask(0);\ RC = FUNC(_args_) #endif // HWPEXECUTOR_H_ diff --git a/src/include/usr/fapi2/plat_hwp_invoker.H b/src/include/usr/fapi2/plat_hwp_invoker.H index 211b3f0c6..c7ababf18 100644 --- a/src/include/usr/fapi2/plat_hwp_invoker.H +++ b/src/include/usr/fapi2/plat_hwp_invoker.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -44,6 +44,15 @@ #include #include +namespace fapi2 { +//@fixme-RTC:147599-Remove when thread-local storage works right +/// +/// @brief Lock or unlock the HWP futex +/// @param[i] i_lock true:lock the mutex, false:unlock +/// +void hwpLock( bool i_lock ); +} + /** * @brief HWP Invoker macro * @@ -59,6 +68,7 @@ #define FAPI_INVOKE_HWP(ERRHNDL, FUNC, _args_...) \ {\ + fapi2::hwpLock(true); \ fapi2::ReturnCode l_rc; \ FAPI_EXEC_HWP(l_rc, FUNC, ##_args_); \ ERRHNDL = fapi2::rcToErrl(l_rc);\ @@ -66,6 +76,7 @@ ERRHNDL->collectTrace(FAPI_IMP_TRACE_NAME,256);\ ERRHNDL->collectTrace(FAPI_TRACE_NAME,384);\ }\ + fapi2::hwpLock(false); \ } #endif // PLATHWPINVOKER_H_ -- cgit v1.2.3