Skip to content
Open
13 changes: 11 additions & 2 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,18 @@ void comp_init_performance_data(struct comp_dev *dev)
{
struct perf_data_item_comp *item = dev->perf_data.perf_data_item;

if (item)
if (item) {
perf_data_item_comp_init(item, dev->ipc_config.id, 0);
perf_data_update_module_resources(dev);
}
}

/* returns true if budget violation occurred */
static bool update_peak_of_measured_cpc(struct comp_dev *dev, size_t measured_cpc)
{
if (dev->cpc && measured_cpc > dev->cpc)
perf_data_inc_cpc_violation(dev);

if (measured_cpc <= dev->perf_data.peak_of_measured_cpc)
return false;
dev->perf_data.peak_of_measured_cpc = measured_cpc;
Expand All @@ -657,7 +662,8 @@ bool comp_update_performance_data(struct comp_dev *dev, uint32_t cycles_used)
{
struct perf_data_item_comp *item = dev->perf_data.perf_data_item;

if (perf_meas_get_state() == IPC4_PERF_MEASUREMENTS_STARTED) {
if (perf_meas_get_state() == IPC4_PERF_MEASUREMENTS_STARTED ||
IS_ENABLED(CONFIG_SOF_TELEMETRY_MODULE_RESOURCES)) {
/* we divide by ibs so we need to check if its set */
if (item && dev->ibs != 0) {
item->total_iteration_count++;
Expand Down Expand Up @@ -720,6 +726,9 @@ void comp_update_ibs_obs_cpc(struct comp_dev *dev)
dev->obs = dev_cfg.obs;
dev->ibs = dev_cfg.ibs;
dev->cpc = dev_cfg.cpc;
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
perf_data_update_module_resources(dev);
#endif
#else
/* set neutral values */
dev->ll_chunk_size = 0;
Expand Down
17 changes: 16 additions & 1 deletion src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <sof/audio/component_ext.h>
#include <sof/audio/format.h>
#include <sof/audio/pipeline.h>
#include <sof/debug/telemetry/telemetry.h>
#include <module/module/base.h>
#include <sof/common.h>
#include <rtos/panic.h>
Expand Down Expand Up @@ -357,6 +358,7 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
/* fill buffer with silence */
buffer_zero(dd->dma_buffer);

telemetry_update_dai_hot(dd, dev);
return dma_status;
}

Expand Down Expand Up @@ -502,6 +504,7 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
/* Increment performance counters */
io_perf_monitor_update_data(dd->io_perf_dai_byte_count, bytes);
#endif
telemetry_update_dai_hot(dd, dev);

return dma_status;
}
Expand Down Expand Up @@ -532,6 +535,7 @@ dai_dma_multi_endpoint_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t fr
/* fill buffer with silence */
buffer_zero(dd->dma_buffer);

telemetry_update_dai_hot(dd, dev);
return dma_status;
}

Expand Down Expand Up @@ -564,6 +568,7 @@ dai_dma_multi_endpoint_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t fr

/* update host position (in bytes offset) for drivers */
dd->total_data_processed += bytes;
telemetry_update_dai_hot(dd, dev);

return dma_status;
}
Expand Down Expand Up @@ -656,6 +661,7 @@ __cold int dai_common_new(struct dai_data *dd, struct comp_dev *dev,
io_perf_monitor_init_data(&dd->io_perf_dai_byte_count, &init_data);
}
#endif
telemetry_register_dai(dd, dev);

return 0;
}
Expand Down Expand Up @@ -790,6 +796,7 @@ __cold void dai_common_free(struct dai_data *dd)
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
io_perf_monitor_release_slot(dd->io_perf_dai_byte_count);
#endif
telemetry_unregister_dai(dd);

if (dd->group)
dai_group_put(dd->group);
Expand Down Expand Up @@ -1293,6 +1300,7 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
goto out;
}

telemetry_register_dai(dd, dev);
out:
/*
* Make sure to free all allocated items, all functions
Expand Down Expand Up @@ -1395,12 +1403,15 @@ int dai_common_prepare(struct dai_data *dd, struct comp_dev *dev)
if (dd->xrun) {
/* after prepare, we have recovered from xrun */
dd->xrun = 0;
telemetry_update_dai_hot(dd, dev);
return 0;
}

ret = dai_dma_config(dd);
if (ret < 0)
comp_set_state(dev, COMP_TRIGGER_RESET);
else
telemetry_update_dai_hot(dd, dev);

return ret;
}
Expand Down Expand Up @@ -1456,6 +1467,7 @@ void dai_common_reset(struct dai_data *dd, struct comp_dev *dev)
dd->wallclock = 0;
dd->total_data_processed = 0;
dd->xrun = 0;
telemetry_update_dai_hot(dd, NULL);
}

