From b9226da65a3cd1c2170dcb57fdf3e25e82595d64 Mon Sep 17 00:00:00 2001 From: Raja Das Date: Tue, 20 Jun 2017 05:31:55 -0500 Subject: Suspend IO chip-op implementation Change-Id: I83d53a8414525c2d5916d54b0ac3e6ecbaeb6520 RTC:166974 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/42103 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Sachin Gupta Reviewed-by: Shakeeb A. Pasha B K Reviewed-by: AMIT J. TENDOLKAR --- src/sbefw/sbe_sp_intf.H | 3 +- src/sbefw/sbecmdgeneric.C | 3 +- src/sbefw/sbecmdiplcontrol.C | 64 +++++++++++++++++++++++++++++++++++- src/sbefw/sbecmdiplcontrol.H | 8 +++++ src/sbefw/sbecmdparser.C | 5 ++- src/test/testcases/test.xml | 1 + src/test/testcases/testSuspendIO.py | 58 ++++++++++++++++++++++++++++++++ src/test/testcases/testSuspendIO.xml | 30 +++++++++++++++++ 8 files changed, 168 insertions(+), 4 deletions(-) create mode 100755 src/test/testcases/testSuspendIO.py create mode 100755 src/test/testcases/testSuspendIO.xml diff --git a/src/sbefw/sbe_sp_intf.H b/src/sbefw/sbe_sp_intf.H index 7e109dca..c1cf688d 100644 --- a/src/sbefw/sbe_sp_intf.H +++ b/src/sbefw/sbe_sp_intf.H @@ -72,6 +72,7 @@ static const uint8_t SBE_CMD_UNKNOWN = 0x00; enum sbeIplControlCommands { SBE_CMD_EXECUTE_ISTEP = 0x01, /* Execute istep */ + SBE_CMD_SUSPEND_IO = 0x02, /* Suspend IO */ }; /** @@ -257,7 +258,7 @@ enum ADDRESS_BLACKLISTING_SUPPPORTED = 0x00000004, FIFO_RESET_SUPPPORTED = 0x00000008, EXECUTE_ISTEP_SUPPPORTED = 0xA1000001, - IS_SBE_DONE_SUPPPORTED = 0xA1000002, + SUSPEND_IO_SUPPPORTED = 0xA1000002, GET_SCOM_SUPPPORTED = 0xA2000001, PUT_SCOM_SUPPPORTED = 0xA2000002, MODIFY_SCOM_SUPPPORTED = 0xA2000004, diff --git a/src/sbefw/sbecmdgeneric.C b/src/sbefw/sbecmdgeneric.C index 6a99199d..5c7320b4 100644 --- a/src/sbefw/sbecmdgeneric.C +++ b/src/sbefw/sbecmdgeneric.C @@ -71,7 +71,8 @@ sbeCapabilityRespMsg::sbeCapabilityRespMsg() // @TODO via RTC : 160602 // Update Capability flags based on lastes spec. capability[IPL_CAPABILITY_START_IDX] = - EXECUTE_ISTEP_SUPPPORTED; + EXECUTE_ISTEP_SUPPPORTED | + SUSPEND_IO_SUPPPORTED; capability[SCOM_CAPABILITY_START_IDX] = GET_SCOM_SUPPPORTED | diff --git a/src/sbefw/sbecmdiplcontrol.C b/src/sbefw/sbecmdiplcontrol.C index 17fcb918..bc87e92f 100644 --- a/src/sbefw/sbecmdiplcontrol.C +++ b/src/sbefw/sbecmdiplcontrol.C @@ -105,6 +105,7 @@ #include "p9_hcd_cache_stopclocks.H" #include "p9_stopclocks.H" #include "p9_suspend_powman.H" +#include "p9_suspend_io.H" #include "sbeXipUtils.H" // For getting hbbl offset #include "sbeutil.H" // For getting SBE_TO_NEST_FREQ_FACTOR @@ -213,6 +214,7 @@ p9_sbe_select_ex_FP_t p9_sbe_select_ex_hwp = &p9_sbe_select_ex; extern p9_stopclocks_FP_t p9_stopclocks_hwp; //p9_thread_control_FP_t threadCntlhwp = &p9_thread_control; extern p9_thread_control_FP_t threadCntlhwp; +p9_suspend_io_FP_t p9_suspend_io_hwp = &p9_suspend_io; #endif //structure for mapping SBE wrapper and HWP functions @@ -858,7 +860,7 @@ ReturnCode istepStartInstruction( sbeIstepHwp_t i_hwp) if(rc == FAPI2_RC_SUCCESS) { (void)SbeRegAccess::theSbeRegAccess().stateTransition( - SBE_RUNTIME_EVENT); + SBE_RUNTIME_EVENT); } return rc; } @@ -1510,3 +1512,63 @@ ReturnCode resetCrespErrLatch( void ) return rc; #undef SBE_FUNC } + +/////////////////////////////////////////////////////////////////////// +// @brief sbeHandleSuspendIO Sbe suspend IO function +// +// @return RC from the underlying FIFO utility +/////////////////////////////////////////////////////////////////////// +uint32_t sbeHandleSuspendIO(uint8_t *i_pArg) +{ + #define SBE_FUNC " sbeHandleSuspendIO " + SBE_ENTER(SBE_FUNC); + uint32_t rc = SBE_SEC_OPERATION_SUCCESSFUL; + ReturnCode fapiRc = FAPI2_RC_SUCCESS; + uint32_t len = 0; + sbeRespGenHdr_t respHdr; + respHdr.init(); + sbeResponseFfdc_t ffdc; + Target procTgt = plat_getChipTarget(); + + do + { + // Dequeue the EOT entry as no more data is expected. + rc = sbeUpFifoDeq_mult (len, NULL); + CHECK_SBE_RC_AND_BREAK_IF_NOT_SUCCESS(rc); + + // Update the PHB functional State before suspend io procedure + fapiRc = updatePhbFunctionalState(); + if(fapiRc != FAPI2_RC_SUCCESS) + { + SBE_ERROR(SBE_FUNC "updatePhbFunctionalState failed"); + respHdr.setStatus( SBE_PRI_GENERIC_EXECUTION_FAILURE, + SBE_SEC_GENERIC_FAILURE_IN_EXECUTION); + ffdc.setRc(fapiRc); + break; + } + + SBE_EXEC_HWP(fapiRc, p9_suspend_io_hwp, procTgt, false); + if( fapiRc != FAPI2_RC_SUCCESS ) + { + SBE_ERROR(SBE_FUNC "p9_suspend_io hwp failed"); + respHdr.setStatus( SBE_PRI_GENERIC_EXECUTION_FAILURE, + SBE_SEC_GENERIC_FAILURE_IN_EXECUTION); + ffdc.setRc(fapiRc); + break; + } + }while(0); + + // Create the Response to caller + do + { + // If there was a FIFO error, will skip sending the response, + // instead give the control back to the command processor thread + CHECK_SBE_RC_AND_BREAK_IF_NOT_SUCCESS(rc); + rc = sbeDsSendRespHdr( respHdr, &ffdc); + }while(0); + + SBE_EXIT(SBE_FUNC); + return rc; + #undef SBE_FUNC +} + diff --git a/src/sbefw/sbecmdiplcontrol.H b/src/sbefw/sbecmdiplcontrol.H index d2b21af0..8429473a 100644 --- a/src/sbefw/sbecmdiplcontrol.H +++ b/src/sbefw/sbecmdiplcontrol.H @@ -121,5 +121,13 @@ uint32_t sbeGetSbeFfdc(uint8_t *i_pArg); */ uint32_t sbeGetFreqSupported(uint8_t *i_pArg); +/** + * @brief execute suspend IO chip-op (0xA102) + * + * @param[in] i_pArg Buffer to be passed to the function (not used as of now) + * + * @return Rc from the FIFO access utility + */ +uint32_t sbeHandleSuspendIO(uint8_t *i_pArg); #endif // __SBEFW_SBECMDIPLCONTROL_H diff --git a/src/sbefw/sbecmdparser.C b/src/sbefw/sbecmdparser.C index 3736aa1a..af7b51bb 100644 --- a/src/sbefw/sbecmdparser.C +++ b/src/sbefw/sbecmdparser.C @@ -94,7 +94,10 @@ static sbeCmdStruct_t g_sbeIplControlCmdArray [] = {sbeHandleIstep, SBE_CMD_EXECUTE_ISTEP, HARDWARE_FENCED_STATE|SBE_FENCE_AT_DUMPING, - // TODO - Issue 157287 - Allow MPIIPL in Isteps state + }, + {sbeHandleSuspendIO, + SBE_CMD_SUSPEND_IO, + SBE_FENCE_AT_DUMPING, }, }; diff --git a/src/test/testcases/test.xml b/src/test/testcases/test.xml index 9dd18c78..677cf9b2 100755 --- a/src/test/testcases/test.xml +++ b/src/test/testcases/test.xml @@ -33,6 +33,7 @@ ../simics/targets/p9_nimbus/sbeTest/testPSUSetStashPair.xml ../simics/targets/p9_nimbus/sbeTest/testIstep.xml ../simics/targets/p9_nimbus/sbeTest/testMatchStashPair.xml + ../simics/targets/p9_nimbus/sbeTest/testSuspendIO.xml ../simics/targets/p9_nimbus/sbeTest/testScom.xml ../simics/targets/p9_nimbus/sbeTest/testGeneric.xml diff --git a/src/test/testcases/testSuspendIO.py b/src/test/testcases/testSuspendIO.py new file mode 100755 index 00000000..2d30b44d --- /dev/null +++ b/src/test/testcases/testSuspendIO.py @@ -0,0 +1,58 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/test/testcases/testSuspendIO.py $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2017 +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG + +import sys +sys.path.append("targets/p9_nimbus/sbeTest" ) +import testUtil +err = False + +TESTDATA = [0,0,0,2, + 0,0,0xA1,0x02 ] + +EXPDATA = [0xc0,0xde,0xa1,0x02, + 0x0,0x0,0x0,0x0, + 0x00,0x0,0x0,0x3]; + + +# MAIN Test Run Starts Here... +#------------------------------------------------- +def main( ): + testUtil.runCycles( 10000000 ) + testUtil.writeUsFifo( TESTDATA ) + testUtil.writeEot( ) + testUtil.readDsFifo( EXPDATA ) + testUtil.readEot( ) + +#------------------------------------------------- +# Calling all test code +#------------------------------------------------- +main() + +if err: + print ("\nTest Suite completed with error(s)") + #sys.exit(1) +else: + print ("\nTest Suite completed with no errors") + #sys.exit(0); + diff --git a/src/test/testcases/testSuspendIO.xml b/src/test/testcases/testSuspendIO.xml new file mode 100755 index 00000000..2bcf96ba --- /dev/null +++ b/src/test/testcases/testSuspendIO.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + run-python-file targets/p9_nimbus/sbeTest/testSuspendIO.py + yes + + -- cgit v1.2.1