mirror of https://github.com/thesofproject/sof.git
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:
parent
ed1c9164f9
commit
03057d17cd
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue