From 16025f0bfc14b1cf69c80309ec780dd9d59492c2 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Wed, 13 Aug 2025 15:49:50 +0300 Subject: [PATCH] audio: chain_dma: fix link DMA reload logic for initial reload Current code waits until host DMA has more than half of the DMA buffer size worth of data available for transfer. The code however does not check whether link DMA has space for all available data yet and can cause the link DMA write pointer to wrap the read pointer. This will break the delay reporting and can lead to link xruns if the wrapped write pointer ends up too close to the link DMA read position (which is moved by DMA hardware in playback case). Tested-by: Peter Ujfalusi Signed-off-by: Kai Vehmanen --- src/audio/chain_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/chain_dma.c b/src/audio/chain_dma.c index f597dc1e4759..9485b4d626e0 100644 --- a/src/audio/chain_dma.c +++ b/src/audio/chain_dma.c @@ -243,7 +243,7 @@ static enum task_state chain_task_run(void *data) if (!cd->first_data_received && host_avail_bytes > half_buff_size) { ret = dma_reload(cd->chan_link->dma->z_dev, cd->chan_link->index, 0, 0, - half_buff_size); + MIN(host_avail_bytes, link_free_bytes)); if (ret < 0) { tr_err(&chain_dma_tr, "dma_reload() link error, ret = %d", ret);