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 <tobiaszx.dryjanski@intel.com>
  • Loading branch information
tobonex committed Jul 26, 2024
1 parent 57d0980 commit 55dab6c
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
51 changes: 51 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 @@ -342,6 +344,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 @@ -434,6 +440,47 @@ 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 = I2S_ID;
break;
case SOF_DAI_INTEL_ALH:
perf_type = SOUND_WIRE_ID;
break;
case SOF_DAI_INTEL_DMIC:
perf_type = DMIC_ID;
break;
case SOF_DAI_INTEL_HDA:
perf_type = HDA_ID;
break;

default:
perf_type = INVALID_ID;
}
if (dai_cfg->direction == SOF_IPC_STREAM_PLAYBACK)
perf_dir = INPUT_DIRECTION;
else
perf_dir = OUTPUT_DIRECTION;

/* ignore perf meas init on case of other dai types */
if (perf_type != INVALID_ID) {
struct io_perf_data_item init_data = {perf_type,
cpu_get_id(),
perf_dir,
POWERED_UP_ENABLED,
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 @@ -491,6 +538,10 @@ void dai_common_free(struct dai_data *dd)

dai_put(dd->dai);

#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
io_perf_monitor_release_slot(dd->io_perf_bytes_count);
#endif

rfree(dd->dai_spec_config);
}

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 @@ -149,6 +151,10 @@ struct dai_data {
uint32_t sampling;
/* 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 55dab6c

Please sign in to comment.