host: add copy_bytes alignment in host_buffer_cb()

Amount of bytes we copied by host component should be
align to minimal possible chunk of data that can be
copied by hda-dma. In other case there is possibility of
occurrence mismatch between amount data we really copied
and buffer read and write pointers.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This commit is contained in:
Bartosz Kokoszko 2019-06-25 10:32:57 +02:00 committed by Tomasz Lauda
parent ed1c9164f9
commit 03057d17cd
1 changed files with 18 additions and 0 deletions

View File

@ -73,6 +73,10 @@ struct host_data {
struct hc_buf *sink;
uint32_t split_remaining;
uint32_t dma_copy_align; /**< Minmal chunk of data possible to be
* copied by dma connected to host
*/
/* stream info */
struct sof_ipc_stream_posn posn; /* TODO: update this */
};
@ -447,6 +451,11 @@ static void host_buffer_cb(void *data, uint32_t bytes)
MIN(avail_bytes, hd->dma_buffer->free) :
MIN(hd->dma_buffer->avail, free_bytes);
/* copy_bytes should be aligned to minimum possible chunk of data to be
* copied by dma.
*/
copy_bytes = ALIGN_DOWN(copy_bytes, hd->dma_copy_align);
tracev_host("host_buffer_cb(), copy_bytes = 0x%x", copy_bytes);
if (hd->copy_blocking)
@ -578,6 +587,15 @@ static int host_params(struct comp_dev *dev)
return err;
}
err = dma_get_attribute(hd->dma, DMA_ATTR_COPY_ALIGNMENT,
&hd->dma_copy_align);
if (err < 0) {
trace_host_error("host_params() error: dma_get_attribute()");
return err;
}
/* set up callback */
dma_set_cb(hd->dma, hd->chan, DMA_CB_TYPE_IRQ |
DMA_CB_TYPE_COPY, host_dma_cb, dev);