Skip to content

Commit

Permalink
I/O performance monitor: add I/O performance counters to IPC interface
Browse files Browse the repository at this point in the history
Set up a measurement of number of input and output IPCs.

Signed-off-by: Tobiasz Dryjanski <tobiaszx.dryjanski@intel.com>
  • Loading branch information
tobonex committed Jul 25, 2024
1 parent 3e7f184 commit e04abc7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/audio/base_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,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)
Expand Down
6 changes: 6 additions & 0 deletions src/include/sof/ipc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,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
Expand Down
26 changes: 25 additions & 1 deletion src/ipc/ipc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <stddef.h>
#include <stdint.h>

#include <sof/debug/telemetry/performance_monitor.h>

LOG_MODULE_REGISTER(ipc, CONFIG_SOF_LOG_LEVEL);

SOF_DEFINE_REG_UUID(ipc);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 = {IPC_ID,
cpu_get_id(),
INPUT_DIRECTION,
POWERED_UP_ENABLED,
D0IX_POWER_MODE,
0, 0, 0 };
io_perf_monitor_init_data(&sof->ipc->io_perf_in_msg_count, &init_data);
init_data.direction = 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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e04abc7

Please sign in to comment.