From 4b8bebae9aa12c2e0e0e7a5220f9009291e5a2e6 Mon Sep 17 00:00:00 2001 From: Michael Rogenmoser Date: Fri, 4 Aug 2023 14:20:05 +0200 Subject: [PATCH] Add DMR performance section code --- include/archi/hmr/hmr_v1.h | 5 +- include/hal/hmr/hmr_v1.h | 20 ++++- include/pulp.h | 5 +- kernel/hmr_synch.c | 159 +++++++++++++++++++++++++++++++++---- 4 files changed, 169 insertions(+), 20 deletions(-) diff --git a/include/archi/hmr/hmr_v1.h b/include/archi/hmr/hmr_v1.h index 6eb7b2b..fc5f891 100644 --- a/include/archi/hmr/hmr_v1.h +++ b/include/archi/hmr/hmr_v1.h @@ -80,6 +80,8 @@ extern "C" { #define HMR_REGISTERS_DMR_CONFIG_REG_OFFSET 0x10 #define HMR_REGISTERS_DMR_CONFIG_RAPID_RECOVERY_BIT 0 #define HMR_REGISTERS_DMR_CONFIG_FORCE_RECOVERY_BIT 1 +#define HMR_REGISTERS_DMR_CONFIG_SETBACK_BIT 2 +#define HMR_REGISTERS_DMR_CONFIG_SYNCH_REQ_BIT 3 // TMR configuration bits. #define HMR_REGISTERS_TMR_CONFIG_REG_OFFSET 0x14 @@ -144,7 +146,8 @@ extern "C" { #define HMR_DMR_REGS_DMR_CONFIG_REG_OFFSET 0x4 #define HMR_DMR_REGS_DMR_CONFIG_RAPID_RECOVERY_BIT 0 #define HMR_DMR_REGS_DMR_CONFIG_FORCE_RECOVERY_BIT 1 -#define HMR_DMR_REGS_DMR_CONFIG_SETBACK_BIT 1 +#define HMR_DMR_REGS_DMR_CONFIG_SETBACK_BIT 2 +#define HMR_DMR_REGS_DMR_CONFIG_SYNCH_REQ_BIT 3 // Address for the last checkpoint. #define HMR_DMR_REGS_CHECKPOINT_ADDR_REG_OFFSET 0x8 diff --git a/include/hal/hmr/hmr_v1.h b/include/hal/hmr/hmr_v1.h index bb7817c..c86181e 100644 --- a/include/hal/hmr/hmr_v1.h +++ b/include/hal/hmr/hmr_v1.h @@ -94,14 +94,26 @@ static inline void hmr_disable_dmr(unsigned int cid, unsigned int dmr_id) { pulp_write32(ARCHI_HMR_GLOBAL_ADDR(cid) + HMR_DMR_OFFSET + HMR_DMR_INCREMENT*dmr_id + HMR_DMR_REGS_DMR_ENABLE_REG_OFFSET, 0); } -static inline void hmr_set_dmr_config(unsigned int cid, unsigned int dmr_id, bool rapid_recovery) { +static inline void hmr_set_dmr_config(unsigned int cid, unsigned int dmr_id, bool rapid_recovery, bool setback, bool synch_req) { pulp_write32(ARCHI_HMR_GLOBAL_ADDR(cid) + HMR_DMR_OFFSET + HMR_DMR_INCREMENT*dmr_id + HMR_DMR_REGS_DMR_CONFIG_REG_OFFSET, - (rapid_recovery ? 1< this should lock the cores together eu_bar_trig_wait_clr(eu_bar_addr(DMR_BARRIER_ID(DMR_GROUP_ID(core_id())))); @@ -475,6 +476,11 @@ void __attribute__((naked)) pos_hmr_dmr_synch() { pos_hmr_sw_reload(); } +void __attribute__((naked)) pos_hmr_dmr_synch() { + pos_hmr_dmr_synch_entry(); + pos_hmr_dmr_synch_exit(); +} + int hmr_tmr_critical_section(int (*function_handle)()) { int ret = 0; if (TMR_IS_MAIN_CORE(core_id())) { @@ -507,10 +513,6 @@ int hmr_dmr_critical_section(int (*function_handle)()) { } void hmr_tmr_performance_section(void (*function_handle)()) { - __asm__ __volatile__( - "la ra, pos_hmr_perf_help\n\t" - "csrw 0x341, ra\n\t" - ); volatile unsigned int tmr_group_id = TMR_GROUP_ID(core_id()); unsigned int tmr_config = hmr_get_tmr_config(0, tmr_group_id); hmr_set_tmr_config_bare(0, tmr_group_id, tmr_config & ~(1<