[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211115142243.60605-3-paul@crapouillou.net>
Date: Mon, 15 Nov 2021 14:22:42 +0000
From: Paul Cercueil <paul@...pouillou.net>
To: Jonathan Cameron <jic23@...nel.org>
Cc: Alexandru Ardelean <ardeleanalex@...il.com>,
Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Sumit Semwal <sumit.semwal@...aro.org>,
Christian König <christian.koenig@....com>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linaro-mm-sig@...ts.linaro.org,
Paul Cercueil <paul@...pouillou.net>
Subject: [PATCH 14/15] iio: buffer-dmaengine: Add support for cyclic buffers
Handle the IIO_BUFFER_DMABUF_CYCLIC flag to support cyclic buffers.
Signed-off-by: Paul Cercueil <paul@...pouillou.net>
---
drivers/iio/buffer/industrialio-buffer-dma.c | 1 +
.../iio/buffer/industrialio-buffer-dmaengine.c | 15 ++++++++++++---
include/linux/iio/buffer-dma.h | 3 +++
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c
index fb39054d8c15..6658f103ee17 100644
--- a/drivers/iio/buffer/industrialio-buffer-dma.c
+++ b/drivers/iio/buffer/industrialio-buffer-dma.c
@@ -933,6 +933,7 @@ int iio_dma_buffer_enqueue_dmabuf(struct iio_buffer *buffer,
}
dma_block->bytes_used = iio_dmabuf->bytes_used ?: dma_block->size;
+ dma_block->cyclic = iio_dmabuf->flags & IIO_BUFFER_DMABUF_CYCLIC;
switch (dma_block->state) {
case IIO_BLOCK_STATE_QUEUED:
diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
index 57a8b2e4ba3c..952e2160a11e 100644
--- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
+++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
@@ -81,9 +81,18 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue,
if (!block->bytes_used || block->bytes_used > max_size)
return -EINVAL;
- desc = dmaengine_prep_slave_single(dmaengine_buffer->chan,
- block->phys_addr, block->bytes_used, dma_dir,
- DMA_PREP_INTERRUPT);
+ if (block->cyclic) {
+ desc = dmaengine_prep_dma_cyclic(dmaengine_buffer->chan,
+ block->phys_addr,
+ block->size,
+ block->bytes_used,
+ dma_dir, 0);
+ } else {
+ desc = dmaengine_prep_slave_single(dmaengine_buffer->chan,
+ block->phys_addr,
+ block->bytes_used, dma_dir,
+ DMA_PREP_INTERRUPT);
+ }
if (!desc)
return -ENOMEM;
diff --git a/include/linux/iio/buffer-dma.h b/include/linux/iio/buffer-dma.h
index 85e55fe35282..27639fdf7b54 100644
--- a/include/linux/iio/buffer-dma.h
+++ b/include/linux/iio/buffer-dma.h
@@ -42,6 +42,7 @@ enum iio_block_state {
* @phys_addr: Physical address of the blocks memory
* @queue: Parent DMA buffer queue
* @state: Current state of the block
+ * @cyclic: True if this is a cyclic buffer
* @fileio: True if this buffer is used for fileio mode
* @dmabuf: Underlying DMABUF object
*/
@@ -65,6 +66,8 @@ struct iio_dma_buffer_block {
*/
enum iio_block_state state;
+ bool cyclic;
+
bool fileio;
struct dma_buf *dmabuf;
};
--
2.33.0
Powered by blists - more mailing lists