From 5866406fb193e8d58162c13207b0d3f078a7e9db Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Wed, 15 May 2019 15:32:17 +0200 Subject: [PATCH] cavs: ipc: added ipc received and processed counters I've added counters for processed and received ipc tasks. They are dropped after trace points in memory window. Signed-off-by: Bartosz Kokoszko --- Kconfig | 8 ++++++ src/drivers/intel/cavs/ipc.c | 26 +++++++++++++++++++ .../apollolake/include/platform/memory.h | 10 ++++--- .../cannonlake/include/platform/memory.h | 10 ++++--- .../icelake/include/platform/memory.h | 10 ++++--- 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/Kconfig b/Kconfig index 4c89b3557b1d..f991b70e36e2 100644 --- a/Kconfig +++ b/Kconfig @@ -140,4 +140,12 @@ config BUILD_VM_ROM help Select if you want to build VM ROM +config DEBUG_IPC_COUNTERS + bool "IPC counters" + depends on CAVS + depends on DEBUG + default n + help + Select for enabling tracing IPC counter in SRAM_REG mailbox + endmenu diff --git a/src/drivers/intel/cavs/ipc.c b/src/drivers/intel/cavs/ipc.c index 5ca723f54a98..42ec8ffb8858 100644 --- a/src/drivers/intel/cavs/ipc.c +++ b/src/drivers/intel/cavs/ipc.c @@ -56,6 +56,24 @@ extern struct ipc *_ipc; +#if CONFIG_DEBUG_IPC_COUNTERS +static inline void increment_ipc_received_counter(void) +{ + static uint32_t ipc_received_counter; + + mailbox_sw_reg_write(SRAM_REG_FW_IPC_RECEIVED_COUNT, + ipc_received_counter++); +} + +static inline void increment_ipc_processed_counter(void) +{ + static uint32_t ipc_processed_counter; + + mailbox_sw_reg_write(SRAM_REG_FW_IPC_PROCESSED_COUNT, + ipc_processed_counter++); +} +#endif + /* test code to check working IRQ */ static void ipc_irq_handler(void *arg) { @@ -93,6 +111,10 @@ static void ipc_irq_handler(void *arg) /* mask Busy interrupt */ ipc_write(IPC_DIPCCTL, dipcctl & ~IPC_DIPCCTL_IPCTBIE); +#if CONFIG_DEBUG_IPC_COUNTERS + increment_ipc_received_counter(); +#endif + /* TODO: place message in Q and process later */ /* It's not Q ATM, may overwrite */ if (_ipc->host_pending) { @@ -174,6 +196,10 @@ void ipc_platform_do_cmd(struct ipc *ipc) ipc_write(IPC_DIPCTDA, ipc_read(IPC_DIPCTDA) | IPC_DIPCTDA_BUSY); #endif +#if CONFIG_DEBUG_IPC_COUNTERS + increment_ipc_processed_counter(); +#endif + /* unmask Busy interrupt */ ipc_write(IPC_DIPCCTL, ipc_read(IPC_DIPCCTL) | IPC_DIPCCTL_IPCTBIE); diff --git a/src/platform/apollolake/include/platform/memory.h b/src/platform/apollolake/include/platform/memory.h index 053915790947..719c0499570e 100644 --- a/src/platform/apollolake/include/platform/memory.h +++ b/src/platform/apollolake/include/platform/memory.h @@ -258,10 +258,12 @@ #define SRAM_SW_REG_SIZE 0x1000 /* SRAM window 0 FW "registers" */ -#define SRAM_REG_ROM_STATUS 0x0 -#define SRAM_REG_FW_STATUS 0x4 -#define SRAM_REG_FW_TRACEP 0x8 -#define SRAM_REG_FW_END 0xc +#define SRAM_REG_ROM_STATUS 0x0 +#define SRAM_REG_FW_STATUS 0x4 +#define SRAM_REG_FW_TRACEP 0x8 +#define SRAM_REG_FW_IPC_RECEIVED_COUNT 0xc +#define SRAM_REG_FW_IPC_PROCESSED_COUNT 0x10 +#define SRAM_REG_FW_END 0x14 #define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) #define SRAM_OUTBOX_SIZE 0x1000 diff --git a/src/platform/cannonlake/include/platform/memory.h b/src/platform/cannonlake/include/platform/memory.h index 30011de73ae3..0caffa064a84 100644 --- a/src/platform/cannonlake/include/platform/memory.h +++ b/src/platform/cannonlake/include/platform/memory.h @@ -203,10 +203,12 @@ #define SRAM_SW_REG_SIZE 0x1000 /* SRAM window 0 FW "registers" */ -#define SRAM_REG_ROM_STATUS 0x0 -#define SRAM_REG_FW_STATUS 0x4 -#define SRAM_REG_FW_TRACEP 0x8 -#define SRAM_REG_FW_END 0xc +#define SRAM_REG_ROM_STATUS 0x0 +#define SRAM_REG_FW_STATUS 0x4 +#define SRAM_REG_FW_TRACEP 0x8 +#define SRAM_REG_FW_IPC_RECEIVED_COUNT 0xc +#define SRAM_REG_FW_IPC_PROCESSED_COUNT 0x10 +#define SRAM_REG_FW_END 0x14 #define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) #define SRAM_OUTBOX_SIZE 0x1000 diff --git a/src/platform/icelake/include/platform/memory.h b/src/platform/icelake/include/platform/memory.h index 4ab15f68db6f..5a02cb1eec4a 100644 --- a/src/platform/icelake/include/platform/memory.h +++ b/src/platform/icelake/include/platform/memory.h @@ -206,10 +206,12 @@ #define SRAM_SW_REG_SIZE 0x1000 /* SRAM window 0 FW "registers" */ -#define SRAM_REG_ROM_STATUS 0x0 -#define SRAM_REG_FW_STATUS 0x4 -#define SRAM_REG_FW_TRACEP 0x8 -#define SRAM_REG_FW_END 0xc +#define SRAM_REG_ROM_STATUS 0x0 +#define SRAM_REG_FW_STATUS 0x4 +#define SRAM_REG_FW_TRACEP 0x8 +#define SRAM_REG_FW_IPC_RECEIVED_COUNT 0xc +#define SRAM_REG_FW_IPC_PROCESSED_COUNT 0x10 +#define SRAM_REG_FW_END 0x14 #define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) #define SRAM_OUTBOX_SIZE 0x1000