From a43e2a5c59c510df1c0e7e55d3f8fb9d3baab790 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 2 Jun 2023 11:33:17 -0500 Subject: [PATCH 1/3] dai-zephyr: return earlier when there is nothing to copy We can skip two code blocks that are completely useless when the number of samples is exactly zero, and return earlier. Signed-off-by: Pierre-Louis Bossart --- src/audio/dai-zephyr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 0b415bf28d86..6c91cbcbfd5f 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -1597,6 +1597,13 @@ int dai_zephyr_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun samples = MIN(samples, src_samples); } + /* return if nothing to copy */ + if (!samples) { + comp_warn(dev, "dai_zephyr_copy(): nothing to copy"); + dma_reload(dd->chan->dma->z_dev, dd->chan->index, 0, 0, 0); + return 0; + } + /* limit bytes per copy to one period for the whole pipeline * in order to avoid high load spike * if FAST_MODE is enabled, then one period limitation is omitted @@ -1619,13 +1626,6 @@ int dai_zephyr_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun comp_warn(dev, "dai_zephyr_copy(): Copy_bytes %d + free bytes %d < period bytes %d, possible glitch", copy_bytes, free_bytes, dd->period_bytes); - /* return if nothing to copy */ - if (!copy_bytes) { - comp_warn(dev, "dai_zephyr_copy(): nothing to copy"); - dma_reload(dd->chan->dma->z_dev, dd->chan->index, 0, 0, 0); - return 0; - } - /* trigger optional DAI_TRIGGER_COPY which prepares dai to copy */ ret = dai_trigger(dd->dai->dev, dev->direction, DAI_TRIGGER_COPY); if (ret < 0) From 052ac789abbc7573095313d5c2204bb100184f9c Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 2 Jun 2023 11:48:05 -0500 Subject: [PATCH 2/3] dai-zephyr: add information on bytes transferred in log A 'nothing to copy' log is not really useful without additional information on when this problem occurred, i.e. if this is on a 1ms tick or after a longer time. Signed-off-by: Pierre-Louis Bossart --- src/audio/dai-zephyr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 6c91cbcbfd5f..14f6038354f8 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -1599,7 +1599,7 @@ int dai_zephyr_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun /* return if nothing to copy */ if (!samples) { - comp_warn(dev, "dai_zephyr_copy(): nothing to copy"); + comp_warn(dev, "dai_zephyr_copy(): nothing to copy, dd->total_data_processed %llu", dd->total_data_processed); dma_reload(dd->chan->dma->z_dev, dd->chan->index, 0, 0, 0); return 0; } From 7be82697d68d83fefba189ac62e061a8c290e526 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 2 Jun 2023 12:10:07 -0500 Subject: [PATCH 3/3] host-zephyr: add total_data_processed to the log This is helpful to see when 'dma_copy_bytes' is zero, e.g. [00:01:10.446,761] host_comp: host_get_copy_bytes_normal: comp:1 0x40002 no bytes to copy, hd->total_data_processed 49664 available samples: 192, free_samples: 0 Signed-off-by: Pierre-Louis Bossart --- src/audio/host-zephyr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index a31ccf84f7af..c61cf2725458 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -422,8 +422,8 @@ static uint32_t host_get_copy_bytes_normal(struct host_data *hd, struct comp_dev dma_copy_bytes = MIN(hd->period_bytes, dma_copy_bytes); if (!dma_copy_bytes) - comp_info(dev, "no bytes to copy, available samples: %d, free_samples: %d", - avail_samples, free_samples); + comp_info(dev, "no bytes to copy, hd->total_data_processed %llu available samples: %d, free_samples: %d", + hd->total_data_processed, avail_samples, free_samples); buffer_release(buffer_c);