[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210212102021.47276-6-alexandru.ardelean@analog.com>
Date: Fri, 12 Feb 2021 12:20:21 +0200
From: Alexandru Ardelean <alexandru.ardelean@...log.com>
To: <linux-kernel@...r.kernel.org>, <linux-iio@...r.kernel.org>
CC: <lars@...afoo.de>, <Michael.Hennerich@...log.com>,
<jic23@...nel.org>, <nuno.sa@...log.com>,
<dragos.bogdan@...log.com>,
Alexandru Ardelean <alexandru.ardelean@...log.com>
Subject: [RFC PATCH 5/5] iio: buffer-dma: add support for cyclic DMA transfers
From: Lars-Peter Clausen <lars@...afoo.de>
This change adds support for cyclic DMA transfers using the IIO buffer DMA
infrastructure.
To do this, userspace must set the IIO_BUFFER_BLOCK_FLAG_CYCLIC flag on the
block when enqueueing them via the ENQUEUE_BLOCK ioctl().
Signed-off-by: Lars-Peter Clausen <lars@...afoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
---
.../buffer/industrialio-buffer-dmaengine.c | 24 ++++++++++++-------
include/uapi/linux/iio/buffer.h | 1 +
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
index 013cc7c1ecf4..94c93a636ad4 100644
--- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
+++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
@@ -82,14 +82,22 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue,
direction = dmaengine_buffer->is_tx ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
- desc = dmaengine_prep_slave_single(dmaengine_buffer->chan,
- block->phys_addr, block->block.bytes_used, direction,
- DMA_PREP_INTERRUPT);
- if (!desc)
- return -ENOMEM;
-
- desc->callback_result = iio_dmaengine_buffer_block_done;
- desc->callback_param = block;
+ if (block->block.flags & IIO_BUFFER_BLOCK_FLAG_CYCLIC) {
+ desc = dmaengine_prep_dma_cyclic(dmaengine_buffer->chan,
+ block->phys_addr, block->block.bytes_used,
+ block->block.bytes_used, direction, 0);
+ if (!desc)
+ return -ENOMEM;
+ } else {
+ desc = dmaengine_prep_slave_single(dmaengine_buffer->chan,
+ block->phys_addr, block->block.bytes_used, direction,
+ DMA_PREP_INTERRUPT);
+ if (!desc)
+ return -ENOMEM;
+
+ desc->callback_result = iio_dmaengine_buffer_block_done;
+ desc->callback_param = block;
+ }
cookie = dmaengine_submit(desc);
if (dma_submit_error(cookie))
diff --git a/include/uapi/linux/iio/buffer.h b/include/uapi/linux/iio/buffer.h
index 70ad3aea01ea..0e0c95f1c38b 100644
--- a/include/uapi/linux/iio/buffer.h
+++ b/include/uapi/linux/iio/buffer.h
@@ -13,6 +13,7 @@ struct iio_buffer_block_alloc_req {
};
#define IIO_BUFFER_BLOCK_FLAG_TIMESTAMP_VALID (1 << 0)
+#define IIO_BUFFER_BLOCK_FLAG_CYCLIC (1 << 1)
struct iio_buffer_block {
__u32 id;
--
2.17.1
Powered by blists - more mailing lists