Skip to contentSkip to conversation

kfifo: add DMA capabilities

PATCH In review Stefani Seibold 2 participants 2 messages Dec 11, 2009 Kfifo

lore
Share & tools
lore

Stefani Seibold

author maintainer
#0 lore raw

PATCH 1/1 kfifo: add DMA capabilities

As requested by Shargorodsky Atal:

This patch adds functions for DMA handling to the new kfifo API.

To prepare a DMA one of the kfifo_dma_..._prepare() Funktions must be called. This results in a scatterlist structure which can passed to the kernel DMA functions.

After the DMA transfer was finished, the corresponding kfifo_dma_..._finsh() function must be called to remove the transfered data from the fifo.

These are the function which added new to the kfifo API:

kfifo_dma_in_prepare()
kfifo_dma_in_finish()
Prepare and finish an incoming DMA.

kfifo_dma_in_prepare_rec
kfifo_dma_in_finish_rec
Ditto for record fifo's

kfifo_dma_out_prepare
kfifo_dma_out_finish
Prepare and finish for an outcoming DMA.

kfifo_dma_out_prepare_rec
kfifo_dma_out_finish_rec
Ditto for record fifo's

The patch-set is against current mm tree from 11-Dec-2009

Greetings,
Stefani

---
 include/linux/kfifo.h |   21 ++++
 kernel/kfifo.c        |  251 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 272 insertions(+)
include/linux/kfifo.h +21 -0
diff -u -N -r -p kfifo8/include/linux/kfifo.h kfifo9/include/linux/kfifo.h
@@ -43,6 +43,7 @@
 
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
+#include <linux/scatterlist.h>
 
 struct kfifo {
 	unsigned char *buffer;	/* the buffer holding the data */
@@ -608,4 +609,24 @@ static inline __must_check unsigned int 
 	return (l > recsize) ? l - recsize : 0;
 }
 
+extern unsigned int kfifo_dma_in_prepare(struct kfifo *fifo,
+	struct scatterlist *sgl, int nents);
+extern void kfifo_dma_in_finish(struct kfifo *fifo, unsigned int len);
+
+extern __must_check unsigned int kfifo_dma_out_prepare(struct kfifo *fifo,
+	struct scatterlist *sgl, int nents, unsigned int len);
+extern void kfifo_dma_out_finish(struct kfifo *fifo, unsigned int len);
+
+extern unsigned int kfifo_dma_in_prepare_rec(struct kfifo *fifo,
+	struct scatterlist *sgl, int nents, unsigned int recsize);
+extern void kfifo_dma_in_finish_rec(struct kfifo *fifo, unsigned int len,
+	unsigned int recsize);
+
+extern __must_check  unsigned int kfifo_dma_out_prepare_rec(struct kfifo *fifo,
+	struct scatterlist *sgl, int nents, unsigned int len,
+	unsigned int recsize);
+extern void kfifo_dma_out_finish_rec(struct kfifo *fifo, unsigned int len,
+	unsigned int recsize);
+
 #endif
+
kernel/kfifo.c +251 -0

254 lines not on this page · raw message

#1 lore raw
Quoted 7 lines · On Fri, 11 Dec 2009 14:36:29 +0100 Stefani Seibold <[email protected]> wrote:

As requested by Shargorodsky Atal:

This patch adds functions for DMA handling to the new kfifo API.

To prepare a DMA one of the kfifo_dma_..._prepare() Funktions must be called. This results in a scatterlist structure which can passed to the kernel DMA functions.

Looks good to me - the tty buffering has similar functions to some bits of this for the same reasons.

Alan