Commit 65e02d0b authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Jonathan Cameron

iio: buffer-dmaengine: adjust `bytes_used` with residue info

A transfer may fall shorter than the bytes in the block.
This information is available in the residue from the DMA engine, so we can
compute actual `bytes_used` with that by subtracting the residue.
Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20200826052011.13348-1-lars@metafoo.deSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent e7b61fc4
...@@ -45,7 +45,8 @@ static struct dmaengine_buffer *iio_buffer_to_dmaengine_buffer( ...@@ -45,7 +45,8 @@ static struct dmaengine_buffer *iio_buffer_to_dmaengine_buffer(
return container_of(buffer, struct dmaengine_buffer, queue.buffer); return container_of(buffer, struct dmaengine_buffer, queue.buffer);
} }
static void iio_dmaengine_buffer_block_done(void *data) static void iio_dmaengine_buffer_block_done(void *data,
const struct dmaengine_result *result)
{ {
struct iio_dma_buffer_block *block = data; struct iio_dma_buffer_block *block = data;
unsigned long flags; unsigned long flags;
...@@ -53,6 +54,7 @@ static void iio_dmaengine_buffer_block_done(void *data) ...@@ -53,6 +54,7 @@ static void iio_dmaengine_buffer_block_done(void *data)
spin_lock_irqsave(&block->queue->list_lock, flags); spin_lock_irqsave(&block->queue->list_lock, flags);
list_del(&block->head); list_del(&block->head);
spin_unlock_irqrestore(&block->queue->list_lock, flags); spin_unlock_irqrestore(&block->queue->list_lock, flags);
block->bytes_used -= result->residue;
iio_dma_buffer_block_done(block); iio_dma_buffer_block_done(block);
} }
...@@ -74,7 +76,7 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, ...@@ -74,7 +76,7 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue,
if (!desc) if (!desc)
return -ENOMEM; return -ENOMEM;
desc->callback = iio_dmaengine_buffer_block_done; desc->callback_result = iio_dmaengine_buffer_block_done;
desc->callback_param = block; desc->callback_param = block;
cookie = dmaengine_submit(desc); cookie = dmaengine_submit(desc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment