Skip to content

Commit

Permalink
I/O performance monitor: Add I/O measurement for DAI
Browse files Browse the repository at this point in the history
Adds I/O performance measurement for audio unterfaces in DAI (SNDW, DMIC,
SSP, HDA).

Signed-off-by: Tobiasz Dryjanski <[email protected]>
  • Loading branch information
tobonex authored and kv2019i committed Sep 18, 2024
1 parent d1095d4 commit d595afd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -523,6 +571,10 @@ static struct comp_dev *dai_new(const struct comp_driver *drv,

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);

Expand Down
6 changes: 6 additions & 0 deletions src/include/sof/lib/dai-zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* @{
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit d595afd

Please sign in to comment.