From 7aeebaf63655535a126885806a2776a8732fd799 Mon Sep 17 00:00:00 2001 From: Tobiasz Dryjanski Date: Wed, 10 Jul 2024 14:13:13 +0200 Subject: [PATCH] I/O performance monitor: add I/O performance counters to IPC interface Set up a measurement of number of input and output IPCs. Signed-off-by: Tobiasz Dryjanski --- src/audio/base_fw.c | 2 +- src/include/sof/ipc/common.h | 6 ++++++ src/ipc/ipc-common.c | 26 +++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/audio/base_fw.c b/src/audio/base_fw.c index 6fad9f5f5..39da6b1c7 100644 --- a/src/audio/base_fw.c +++ b/src/audio/base_fw.c @@ -476,7 +476,7 @@ static int io_global_perf_data_get(uint32_t *data_off_size, char *data) { #ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS int ret; - struct global_perf_data *perf_data = (struct global_perf_data *)data; + struct io_global_perf_data *perf_data = (struct io_global_perf_data *)data; ret = io_perf_monitor_get_performance_data(perf_data); if (ret < 0) diff --git a/src/include/sof/ipc/common.h b/src/include/sof/ipc/common.h index 09bf075ff..43ad023da 100644 --- a/src/include/sof/ipc/common.h +++ b/src/include/sof/ipc/common.h @@ -70,6 +70,12 @@ struct ipc { /* processing task */ struct task ipc_task; +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* io performance measurement */ + struct io_perf_data_item *io_perf_in_msg_count; + struct io_perf_data_item *io_perf_out_msg_count; +#endif + #ifdef __ZEPHYR__ struct k_work_delayable z_delayed_work; #endif diff --git a/src/ipc/ipc-common.c b/src/ipc/ipc-common.c index 0bb57b277..bf94e0481 100644 --- a/src/ipc/ipc-common.c +++ b/src/ipc/ipc-common.c @@ -32,6 +32,8 @@ #include #include +#include + LOG_MODULE_REGISTER(ipc, CONFIG_SOF_LOG_LEVEL); SOF_DEFINE_REG_UUID(ipc); @@ -154,9 +156,14 @@ void ipc_send_queued_msg(void) msg = list_first_item(&ipc->msg_list, struct ipc_msg, list); - if (ipc_platform_send_msg(msg) == 0) + if (ipc_platform_send_msg(msg) == 0) { /* Remove the message from the list if it has been successfully sent. */ list_item_del(&msg->list); +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* Increment performance counters */ + io_perf_monitor_update_data(ipc->io_perf_out_msg_count, 1); +#endif + } out: k_spin_unlock(&ipc->lock, key); } @@ -274,6 +281,18 @@ int ipc_init(struct sof *sof) list_init(&sof->ipc->msg_list); list_init(&sof->ipc->comp_list); +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + struct io_perf_data_item init_data = {IO_PERF_IPC_ID, + cpu_get_id(), + IO_PERF_INPUT_DIRECTION, + IO_PERF_POWERED_UP_ENABLED, + IO_PERF_D0IX_POWER_MODE, + 0, 0, 0 }; + io_perf_monitor_init_data(&sof->ipc->io_perf_in_msg_count, &init_data); + init_data.direction = IO_PERF_OUTPUT_DIRECTION; + io_perf_monitor_init_data(&sof->ipc->io_perf_out_msg_count, &init_data); +#endif + #ifdef __ZEPHYR__ k_work_init_delayable(&sof->ipc->z_delayed_work, ipc_work_handler); #endif @@ -317,6 +336,11 @@ static enum task_state ipc_do_cmd(void *data) { struct ipc *ipc = data; +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* Increment performance counters */ + io_perf_monitor_update_data(ipc->io_perf_in_msg_count, 1); +#endif + /* * 32-bit writes are atomic and at the moment no IPC processing is * taking place, so, no need for a lock.