static int dai_reset(struct comp_dev *dev)
Expand Down Expand Up @@ -1559,6 +1571,7 @@ static int dai_comp_trigger_internal(struct dai_data *dd, struct comp_dev *dev,
case COMP_TRIGGER_XRUN:
comp_info(dev, "XRUN");
dd->xrun = 1;
telemetry_update_dai_hot(dd, dev);

COMPILER_FALLTHROUGH;
case COMP_TRIGGER_STOP:
Expand Down Expand Up @@ -1611,8 +1624,10 @@ static int dai_comp_trigger_internal(struct dai_data *dd, struct comp_dev *dev,
* See issue #8920 for details.
*/
if (!ret)
return comp_set_state(dev, cmd);
ret = comp_set_state(dev, cmd);
#endif /* CONFIG_IPC_MAJOR_3 */
if (!ret)
telemetry_update_dai_hot(dd, dev);

return ret;
}
Expand Down
11 changes: 11 additions & 0 deletions src/audio/host-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <sof/ut.h>
#include <sof/trace/trace.h>
#include <sof/debug/telemetry/performance_monitor.h>
#include <sof/debug/telemetry/telemetry.h>
#include <sof/schedule/ll_schedule_domain.h> /* zephyr_ll_user_heap() */
#include <ipc/stream.h>
#include <ipc/topology.h>
Expand Down Expand Up @@ -291,6 +292,7 @@ void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t byt
#endif

hd->total_data_processed += bytes;
telemetry_update_host_hot(hd, dev);

/* new local period, update host buffer position blks
* local_pos is queried by the ops.position() API
Expand Down Expand Up @@ -557,6 +559,8 @@ static uint32_t host_get_copy_bytes_normal(struct host_data *hd, struct comp_dev
avail_samples, free_samples);
}
hd->n_skipped++;
telemetry_notify_host_skip(hd);
telemetry_update_host_hot(hd, dev);
}
}

Expand Down Expand Up @@ -738,6 +742,9 @@ int host_common_trigger(struct host_data *hd, struct comp_dev *dev, int cmd)
break;
}

if (!ret)
telemetry_update_host_hot(hd, dev);

return ret;
}

Expand Down Expand Up @@ -866,6 +873,7 @@ __cold void host_common_free(struct host_data *hd)
hd->io_perf_host_byte_count = NULL;
}
#endif
telemetry_unregister_host(hd);

/* release DMA channel if not already done by reset */
if (hd->chan_index >= 0) {
Expand Down Expand Up @@ -1197,6 +1205,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
io_perf_monitor_init_data(&hd->io_perf_host_byte_count, &init_data);
}
#endif
telemetry_register_host(hd, dev);

return 0;

Expand Down Expand Up @@ -1232,6 +1241,7 @@ static int host_params(struct comp_dev *dev,
int host_common_prepare(struct host_data *hd)
{
buffer_zero(hd->dma_buffer);
telemetry_update_host_hot(hd, NULL);
return 0;
}

Expand Down Expand Up @@ -1299,6 +1309,7 @@ void host_common_reset(struct host_data *hd, uint16_t state)
hd->copy_type = COMP_COPY_NORMAL;
hd->source = NULL;
hd->sink = NULL;
telemetry_update_host_hot(hd, NULL);
}

#if CONFIG_IPC_MAJOR_3
Expand Down
6 changes: 6 additions & 0 deletions src/audio/module_adapter/module/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <sof/objpool.h>
#include <sof/audio/module_adapter/module/generic.h>
#include <sof/audio/data_blob.h>
#include <sof/debug/telemetry/performance_monitor.h>
#include <sof/lib/cold.h>
#include <sof/lib/fast-get.h>
#include <sof/lib/vregion.h>
Expand Down Expand Up @@ -231,6 +232,7 @@ void *z_impl_mod_balloc_align(struct processing_module *mod, size_t size, size_t
res->heap_high_water_mark = res->heap_usage;

k_mutex_unlock(&mod_res_lock);
perf_data_update_module_resources(mod->dev);
Comment thread
lgirdwood marked this conversation as resolved.
Resolved
return ptr;
}
EXPORT_SYMBOL(z_impl_mod_balloc_align);
Expand Down Expand Up @@ -284,6 +286,7 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t
res->heap_high_water_mark = res->heap_usage;

k_mutex_unlock(&mod_res_lock);
perf_data_update_module_resources(mod->dev);
return ptr;
}
EXPORT_SYMBOL(z_impl_mod_alloc_ext);
Expand Down Expand Up @@ -486,6 +489,8 @@ int z_impl_mod_free(struct processing_module *mod, const void *ptr)

if (ret < 0)
comp_err(mod->dev, "error: could not find memory pointed by %p", ptr);
else
perf_data_update_module_resources(mod->dev);

return ret;
}
Expand Down Expand Up @@ -791,6 +796,7 @@ __cold void z_impl_mod_free_all(struct processing_module *mod)

/* Make sure resource lists and accounting are reset */
mod_resource_init(mod);
perf_data_update_module_resources(mod->dev);
}

__cold int module_free(struct processing_module *mod)
Expand Down
9 changes: 8 additions & 1 deletion src/audio/pipeline/pipeline-schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <sof/audio/buffer.h>
#include <sof/audio/component_ext.h>
#include <sof/audio/pipeline.h>
#include <sof/debug/telemetry/telemetry.h>
#include <rtos/alloc.h>
#include <rtos/interrupt.h>
#include <sof/lib/agent.h>
Expand Down Expand Up @@ -107,6 +108,7 @@ static enum task_state pipeline_task_cmd(struct pipeline *p,
}

p->trigger.aborted = false;
telemetry_notify_pipeline_change();
return ret;
}

Expand Down Expand Up @@ -144,8 +146,10 @@ static enum task_state pipeline_task_cmd(struct pipeline *p,
}
} else if (p->trigger.cmd != cmd) {
/* PRE stage completed */
if (p->trigger.delay)
if (p->trigger.delay) {
telemetry_notify_pipeline_change();
return SOF_TASK_STATE_RESCHEDULE;
}
/* No delay: the final stage has already run too */
err = SOF_TASK_STATE_RESCHEDULE;
} else if (p->status == COMP_STATE_PAUSED) {
Expand All @@ -163,6 +167,7 @@ static enum task_state pipeline_task_cmd(struct pipeline *p,
}

p->trigger.cmd = COMP_TRIGGER_NO_ACTION;
telemetry_notify_pipeline_change();

ipc_msg_reply(reply);

Expand Down Expand Up @@ -240,6 +245,7 @@ static enum task_state ipc3_pipeline_task(void *arg)
err = pipeline_xrun_recover(p);
if (err < 0) {
pipe_err(p, "xrun recovery failed! pipeline is stopped.");
telemetry_notify_pipeline_change();
/* failed - host will stop this pipeline */
return SOF_TASK_STATE_COMPLETED;
}
Expand Down Expand Up @@ -332,6 +338,7 @@ static enum task_state ipc4_pipeline_copy_task(void *arg)
err = pipeline_xrun_recover(p);
if (err < 0) {
pipe_err(p, "xrun recovery failed! pipeline is stopped.");
telemetry_notify_pipeline_change();
/* failed - host will stop this pipeline */
return SOF_TASK_STATE_COMPLETED;
}
Expand Down
7 changes: 6 additions & 1 deletion src/audio/pipeline/pipeline-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <sof/audio/buffer.h>
#include <sof/audio/component_ext.h>
#include <sof/audio/pipeline.h>
#include <sof/debug/telemetry/telemetry.h>
#include <sof/lib/dai.h>
#include <rtos/timer.h>
#include <sof/list.h>
Expand Down Expand Up @@ -401,7 +402,10 @@ int pipeline_trigger(struct pipeline *p, struct comp_dev *host, int cmd)
if (p->status == COMP_STATE_PAUSED || p->xrun_bytes) {
/* The task isn't running, trigger inline */
ret = pipeline_trigger_run(p, host, cmd);
return ret < 0 ? ret : 0;
if (ret < 0)
return ret;
telemetry_notify_pipeline_change();
return 0;
}

COMPILER_FALLTHROUGH;
Expand Down Expand Up @@ -435,6 +439,7 @@ int pipeline_trigger(struct pipeline *p, struct comp_dev *host, int cmd)
return PPL_STATUS_SCHEDULED;
}

telemetry_notify_pipeline_change();
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions src/audio/pipeline/pipeline-xrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <sof/audio/buffer.h>
#include <sof/audio/pipeline.h>
#include <sof/debug/telemetry/performance_monitor.h>
#include <sof/debug/telemetry/telemetry.h>
#include <sof/ipc/msg.h>
#include <sof/list.h>
#include <sof/lib/mailbox.h>
Expand Down Expand Up @@ -163,6 +165,9 @@ void pipeline_xrun(struct pipeline *p, struct comp_dev *dev,
if (dev->state != COMP_STATE_ACTIVE)
return;

telemetry_notify_pipeline_xrun(p, bytes);
perf_data_inc_xrun(dev);

/* notify all pipeline comps we are in XRUN, and stop copying */
ret = pipeline_trigger(p, p->source_comp, COMP_TRIGGER_XRUN);
if (ret < 0)
Expand Down
Loading
Loading