diff options
| author | Dan Crowell <dcrowell@us.ibm.com> | 2017-01-06 13:55:20 -0600 |
|---|---|---|
| committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2017-01-23 23:29:43 -0500 |
| commit | c50f586098a5208764c5cbee9b88f23a51d16f07 (patch) | |
| tree | df2d2cc4e36295344b2c1ab6cfe4d0e19b09a56d /src/usr/fapi2/test | |
| parent | 44eaa7b67e29cbca5b79e60c491ebdfcb624d787 (diff) | |
| download | talos-hostboot-c50f586098a5208764c5cbee9b88f23a51d16f07.tar.gz talos-hostboot-c50f586098a5208764c5cbee9b88f23a51d16f07.zip | |
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 <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/fapi2/test')
| -rw-r--r-- | src/usr/fapi2/test/fapi2HwAccessTest.H | 123 | ||||
| -rw-r--r-- | src/usr/fapi2/test/p9_hwtests.C | 88 | ||||
| -rw-r--r-- | src/usr/fapi2/test/p9_hwtests.H | 5 |
3 files changed, 105 insertions, 111 deletions
diff --git a/src/usr/fapi2/test/fapi2HwAccessTest.H b/src/usr/fapi2/test/fapi2HwAccessTest.H index c113f5d18..867f5ac54 100644 --- a/src/usr/fapi2/test/fapi2HwAccessTest.H +++ b/src/usr/fapi2/test/fapi2HwAccessTest.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -49,6 +49,12 @@ using namespace fapi2; +//This function does nothing, it is used to call FAPI_INVOKE on +fapi2::ReturnCode empty_function(void) +{ + return fapi2::current_err; +} + class Fapi2HwAccessTest : public CxxTest::TestSuite { @@ -191,16 +197,6 @@ void test_fapi2HwAccess() } numTests++; - FAPI_INVOKE_HWP(l_errl, p9_opmodetest_getsetopmode); - if(l_errl) - { - TS_FAIL("p9_opmodetest_getsetopmode !!"); - numFails++; - delete l_errl; // delete unexpected error log so we dont get - // a false negative on the next case - } - - numTests++; uint8_t failed = 0; FAPI_INVOKE_HWP(l_errl, p9_opmodetest_ignorehwerr, @@ -218,15 +214,6 @@ void test_fapi2HwAccess() } numTests++; - FAPI_INVOKE_HWP(l_errl, p9_piberrmask_getsettest); - if(l_errl) - { - TS_FAIL("p9_piberrmask_getsettest returned an error!"); - numFails++; - errlCommit(l_errl,FAPI2_COMP_ID); - } - - numTests++; FAPI_INVOKE_HWP(l_errl, p9_piberrmask_masktest, fapi2_procTarget); if(l_errl) { @@ -275,6 +262,102 @@ void test_fapi2HwAccess() FAPI_INF("fapi2HwAccessTest Test Complete. %d/%d fails", numFails , numTests); } +void test_piberrmask() +{ + FAPI_INF("Entering test_piberrmask..."); + FAPI_INF("Ensure that getPIBErrorMask return 0 initially"); + + errlHndl_t l_errl = NULL; + + do + { + uint8_t mask = fapi2::getPIBErrorMask(); + if(mask != 0) + { + TS_FAIL("test_piberrmask>> Expected fapi2::getPIBErrorMask to return (0x0) but instead returned 0x%x", mask); + break; + } + + FAPI_INF("Setting pib_err_mask to PIB_CHIPLET_OFFLINE (0x2) and checking that we get it back with getPIBErrorMask"); + + fapi2::setPIBErrorMask((uint8_t)PIB::PIB_CHIPLET_OFFLINE); + mask = fapi2::getPIBErrorMask(); + if(mask != PIB::PIB_CHIPLET_OFFLINE) + { + TS_FAIL("test_piberrmask>> Expected fapi2::getPIBErrorMask to return 0x2 but instead returned 0x%x", mask); + break; + } + + //Call FAPI_INVOKE on an empty function to test if + //it resets the pib err mask + FAPI_INVOKE_HWP(l_errl,empty_function); + if( l_errl ) + { + TS_FAIL("test_piberrmask got an error !!"); + delete l_errl; // delete unexpected error log so we dont get + // a false negative on the next case + } + + mask = fapi2::getPIBErrorMask(); + if(mask != 0) + { + TS_FAIL("test_piberrmask>> Expected fapi2::getPIBErrorMask to return PIB_NO_ERROR (0x0) but instead returned %x , FAPI_INVOKE failed to reset pib_err_mask", mask); + break; + } + + }while(0); + + FAPI_INF("Exiting test_piberrmask..."); +} + + +void test_getsetopmode() +{ + FAPI_INF("Enter test_getsetopmode"); + FAPI_INF("Ensure that getOpMode return NORMAL initially"); + + do + { + fapi2::OpModes mode = fapi2::getOpMode(); + if(mode != fapi2::NORMAL) + { + TS_FAIL("test_getsetopmode>> Expected fapi2::getOpMode to return fapi2::NORMAL (0x0) but instead returned %x", mode); + break; + } + + FAPI_INF("Setting opMode to IGNORE_HW_ERROR (0x1) and checking that we get it back with getOpMode"); + + fapi2::setOpMode(fapi2::IGNORE_HW_ERROR); + mode = fapi2::getOpMode(); + if(mode != fapi2::IGNORE_HW_ERROR) + { + TS_FAIL("test_getsetopmode>> Expected fapi2::getOpMode to return fapi2::IGNORE_HW_ERROR (0x1) but instead returned %x", mode); + break; + } + + //Call FAPI_INVOKE on an empty function to test if it resets the opMode + errlHndl_t l_errl = NULL; + FAPI_INVOKE_HWP(l_errl,empty_function); + if( l_errl ) + { + TS_FAIL("test_getsetopmode got an error !!"); + delete l_errl; // delete unexpected error log so we dont get + // a false negative on the next case + } + + mode = fapi2::getOpMode(); + if(mode != fapi2::NORMAL) + { + TS_FAIL("test_getsetopmode>> Expected fapi2::getOpMode to return fapi2::NORMAL (0x0) but instead returned %x , FAPI_INVOKE failed to reset opmode", mode); + break; + } + + }while(0); + + FAPI_INF("Exiting test_getsetopmode"); +} + + }; #endif // End __FAPI2_HWACCESSTEST_H diff --git a/src/usr/fapi2/test/p9_hwtests.C b/src/usr/fapi2/test/p9_hwtests.C index fedf8582f..1f8a713ec 100644 --- a/src/usr/fapi2/test/p9_hwtests.C +++ b/src/usr/fapi2/test/p9_hwtests.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -35,12 +35,6 @@ #include <xscom/piberror.H> #include <plat_hwp_invoker.H> -//This function does nothing, it is used to call FAPI_INVOKE on -fapi2::ReturnCode empty_function(void) -{ - return fapi2::current_err; -} - fapi2::ReturnCode p9_scomtest_getscom_fail( fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target) { @@ -325,86 +319,6 @@ fapi2::ReturnCode p9_platPutRingWRingID_pass() } -fapi2::ReturnCode p9_opmodetest_getsetopmode() -{ - FAPI_INF("Ensure that getOpMode return NORMAL initially"); - do - { - fapi2::OpModes mode = fapi2::getOpMode(); - if(mode != fapi2::NORMAL) - { - TS_FAIL("p9_opmodetest_getsetopmode>> Expected fapi2::getOpMode to return fapi2::NORMAL (0x0) but instead returned %x", mode); - break; - } - - FAPI_INF("Setting opMode to IGNORE_HW_ERROR (0x1) and checking that we get it back with getOpMode"); - - fapi2::setOpMode(fapi2::IGNORE_HW_ERROR); - mode = fapi2::getOpMode(); - if(mode != fapi2::IGNORE_HW_ERROR) - { - TS_FAIL("p9_opmodetest_getsetopmode>> Expected fapi2::getOpMode to return fapi2::IGNORE_HW_ERROR (0x1) but instead returned %x", mode); - break; - } - - //Call FAPI_INVOKE on an empty function to test if it resets the opMode - errlHndl_t l_errl = NULL; - FAPI_INVOKE_HWP(l_errl,empty_function); - - mode = fapi2::getOpMode(); - if(mode != fapi2::NORMAL) - { - TS_FAIL("p9_opmodetest_getsetopmode>> Expected fapi2::getOpMode to return fapi2::NORMAL (0x0) but instead returned %x , FAPI_INVOKE failed to reset opmode", mode); - break; - } - - }while(0); - return fapi2::current_err; -} - -fapi2::ReturnCode p9_piberrmask_getsettest() -{ - FAPI_INF("Entering p9_piberrmask_getsettest..."); - - FAPI_INF("Ensure that getPIBErrorMask return 0 initially"); - - uint8_t mask = fapi2::getPIBErrorMask(); - do - { - if(mask != 0) - { - TS_FAIL("p9_piberrmask_getsettest>> Expected fapi2::getPIBErrorMask to return (0x0) but instead returned 0x%x", mask); - break; - } - - FAPI_INF("Setting pib_err_mask to PIB_CHIPLET_OFFLINE (0x2) and checking that we get it back with getPIBErrorMask"); - - fapi2::setPIBErrorMask((uint8_t)PIB::PIB_CHIPLET_OFFLINE); - mask = fapi2::getPIBErrorMask(); - if(mask != PIB::PIB_CHIPLET_OFFLINE) - { - TS_FAIL("p9_piberrmask_getsettest>> Expected fapi2::getPIBErrorMask to return 0x2 but instead returned 0x%x", mask); - break; - } - - //Call FAPI_INVOKE on an empty function to test if - //it resets the pib err mask - errlHndl_t l_errl = NULL; - FAPI_INVOKE_HWP(l_errl,empty_function); - - mask = fapi2::getPIBErrorMask(); - if(mask != 0) - { - TS_FAIL("p9_piberrmask_getsettest>> Expected fapi2::getPIBErrorMask to return PIB_NO_ERROR (0x0) but instead returned %x , FAPI_INVOKE failed to reset pib_err_mask", mask); - break; - } - - FAPI_INF("Exiting p9_piberrmask_getsettest..."); - }while(0); - - return fapi2::current_err; -} - fapi2::ReturnCode p9_opmodetest_ignorehwerr( fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target, uint8_t o_fail) diff --git a/src/usr/fapi2/test/p9_hwtests.H b/src/usr/fapi2/test/p9_hwtests.H index cdafe1b06..984c9fce3 100644 --- a/src/usr/fapi2/test/p9_hwtests.H +++ b/src/usr/fapi2/test/p9_hwtests.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -72,14 +72,11 @@ fapi2::ReturnCode p9_cfamtest_getcfam_pass( fapi2::ReturnCode p9_cfamtest_putcfam_pass( fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target); -fapi2::ReturnCode p9_opmodetest_getsetopmode(); - fapi2::ReturnCode p9_platPutRingWRingID_pass(); fapi2::ReturnCode p9_opmodetest_ignorehwerr( fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target, uint8_t fail); -fapi2::ReturnCode p9_piberrmask_getsettest(); fapi2::ReturnCode p9_piberrmask_masktest( fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target); |

