From 9f90433232b883ebd760265736e64bfb840b7554 Mon Sep 17 00:00:00 2001 From: spashabk-in Date: Fri, 18 May 2018 04:14:04 -0500 Subject: Support periodic timer This timer will be sued to toggle EI bus after every 24 hours. Change-Id: Id21af317914ddfb02d42a166bc7c0b6ce62bffdd Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/60777 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: RAJA DAS Reviewed-by: Sachin Gupta (cherry picked from commit 4fe7e7c6520087ec1416e332be2b0b8ca85574d4) Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/48096 --- src/build/img_defs.mk | 7 +++- src/build/import_hwp_mk/power/istepmpipl/Makefile | 2 +- .../power/istepmpipl/istepmpiplfiles.mk | 2 + src/build/power_defs.mk | 1 + src/sbefw/core/sbe_sp_intf.H | 1 + src/sbefw/core/sbecmdprocessor.C | 44 +++++++++++++++++++--- src/sbefw/core/sbeglobals.H | 10 +++++ src/sbefw/core/sbemain.C | 9 +++++ 8 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/build/img_defs.mk b/src/build/img_defs.mk index c6cd7d8d..24b82b95 100644 --- a/src/build/img_defs.mk +++ b/src/build/img_defs.mk @@ -135,6 +135,10 @@ ifndef NEST_SRCDIR export NEST_SRCDIR = $(IMPORT_SRCDIR)/chips/p9/procedures/hwp/nest endif +ifndef IO_SRCDIR +export IO_SRCDIR = $(IMPORT_SRCDIR)/chips/p9/procedures/hwp/io +endif + ifndef PM_SRCDIR export PM_SRCDIR = $(IMPORT_SRCDIR)/chips/p9/procedures/hwp/pm endif @@ -184,7 +188,7 @@ export P9_XIP_BINDIR = $(BASE_OBJDIR)/xip endif ifndef IMG_INCLUDES -export IMG_INCLUDES = -I$(IMAGEPROCS_COMMON_SRCDIR) -I$(IMAGEPROCS_P9_SRCDIR) -I$(IMAGEPROCS_CEN_SRCDIR) -I$(P9_XIP_SRCDIR) -I$(BUILD_DIR) -I$(CACHE_SRCDIR) -I$(UTILS_SRCDIR) -I$(CORE_SRCDIR) -I$(PERV_SRCDIR) -I$(NEST_SRCDIR) -I$(PM_SRCDIR) -I$(INITFILES_SRCDIR) -I$(HWPLIB_SRCDIR) -I$(HWPFFDC_SRCDIR) +export IMG_INCLUDES = -I$(IMAGEPROCS_COMMON_SRCDIR) -I$(IMAGEPROCS_P9_SRCDIR) -I$(IMAGEPROCS_CEN_SRCDIR) -I$(P9_XIP_SRCDIR) -I$(BUILD_DIR) -I$(CACHE_SRCDIR) -I$(UTILS_SRCDIR) -I$(CORE_SRCDIR) -I$(PERV_SRCDIR) -I$(NEST_SRCDIR) -I$(IO_SRCDIR) -I$(PM_SRCDIR) -I$(INITFILES_SRCDIR) -I$(HWPLIB_SRCDIR) -I$(HWPFFDC_SRCDIR) endif ifndef BOOT_OBJDIR @@ -378,6 +382,7 @@ GCC-DEFS += -DPLAT_NO_THREAD_LOCAL_STORAGE=1 # disable assert GCC-DEFS += -DNDEBUG GCC-DEFS += -DHOST_INTERFACE_AVAILABLE=$(HOST_INTERFACE_AVAILABLE) +GCC-DEFS += -DPERIODIC_IO_TOGGLE_SUPPORTED=$(PERIODIC_IO_TOGGLE_SUPPORTED) # use the default settings in the code unless a size is defined ifdef PK_TRACE_SZ diff --git a/src/build/import_hwp_mk/power/istepmpipl/Makefile b/src/build/import_hwp_mk/power/istepmpipl/Makefile index f9cba2db..4cc55c04 100644 --- a/src/build/import_hwp_mk/power/istepmpipl/Makefile +++ b/src/build/import_hwp_mk/power/istepmpipl/Makefile @@ -31,7 +31,7 @@ export SUB_OBJDIR = /$(IMPORT_OBJDIR)/istepmpipl include img_defs.mk include istepmpiplfiles.mk -export VPATH = $(PERV_SRCDIR):$(NEST_SRCDIR):$(CACHE_SRCDIR):$(CORE_SRCDIR):$(PM_SRCDIR):$(INITFILES_SRCDIR):$(HWPLIB_SRCDIR) +export VPATH = $(PERV_SRCDIR):$(NEST_SRCDIR):$(IO_SRCDIR):$(CACHE_SRCDIR):$(CORE_SRCDIR):$(PM_SRCDIR):$(INITFILES_SRCDIR):$(HWPLIB_SRCDIR) OBJSISTEPMPIPL := $(addprefix $(OBJDIR-ISTEPMPIPL)/, $(ISTEPMPIPL_OBJECTS)) diff --git a/src/build/import_hwp_mk/power/istepmpipl/istepmpiplfiles.mk b/src/build/import_hwp_mk/power/istepmpipl/istepmpiplfiles.mk index e353031f..e84c70ca 100644 --- a/src/build/import_hwp_mk/power/istepmpipl/istepmpiplfiles.mk +++ b/src/build/import_hwp_mk/power/istepmpipl/istepmpiplfiles.mk @@ -58,6 +58,8 @@ ISTEPMPIPL-CPP-SOURCES +=p9_query_cache_access_state.C ISTEPMPIPL-CPP-SOURCES += p9_sbe_fastarray_abist_catchup.C ISTEPMPIPL-CPP-SOURCES += p9_sbe_fastarray_cleanup.C ISTEPMPIPL-CPP-SOURCES += p9_sbe_fastarray_setup.C +# io eol toggle procedure moved here to locate it on seeprom +ISTEPMPIPL-CPP-SOURCES += p9_sbe_io_eol_toggle.C ISTEPMPIPL-C-SOURCES = ISTEPMPIPL-S-SOURCES = diff --git a/src/build/power_defs.mk b/src/build/power_defs.mk index d9db8b07..d9304180 100644 --- a/src/build/power_defs.mk +++ b/src/build/power_defs.mk @@ -33,6 +33,7 @@ SBE_TRACE_LEVEL_DEF = 2 FAPI_TRACE_LEVEL_DEF = 2 HOST_INTERFACE_AVAILABLE = 1 +PERIODIC_IO_TOGGLE_SUPPORTED = 1 export SBE_S0_SUPPORT = 1 diff --git a/src/sbefw/core/sbe_sp_intf.H b/src/sbefw/core/sbe_sp_intf.H index e35ac4be..b283777b 100644 --- a/src/sbefw/core/sbe_sp_intf.H +++ b/src/sbefw/core/sbe_sp_intf.H @@ -225,6 +225,7 @@ enum sbeSecondaryResponse SBE_SEC_S0_START_MPIPL_FAILED = 0x24, SBE_SEC_S0_STOP_CLOCK_FAILED = 0x25, SBE_SEC_S0_CONTINUE_MPIPL_FAILED = 0x26, + SBE_SEC_PERIODIC_IO_TOGGLE_FAILED = 0x27, }; /** diff --git a/src/sbefw/core/sbecmdprocessor.C b/src/sbefw/core/sbecmdprocessor.C index 32645255..e200babf 100644 --- a/src/sbefw/core/sbecmdprocessor.C +++ b/src/sbefw/core/sbecmdprocessor.C @@ -48,11 +48,18 @@ #include "sbeglobals.H" #include "core/chipop_handler.H" #include "core/ipl.H" +#include "sbeFFDC.H" #ifdef _S0_ #include "sbes0handler.H" #endif +#if PERIODIC_IO_TOGGLE_SUPPORTED +#include "p9_sbe_io_eol_toggle.H" +#endif + +const uint32_t PERIODIC_TIMER_INTERVAL_MS = 24*60*60*1000; // 24 hours + using namespace fapi2; // Forward declaration for performAttrSetup @@ -418,18 +425,45 @@ void sbeSyncCommandProcessor_routine(void *i_pArg) #endif } while(true); // Thread always exists SBE_EXIT(SBE_FUNC); + #undef SBE_FUNC } ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// void sbeAsyncCommandProcessor_routine(void *arg) { - SBE_INFO("sbeAsyncCommandProcessor Thread started"); - + #define SBE_FUNC "sbeAsyncCommandProcessor" + SBE_INFO(SBE_FUNC " Thread started"); + #if PERIODIC_IO_TOGGLE_SUPPORTED do { - // @TODO RTC via : 130392 - // Add infrastructure for host interface + // Since currently there is only one async job + // - IO EOL toggle, this task runs every + // PERIODIC_TIMER_INTERVAL_MS and performs the + // operation. Modify this implementation by introducing job + // queue, if there are more asynchronous jobs. + int l_rcPk = pk_semaphore_pend ( + &SBE_GLOBAL->sbeSemAsyncProcess, + PK_MILLISECONDS(PERIODIC_TIMER_INTERVAL_MS)); + // PK API failure + if ((-l_rcPk) != PK_SEMAPHORE_PEND_TIMED_OUT) + { + SBE_ERROR(SBE_FUNC" pk_semaphore_pend failed, " + "l_rcPk=-%04x", -l_rcPk ); + // Ignore the failure + } - } while(0); + ReturnCode rc = FAPI2_RC_SUCCESS; + Target proc = plat_getChipTarget(); + SBE_EXEC_HWP(rc, p9_sbe_io_eol_toggle, proc) + if (rc != FAPI2_RC_SUCCESS) + { + SBE_ERROR(SBE_FUNC " p9_sbe_io_eol_toggle failed"); + // SBE async ffdc + captureAsyncFFDC(SBE_PRI_GENERIC_EXECUTION_FAILURE, + SBE_SEC_PERIODIC_IO_TOGGLE_FAILED); + } + } while(1); + #endif // PERIODIC_IO_TOGGLE_SUPPORTED + #undef SBE_FUNC } diff --git a/src/sbefw/core/sbeglobals.H b/src/sbefw/core/sbeglobals.H index 8ddb06be..e7bd76b6 100644 --- a/src/sbefw/core/sbeglobals.H +++ b/src/sbefw/core/sbeglobals.H @@ -76,6 +76,15 @@ class SBEGlobalsSingleton * */ PkSemaphore sbeSemCmdProcess; + + /** + * @brief Global semaphore for async task + * + * This is used to send invoke commands on Async process + * + */ + PkSemaphore sbeSemAsyncProcess; + sbeRole SBERole; // SBE Frequency. Initially nest frequency is 133 MHZ uint32_t sbefreq; @@ -138,6 +147,7 @@ class SBEGlobalsSingleton sbeIntrSource(), sbeSemCmdRecv(), sbeSemCmdProcess(), + sbeSemAsyncProcess(), SBERole(SBE_ROLE_MASTER), sbefreq(( 133 * 1000 * 1000)/SBE::SBE_TO_NEST_FREQ_FACTOR), sbeFWSecurityEnabled(1) diff --git a/src/sbefw/core/sbemain.C b/src/sbefw/core/sbemain.C index bc84739b..327c3339 100644 --- a/src/sbefw/core/sbemain.C +++ b/src/sbefw/core/sbemain.C @@ -49,6 +49,9 @@ // Max defines for Semaphores static uint32_t MAX_SEMAPHORE_COUNT = 3; +// As periodic timer expire in 24 hours count should never +// be more than 1. +static uint32_t MAX_PERIODIC_TIMER_SEMAPHORE_COUNT = 1; extern "C" { // These variables are declared in linker script to keep track of @@ -119,6 +122,12 @@ uint32_t sbeInitSems(void) { break; } + l_rc = pk_semaphore_create(&SBE_GLOBAL->sbeSemAsyncProcess, 0, + MAX_PERIODIC_TIMER_SEMAPHORE_COUNT); + if (l_rc) + { + break; + } } while (false); if (l_rc) -- cgit v1.2.1