From 0e10666787ee49021f5731d464c43d16fa207fbb Mon Sep 17 00:00:00 2001 From: Tobiasz Dryjanski Date: Wed, 10 Jul 2024 18:52:32 +0200 Subject: [PATCH] I/O performance monitor: Add I/O measurements for IDC interface Set up a counter of input and output IDCs. Signed-off-by: Tobiasz Dryjanski --- src/idc/idc.c | 19 +++++++++++++++++++ src/idc/zephyr_idc.c | 12 ++++++++++++ zephyr/include/rtos/idc.h | 7 +++++++ 3 files changed, 38 insertions(+) diff --git a/src/idc/idc.c b/src/idc/idc.c index 69c7ad1f84bd..12491cc22fbe 100644 --- a/src/idc/idc.c +++ b/src/idc/idc.c @@ -34,6 +34,8 @@ #include #include +#include + LOG_MODULE_REGISTER(idc, CONFIG_SOF_LOG_LEVEL); /** \brief IDC message payload per core. */ @@ -481,6 +483,11 @@ static void idc_complete(void *data) uint32_t type = iTS(idc->received_msg.header); k_spinlock_key_t key; +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* Increment performance counters */ + io_perf_monitor_update_data(idc->io_perf_out_msg_count, 1); +#endif + switch (type) { case iTS(IDC_MSG_IPC): /* Signal the host */ @@ -511,6 +518,18 @@ int idc_init(void) /* initialize idc data */ (*idc)->payload = platform_shared_get(static_payload, sizeof(static_payload)); +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + struct io_perf_data_item init_data = {IDC_ID, + cpu_get_id(), + INPUT_DIRECTION, + POWERED_UP_ENABLED, + D0IX_POWER_MODE, + 0, 0, 0 }; + io_perf_monitor_init_data(&(*idc)->io_perf_in_msg_count, &init_data); + init_data.direction = OUTPUT_DIRECTION; + io_perf_monitor_init_data(&(*idc)->io_perf_out_msg_count, &init_data); +#endif + /* process task */ #ifndef __ZEPHYR__ schedule_task_init_edf(&(*idc)->idc_task, SOF_UUID(idc_cmd_task_uuid), diff --git a/src/idc/zephyr_idc.c b/src/idc/zephyr_idc.c index 74a0da0f5bab..664d09a260ca 100644 --- a/src/idc/zephyr_idc.c +++ b/src/idc/zephyr_idc.c @@ -33,6 +33,8 @@ #include #include +#include + LOG_MODULE_REGISTER(zephyr_idc, CONFIG_SOF_LOG_LEVEL); SOF_DEFINE_REG_UUID(zephyr_idc); @@ -88,6 +90,11 @@ static void idc_handler(struct k_p4wq_work *work) idc->received_msg.header = msg->header; idc->received_msg.extension = msg->extension; +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* Increment performance counters */ + io_perf_monitor_update_data(idc->io_perf_in_msg_count, 1); +#endif + switch (msg->header) { case IDC_MSG_POWER_UP: /* Run the core initialisation? */ @@ -151,6 +158,11 @@ int idc_send_msg(struct idc_msg *msg, uint32_t mode) k_p4wq_submit(q_zephyr_idc + target_cpu, work); +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* Increment performance counters */ + io_perf_monitor_update_data(idc->io_perf_out_msg_count, 1); +#endif + switch (mode) { case IDC_BLOCKING: ret = k_p4wq_wait(work, K_USEC(IDC_TIMEOUT)); diff --git a/zephyr/include/rtos/idc.h b/zephyr/include/rtos/idc.h index 178048eb0cbd..8fdfb09f3c99 100644 --- a/zephyr/include/rtos/idc.h +++ b/zephyr/include/rtos/idc.h @@ -20,6 +20,8 @@ #include #include +#include + /** \brief IDC send blocking flag. */ #define IDC_BLOCKING 0 @@ -171,6 +173,11 @@ struct idc { struct task idc_task; /**< IDC processing task */ struct idc_payload *payload; int irq; +#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 }; /* idc trace context, used by multiple units */