Skip to content

Commit c11562b

Browse files
jsarhalgirdwood
authored andcommitted
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>
1 parent 9983ab6 commit c11562b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/trace/dma-trace.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,23 @@ static int dma_trace_buffer_init(struct dma_trace_data *d)
223223
struct dma_trace_buf *buffer = &d->dmatb;
224224
void *buf;
225225
k_spinlock_key_t key;
226+
uint32_t addr_align;
227+
int err;
228+
229+
if (!d || !d->dc.dmac) {
230+
mtrace_printf(LOG_LEVEL_ERROR,
231+
"%s failed: no DMAC!", __func__);
232+
return -ENODEV;
233+
}
234+
235+
err = dma_get_attribute(d->dc.dmac, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT,
236+
&addr_align);
237+
if (err < 0)
238+
return err;
226239

227-
/* allocate new buffer */
228-
buf = rballoc(0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA,
229-
DMA_TRACE_LOCAL_SIZE);
240+
/* For DMA to work properly the buffer must be correctly aligned */
241+
buf = rballoc_align(0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA,
242+
DMA_TRACE_LOCAL_SIZE, addr_align);
230243
if (!buf) {
231244
tr_err(&dt_tr, "dma_trace_buffer_init(): alloc failed");
232245
return -ENOMEM;

0 commit comments

Comments
 (0)