Skip to content

Commit d595afd

Browse files
tobonexkv2019i
authored andcommitted
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>
1 parent d1095d4 commit d595afd

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

src/audio/dai-zephyr.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#include <zephyr/device.h>
4242
#include <zephyr/drivers/dai.h>
4343

44+
#include <sof/debug/telemetry/performance_monitor.h>
45+
4446
/* note: if this macro is not defined
4547
* then that means the HOST and the DSP
4648
* 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,
383385
/* update host position (in bytes offset) for drivers */
384386
dd->total_data_processed += bytes;
385387
}
388+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
389+
/* Increment performance counters */
390+
io_perf_monitor_update_data(dd->io_perf_bytes_count, bytes);
391+
#endif
386392

387393
return dma_status;
388394
}
@@ -478,6 +484,48 @@ int dai_common_new(struct dai_data *dd, struct comp_dev *dev,
478484
dd->xrun = 0;
479485
dd->chan = NULL;
480486

487+
/* I/O performance init, keep it last so the function does not reach this in case
488+
* of return on error, so that we do not waste a slot
489+
*/
490+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
491+
enum io_perf_data_item_id perf_type;
492+
enum io_perf_data_item_dir perf_dir;
493+
494+
switch (dai_cfg->type) {
495+
case SOF_DAI_INTEL_SSP:
496+
perf_type = IO_PERF_I2S_ID;
497+
break;
498+
case SOF_DAI_INTEL_ALH:
499+
perf_type = IO_PERF_SOUND_WIRE_ID;
500+
break;
501+
case SOF_DAI_INTEL_DMIC:
502+
perf_type = IO_PERF_DMIC_ID;
503+
break;
504+
case SOF_DAI_INTEL_HDA:
505+
perf_type = IO_PERF_HDA_ID;
506+
break;
507+
508+
default:
509+
perf_type = IO_PERF_INVALID_ID;
510+
comp_warn(dev, "Unsupported DAI type");
511+
}
512+
if (dai_cfg->direction == SOF_IPC_STREAM_PLAYBACK)
513+
perf_dir = IO_PERF_OUTPUT_DIRECTION;
514+
else
515+
perf_dir = IO_PERF_INPUT_DIRECTION;
516+
517+
/* ignore perf meas init on case of other dai types */
518+
if (perf_type != IO_PERF_INVALID_ID) {
519+
struct io_perf_data_item init_data = {perf_type,
520+
cpu_get_id(),
521+
perf_dir,
522+
IO_PERF_POWERED_UP_ENABLED,
523+
IO_PERF_D0IX_POWER_MODE,
524+
0, 0, 0 };
525+
io_perf_monitor_init_data(&dd->io_perf_bytes_count, &init_data);
526+
}
527+
#endif
528+
481529
return 0;
482530
}
483531

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

524572
void dai_common_free(struct dai_data *dd)
525573
{
574+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
575+
io_perf_monitor_release_slot(dd->io_perf_bytes_count);
576+
#endif
577+
526578
if (dd->group)
527579
dai_group_put(dd->group);
528580

src/include/sof/lib/dai-zephyr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include <zephyr/device.h>
3636
#include <zephyr/drivers/dai.h>
3737

38+
#include <sof/debug/telemetry/performance_monitor.h>
39+
3840
/** \addtogroup sof_dai_drivers DAI Drivers
3941
* DAI Drivers API specification.
4042
* @{
@@ -157,6 +159,10 @@ struct dai_data {
157159
struct llp_slot_info slot_info;
158160
/* fast mode, use one byte memory to save repreated cycles */
159161
bool fast_mode;
162+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
163+
/* io performance measurement */
164+
struct io_perf_data_item *io_perf_bytes_count;
165+
#endif
160166
};
161167

162168
/* these 3 are here to satisfy clk.c and ssp.h interconnection, will be removed leter */

0 commit comments

Comments
 (0)