From: Yan Wang yan.wang@linux.intel.com
When DMA host buffer is wrapped, host DMA copy need more time to finish copying. So previous implementation will output old trace when DMA host buffer is wrapped because positions update is sent before DMA copying finished. Now trace_work() will always update previous position and avoid this.
Signed-off-by: Yan Wang yan.wang@linux.intel.com --- Test with: Mininow max rt5651 and APL UP^2 nocodec and CNL nocodec SOF 1.1-stable: 1c417f9f3d0a01f2a5c997636c2c89227a949db0 SOF-Tool 1.1-stable: 739acd1e5e542b09f7b204f44350d676dacf0000 https://github.com/plbossart/sound/tree/topic/sof-v4.14: c33cfed51fff5eb156dcf70ba849e6ffb3008377 --- src/lib/dma-trace.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/lib/dma-trace.c b/src/lib/dma-trace.c index 5046a09..21d1a39 100644 --- a/src/lib/dma-trace.c +++ b/src/lib/dma-trace.c @@ -53,6 +53,20 @@ static uint64_t trace_work(void *data, uint64_t delay) uint32_t hsize; uint32_t lsize;
+ if (d->host_offset == d->host_size) + d->host_offset = 0; + +#if defined CONFIG_DMA_GW + /* + * there isn't DMA completion callback in GW DMA copying. + * so we send previous position always before the next copying + * for guaranteeing previous DMA copying is finished. + * This function will be called once every 500ms at least even + * if no new trace is filled. + */ + ipc_dma_trace_send_position(); +#endif + /* any data to copy ? */ if (avail == 0) return DMA_TRACE_PERIOD; @@ -98,8 +112,6 @@ static uint64_t trace_work(void *data, uint64_t delay)
/* update host pointer and check for wrap */ d->host_offset += size; - if (d->host_offset == d->host_size) - d->host_offset = 0;
/* update local pointer and check for wrap */ buffer->r_ptr += size; @@ -121,14 +133,6 @@ out:
spin_unlock_irq(&d->lock, flags);
-#if defined CONFIG_DMA_GW - /* - * there isn't DMA completion callback in GW DMA copying - * so we send position IPC message after DMA copying API calling - */ - ipc_dma_trace_send_position(); -#endif - /* reschedule the trace copying work */ return DMA_TRACE_PERIOD; }