dma-trace: Align DMA buffer correctly to fix dma tracing issues

Force DMA buffer to be correctly aligned. If the buffer is only
64-byte aligned, when using hda-dma, then the last 64-bytes of the DMA
buffer is not transferred correctly to host side.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
This commit is contained in:
Jyri Sarha 2022-02-08 10:11:19 +02:00 committed by Liam Girdwood
parent 9983ab67a9
commit c11562b00a
1 changed files with 16 additions and 3 deletions

View File

@ -223,10 +223,23 @@ static int dma_trace_buffer_init(struct dma_trace_data *d)
struct dma_trace_buf *buffer = &d->dmatb;
void *buf;
k_spinlock_key_t key;
uint32_t addr_align;
int err;
/* allocate new buffer */
buf = rballoc(0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA,
DMA_TRACE_LOCAL_SIZE);
if (!d || !d->dc.dmac) {
mtrace_printf(LOG_LEVEL_ERROR,
"%s failed: no DMAC!", __func__);
return -ENODEV;
}
err = dma_get_attribute(d->dc.dmac, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT,
&addr_align);
if (err < 0)
return err;
/* For DMA to work properly the buffer must be correctly aligned */
buf = rballoc_align(0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA,
DMA_TRACE_LOCAL_SIZE, addr_align);
if (!buf) {
tr_err(&dt_tr, "dma_trace_buffer_init(): alloc failed");
return -ENOMEM;