Skip to content

Commit de318aa

Browse files
committed
telemetry: add IO counter for a HDA Host interface
Currently SOF can collect IO performance data only for HAD Link interface. The corresponding counter on Host side is missing. This commit adds the missing counter with DMA index used as the counter instance Signed-off-by: Wojciech Jablonski <wojciech.jablonski@intel.com>
1 parent c1ed9ec commit de318aa

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

src/audio/copier/host_copier.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <sof/lib/notifier.h>
2323
#include "copier.h"
2424

25+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
26+
struct io_perf_data_item;
27+
#endif
28+
2529
typedef void (*copy_callback_t)(struct comp_dev *dev, size_t bytes);
2630

2731
struct host_data;
@@ -112,6 +116,9 @@ struct host_data {
112116
uint64_t next_sync;
113117
uint64_t period_in_cycles;
114118
#endif
119+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
120+
struct io_perf_data_item *io_perf_host_byte_count;
121+
#endif
115122
};
116123

117124
int host_common_new(struct host_data *hd, struct comp_dev *dev,

src/audio/host-legacy.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <rtos/string.h>
2626
#include <sof/ut.h>
2727
#include <sof/trace/trace.h>
28+
#include <sof/debug/telemetry/performance_monitor.h>
2829
#include <ipc/stream.h>
2930
#include <ipc/topology.h>
3031
#include <user/trace.h>
@@ -250,6 +251,10 @@ void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t byt
250251
if (ret < 0)
251252
return;
252253

254+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
255+
io_perf_monitor_update_data(hd->io_perf_host_byte_count, bytes);
256+
#endif
257+
253258
hd->total_data_processed += bytes;
254259

255260
/* new local period, update host buffer position blks
@@ -599,6 +604,14 @@ static struct comp_dev *host_new(const struct comp_driver *drv,
599604

600605
void host_common_free(struct host_data *hd)
601606
{
607+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
608+
/* Check for NULL just in case the params() step is omitted */
609+
if (hd->io_perf_host_byte_count) {
610+
io_perf_monitor_release_slot(hd->io_perf_host_byte_count);
611+
hd->io_perf_host_byte_count = NULL;
612+
}
613+
#endif
614+
602615
dma_put(hd->dma);
603616

604617
ipc_msg_free(hd->msg);
@@ -829,6 +842,25 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
829842
pcm_get_conversion_function(audio_stream_get_frm_fmt(&hd->local_buffer->stream),
830843
audio_stream_get_frm_fmt(&hd->local_buffer->stream));
831844

845+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
846+
if (!hd->io_perf_host_byte_count) {
847+
/* On the Host side, unlike the DAI side, an IO port direction enum values match
848+
* stream direction enum values (CAPTURE/PLAYBACK), so we can directly use
849+
* params->direction here.
850+
*/
851+
struct io_perf_data_item init_data = {
852+
IO_PERF_HDA_ID,
853+
hd->chan->index,
854+
params->direction,
855+
IO_PERF_POWERED_UP_ENABLED,
856+
IO_PERF_D0IX_POWER_MODE,
857+
0, 0, 0
858+
};
859+
860+
io_perf_monitor_init_data(&hd->io_perf_host_byte_count, &init_data);
861+
}
862+
#endif
863+
832864
out:
833865

834866
hd->cb_dev = dev;

src/audio/host-zephyr.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <rtos/string.h>
2525
#include <sof/ut.h>
2626
#include <sof/trace/trace.h>
27+
#include <sof/debug/telemetry/performance_monitor.h>
2728
#include <ipc/stream.h>
2829
#include <ipc/topology.h>
2930
#include <user/trace.h>
@@ -262,6 +263,10 @@ void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t byt
262263
return;
263264
}
264265

266+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
267+
io_perf_monitor_update_data(hd->io_perf_host_byte_count, bytes);
268+
#endif
269+
265270
hd->total_data_processed += bytes;
266271

267272
/* new local period, update host buffer position blks
@@ -771,6 +776,14 @@ __cold void host_common_free(struct host_data *hd)
771776
{
772777
assert_can_be_cold();
773778

779+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
780+
/* Check for NULL just in case the params() step is omitted */
781+
if (hd->io_perf_host_byte_count) {
782+
io_perf_monitor_release_slot(hd->io_perf_host_byte_count);
783+
hd->io_perf_host_byte_count = NULL;
784+
}
785+
#endif
786+
774787
sof_dma_put(hd->dma);
775788

776789
ipc_msg_free(hd->msg);
@@ -1074,6 +1087,25 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
10741087
hd->copy = hd->copy_type == COMP_COPY_ONE_SHOT ? host_copy_one_shot :
10751088
host_copy_normal;
10761089

1090+
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
1091+
if (!hd->io_perf_host_byte_count) {
1092+
/* On the Host side, unlike the DAI side, an IO port direction enum values match
1093+
* stream direction enum values (CAPTURE/PLAYBACK), so we can directly use
1094+
* params->direction here.
1095+
*/
1096+
struct io_perf_data_item init_data = {
1097+
IO_PERF_HDA_ID,
1098+
hd->chan->index,
1099+
params->direction,
1100+
IO_PERF_POWERED_UP_ENABLED,
1101+
IO_PERF_D0IX_POWER_MODE,
1102+
0, 0, 0
1103+
};
1104+
1105+
io_perf_monitor_init_data(&hd->io_perf_host_byte_count, &init_data);
1106+
}
1107+
#endif
1108+
10771109
return 0;
10781110

10791111
err_free_block_cfg:

0 commit comments

Comments
 (0)