Fix DMA host offset calculation and wrapper condition checking.

1. "size" should not be considered twice.
2. Change host_offset to uint32_t type.
3. size = min(hsize, lsize), so it is unncessary to check ">"
for wrap local and host buffer.

Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
This commit is contained in:
Yan Wang 2017-11-10 14:09:31 +08:00 committed by Liam Girdwood
parent eb2af44172
commit 9155f50c03
2 changed files with 3 additions and 3 deletions

View File

@ -56,7 +56,7 @@ struct dma_trace_data {
struct dma_sg_config config;
struct dma_trace_buf dmatb;
struct dma_copy dc;
int32_t host_offset;
uint32_t host_offset;
uint32_t host_size;
struct work dmat_work;
uint32_t enabled;

View File

@ -90,12 +90,12 @@ 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 + size >= d->host_size)
if (d->host_offset == d->host_size)
d->host_offset = 0;
/* update local pointer and check for wrap */
buffer->r_ptr += size;
if (buffer->r_ptr >= buffer->end_addr)
if (buffer->r_ptr == buffer->end_addr)
buffer->r_ptr = buffer->addr;
out: