diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index a3c036ad1982..2fc556606481 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -442,7 +442,6 @@ static inline bool stream_sync(struct host_data *hd, struct comp_dev *dev) */ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_callback_t cb) { - struct comp_buffer __sparse_cache *buffer_c; uint32_t copy_bytes; const unsigned int threshold = #if CONFIG_HOST_DMA_RELOAD_DELAY_ENABLE @@ -460,7 +459,6 @@ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_cal cb(dev, copy_bytes); hd->partial_size += copy_bytes; - buffer_c = buffer_acquire(hd->dma_buffer); /* * On large buffers we don't need to reload DMA on every period. When @@ -469,8 +467,8 @@ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_cal * also adding a 2ms safety margin. */ if (!IS_ENABLED(CONFIG_HOST_DMA_RELOAD_DELAY_ENABLE) || - audio_stream_get_size(&buffer_c->stream) < hd->period_bytes << 3 || - audio_stream_get_size(&buffer_c->stream) - hd->partial_size <= + hd->dma_buffer_size < hd->period_bytes << 3 || + hd->dma_buffer_size - hd->partial_size <= (2 + threshold) * hd->period_bytes) { if (stream_sync(hd, dev)) { ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0, @@ -481,9 +479,6 @@ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_cal hd->partial_size = 0; } } - - buffer_release(buffer_c); - return ret; } @@ -858,6 +853,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev, config->src_width = audio_stream_sample_bytes(&dma_buf_c->stream); config->dest_width = config->src_width; + hd->dma_buffer_size = audio_stream_get_size(&dma_buf_c->stream); buffer_release(dma_buf_c); } diff --git a/src/include/sof/audio/host_copier.h b/src/include/sof/audio/host_copier.h index 60f0dccfdb90..c7ac454bf800 100644 --- a/src/include/sof/audio/host_copier.h +++ b/src/include/sof/audio/host_copier.h @@ -96,6 +96,7 @@ struct host_data { /* stream info */ struct sof_ipc_stream_posn posn; /* TODO: update this */ struct ipc_msg *msg; /**< host notification */ + uint32_t dma_buffer_size; /* dma buffer size */ #if CONFIG_HOST_DMA_STREAM_SYNCHRONIZATION bool is_grouped; uint8_t group_id;