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 <tobiaszx.dryjanski@intel.com>
This commit is contained in:
Tobiasz Dryjanski 2024-07-17 11:46:09 +02:00 committed by Kai Vehmanen
parent d1095d4081
commit d595afd87d
2 changed files with 58 additions and 0 deletions

View File

@ -41,6 +41,8 @@
#include <zephyr/device.h>
#include <zephyr/drivers/dai.h>
#include <sof/debug/telemetry/performance_monitor.h>
/* 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);

View File

@ -35,6 +35,8 @@
#include <zephyr/device.h>
#include <zephyr/drivers/dai.h>
#include <sof/debug/telemetry/performance_monitor.h>
/** \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 */