From d595afd87d8344c1ced5b5e11adb3a11844d0b52 Mon Sep 17 00:00:00 2001 From: Tobiasz Dryjanski Date: Wed, 17 Jul 2024 11:46:09 +0200 Subject: [PATCH] I/O performance monitor: Add I/O measurement for DAI Adds I/O performance measurement for audio unterfaces in DAI (SNDW, DMIC, SSP, HDA). Signed-off-by: Tobiasz Dryjanski --- src/audio/dai-zephyr.c | 52 ++++++++++++++++++++++++++++++++ src/include/sof/lib/dai-zephyr.h | 6 ++++ 2 files changed, 58 insertions(+) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index aea7a64d1..89185c3f4 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -41,6 +41,8 @@ #include #include +#include + /* note: if this macro is not defined * then that means the HOST and the DSP * have the same view of the address space. @@ -383,6 +385,10 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, /* update host position (in bytes offset) for drivers */ dd->total_data_processed += bytes; } +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* Increment performance counters */ + io_perf_monitor_update_data(dd->io_perf_bytes_count, bytes); +#endif return dma_status; } @@ -478,6 +484,48 @@ int dai_common_new(struct dai_data *dd, struct comp_dev *dev, dd->xrun = 0; dd->chan = NULL; + /* I/O performance init, keep it last so the function does not reach this in case + * of return on error, so that we do not waste a slot + */ +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + enum io_perf_data_item_id perf_type; + enum io_perf_data_item_dir perf_dir; + + switch (dai_cfg->type) { + case SOF_DAI_INTEL_SSP: + perf_type = IO_PERF_I2S_ID; + break; + case SOF_DAI_INTEL_ALH: + perf_type = IO_PERF_SOUND_WIRE_ID; + break; + case SOF_DAI_INTEL_DMIC: + perf_type = IO_PERF_DMIC_ID; + break; + case SOF_DAI_INTEL_HDA: + perf_type = IO_PERF_HDA_ID; + break; + + default: + perf_type = IO_PERF_INVALID_ID; + comp_warn(dev, "Unsupported DAI type"); + } + if (dai_cfg->direction == SOF_IPC_STREAM_PLAYBACK) + perf_dir = IO_PERF_OUTPUT_DIRECTION; + else + perf_dir = IO_PERF_INPUT_DIRECTION; + + /* ignore perf meas init on case of other dai types */ + if (perf_type != IO_PERF_INVALID_ID) { + struct io_perf_data_item init_data = {perf_type, + cpu_get_id(), + perf_dir, + IO_PERF_POWERED_UP_ENABLED, + IO_PERF_D0IX_POWER_MODE, + 0, 0, 0 }; + io_perf_monitor_init_data(&dd->io_perf_bytes_count, &init_data); + } +#endif + return 0; } @@ -523,6 +571,10 @@ e_data: void dai_common_free(struct dai_data *dd) { +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + io_perf_monitor_release_slot(dd->io_perf_bytes_count); +#endif + if (dd->group) dai_group_put(dd->group); diff --git a/src/include/sof/lib/dai-zephyr.h b/src/include/sof/lib/dai-zephyr.h index 797d17540..5af6f5aee 100644 --- a/src/include/sof/lib/dai-zephyr.h +++ b/src/include/sof/lib/dai-zephyr.h @@ -35,6 +35,8 @@ #include #include +#include + /** \addtogroup sof_dai_drivers DAI Drivers * DAI Drivers API specification. * @{ @@ -157,6 +159,10 @@ struct dai_data { struct llp_slot_info slot_info; /* fast mode, use one byte memory to save repreated cycles */ bool fast_mode; +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* io performance measurement */ + struct io_perf_data_item *io_perf_bytes_count; +#endif }; /* these 3 are here to satisfy clk.c and ssp.h interconnection, will be removed leter */