fsldma: Add DMA_SLAVE support
Subsystems (3)
PATCH v3 2/2 fsldma: Add DMA_SLAVE support
Use the DMA_SLAVE capability of the DMAEngine API to copy/from a scatterlist into an arbitrary list of hardware address/length pairs.
This allows a single DMA transaction to copy data from several different devices into a scatterlist at the same time.
This also adds support to enable some controller-specific features such as external start and external pause for a DMA transaction.
---
This patch depends on the "fsldma: split apart external pause and request count features" patch.
After discussion with Dan Williams, this is the third version of the DMA_SLAVE API for the Freescale DMA controller. I've tested it heavily with both drivers I have written against this API, an FPGA programmer and an FPGA data grabber.
Kumar, Dan asked me to add you to the CC list, so you can have a look at this patch before he adds it to his tree.
The other two small patches I posted earlier are very helpful in testing this functionality. They make the fsldma driver leave the BWC (bandwidth control) bits alone on the 83xx controller, as well as making the external start feature available on 83xx.
v2 -> v3:
* add support for setting DMA request count
v1 -> v2:
* move fsldma.h from include/linux to arch/powerpc/include/asm
* add kerneldoc documentation
arch/powerpc/include/asm/fsldma.h | 136 ++++++++++++++++++++++ drivers/dma/fsldma.c | 227 +++++++++++++++++++++++++++++++++++++ 2 files changed, 363 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/include/asm/fsldma.h
arch/powerpc/include/asm/fsldma.h new file +136 -0
@@ -0,0 +1,136 @@ +/* +* Freescale MPC83XX / MPC85XX DMA Controller +* +* Copyright (c) 2009 Ira W. Snyder <[email protected]> +* +* This file is licensed under the terms of the GNU General Public License +* version 2. This program is licensed "as is" without any warranty of any +* kind, whether express or implied. +*/ + +#ifndef __ARCH_POWERPC_ASM_FSLDMA_H__ +#define __ARCH_POWERPC_ASM_FSLDMA_H__ + +#include <linux/dmaengine.h> + +/* +* Definitions for the Freescale DMA controller's DMA_SLAVE implemention +* +* The Freescale DMA_SLAVE implementation was designed to handle many-to-many +* transfers. An example usage would be an accelerated copy between two +* scatterlists. Another example use would be an accelerated copy from +* multiple non-contiguous device buffers into a single scatterlist. +* +* A DMA_SLAVE transaction is defined by a struct fsl_dma_slave. This +* structure contains a list of hardware addresses that should be copied +* to/from the scatterlist passed into device_prep_slave_sg(). The structure +* also has some fields to enable hardware-specific features. +*/ + +/** +* struct fsl_dma_hw_addr +* @entry: linked list entry +* @address: the hardware address +* @length: length to transfer +* +* Holds a single physical hardware address / length pair for use +* with the DMAEngine DMA_SLAVE API. +*/ +struct fsl_dma_hw_addr { +struct list_head entry; + +dma_addr_t address; +size_t length; +}; + +/** +* struct fsl_dma_slave +* @addresses: a linked list of struct fsl_dma_hw_addr structures +* @request_count: value for DMA request count +* @src_loop_size: setup and enable constant source-address DMA transfers +* @dst_loop_size: setup and enable constant destination address DMA transfers +* @external_start: enable externally started DMA transfers +* @external_pause: enable externally paused DMA transfers +* +* Holds a list of address / length pairs for use with the DMAEngine +* DMA_SLAVE API implementation for the Freescale DMA controller. +*/ +struct fsl_dma_slave { + +/* List of hardware address/length pairs */ +struct list_head addresses; + +/* Support for extra controller features */ +unsigned int request_count; +unsigned int src_loop_size; +unsigned int dst_loop_size; +bool external_start; +bool external_pause; +}; + +/** +* fsl_dma_slave_append - add an address/length pair to a struct fsl_dma_slave +* @slave: the &struct fsl_dma_slave to add to +* @address: the hardware address to add +* @length: the length of bytes to transfer from @address +* +* Add a hardware address/length pair to a struct fsl_dma_slave. Returns 0 on +* success, -ERRNO otherwise. +*/ +static inline int fsl_dma_slave_append (struct fsl_dma_slave *slave, +dma_addr_t address,size_t length) +{ +struct fsl_dma_hw_addr *addr; + + addr =kzalloc (sizeof (*addr),GFP_ATOMIC ); +if (!addr) +return -ENOMEM ; + +INIT_LIST_HEAD (&addr->entry); + addr->address = address; + addr->length = length; + +list_add_tail (&addr->entry, &slave->addresses); +return 0 ; +} + +/** +* fsl_dma_slave_free - free a struct fsl_dma_slave +* @slave: the struct fsl_dma_slave to free +* +* Free a struct fsl_dma_slave and all associated address/length pairs +*/ +static inline void fsl_dma_slave_free (struct fsl_dma_slave *slave) +{ +struct fsl_dma_hw_addr *addr, *tmp; + +if (slave) { +list_for_each_entry_safe (addr, tmp, &slave->addresses, entry) { +list_del (&addr->entry); +kfree (addr); + } + +kfree (slave); + } +} + +/** +* fsl_dma_slave_alloc - allocate a struct fsl_dma_slave +* @gfp: the flags to pass to kmalloc when allocating this structure +* +* Allocate a struct fsl_dma_slave for use by the DMA_SLAVE API. Returns a new +* struct fsl_dma_slave on success, or NULL on failure. +*/ +static inline struct fsl_dma_slave *fsl_dma_slave_alloc (gfp_t gfp) +{ +struct fsl_dma_slave *slave; + + slave =kzalloc (sizeof (*slave), gfp); +if (!slave) +return NULL ; + +INIT_LIST_HEAD (&slave->addresses); +return slave; +} + +#endif /* __ARCH_POWERPC_ASM_FSLDMA_H__ */
drivers/dma/fsldma.c +227 -0
251 lines not on this page · raw message
Signature · 1 line
1.5.4.3
Quoted 20 lines · Ira Snyder
Use the
DMA_SLAVEcapability of the DMAEngine API to copy/from a scatterlist into an arbitrary list of hardware address/length pairs.This allows a single DMA transaction to copy data from several different devices into a scatterlist at the same time.
This also adds support to enable some controller-specific features such as external start and external pause for a DMA transaction.
Signed-off-by Ira W. Snyder <[email protected]>---
This patch depends on the "fsldma: split apart external pause and request count features" patch.
After discussion with Dan Williams, this is the third version of the
DMA_SLAVEAPI for the Freescale DMA controller. I've tested it heavily with both drivers I have written against this API, an FPGA programmer and an FPGA data grabber.
Quoted 8 lines
Kumar, Dan asked me to add you to the CC list, so you can have a look at this patch before he adds it to his tree.
The other two small patches I posted earlier are very helpful in testing this functionality. They make the fsldma driver leave the BWC (bandwidth control) bits alone on the 83xx controller, as well as making the external start feature available on 83xx.
Kumar, Leo,
Can I get your acked-by's for the current state of async_tx.git/next? I just pushed out Ira's latest so it may take a moment to mirror out.
Thanks,
Dan
The following changes since commit f234012f52a37e48f2330e1ca2df69800e797c3b:
Linus Torvalds (1):
Merge branch 'for-linus' of git://git.kernel.org/.../drzeus/mmc
are available in the git repository at:
ssh://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx.git next
Dan Williams (1):
dmaengine: move HIGHMEM64G restriction to ASYNC_TX_DMA
Ira Snyder (4):
fsldma: enable external start for the 83xx controller
fsldma: do not clear bandwidth control bits on the 83xx controller
fsldma: split apart external pause and request count features
fsldma: Add DMA_SLAVE support
Ira W. Snyder (1):
fsldma: use PCI Read Multiple command
arch/powerpc/include/asm/fsldma.h | 136 +++++++++++++++++ drivers/dma/Kconfig | 4 +- drivers/dma/fsldma.c | 287 ++++++++++++++++++++++++++++++++++--- drivers/dma/fsldma.h | 4 +- 4 files changed, 408 insertions(+), 23 deletions(-) create mode 100644 arch/powerpc/include/asm/fsldma.h
Quoted 38 lines · Dan Williams
Quoted 20 lines · Ira Snyder
Use the
DMA_SLAVEcapability of the DMAEngine API to copy/from a scatterlist into an arbitrary list of hardware address/length pairs.This allows a single DMA transaction to copy data from several different devices into a scatterlist at the same time.
This also adds support to enable some controller-specific features such as external start and external pause for a DMA transaction.
Signed-off-by Ira W. Snyder <[email protected]>---
This patch depends on the "fsldma: split apart external pause and request count features" patch.
After discussion with Dan Williams, this is the third version of the
DMA_SLAVEAPI for the Freescale DMA controller. I've tested it heavily with both drivers I have written against this API, an FPGA programmer and an FPGA data grabber.Quoted 8 lines
Kumar, Dan asked me to add you to the CC list, so you can have a look at this patch before he adds it to his tree.
The other two small patches I posted earlier are very helpful in testing this functionality. They make the fsldma driver leave the BWC (bandwidth control) bits alone on the 83xx controller, as well as making the external start feature available on 83xx.
Kumar, Leo,
Can I get your acked-by's for the current state of async_tx.git/next? I just pushed out Ira's latest so it may take a moment to mirror out.
Thanks,
Dan
Quoted 7 lines
The following changes since commit
f234012f52a37e48f2330e1ca2df69800e797c3b:
Linus Torvalds (1):
Merge branch 'for-linus' ofgit://git.kernel.org/.../drzeus/mmcare available in the git repository at:
ssh://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx.git next
That should be:
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx.git next
Li Yang
Acked-byOn Tue, Jun 23, 2009 at 5:20 AM, Dan Williams<[email protected]> wro= te:
Quoted 8 lines · Ira Snyder
Quoted 7 lines
Use the
DMA_SLAVEcapability of the DMAEngine API to copy/from a scatterlist into an arbitrary list of hardware address/length pairs.This allows a single DMA transaction to copy data from several different devices into a scatterlist at the same time.
This also adds support to enable some controller-specific features such =
as
Quoted 22 lines
Quoted 13 lines
external start and external pause for a DMA transaction.
Signed-off-by Ira W. Snyder <[email protected]>---
This patch depends on the "fsldma: split apart external pause and request count features" patch.
After discussion with Dan Williams, this is the third version of the
DMA_SLAVEAPI for the Freescale DMA controller. I've tested it heavily with both drivers I have written against this API, an FPGA programmer and an FPGA data grabber.Quoted 8 lines
Kumar, Dan asked me to add you to the CC list, so you can have a look at this patch before he adds it to his tree.
The other two small patches I posted earlier are very helpful in testing this functionality. They make the fsldma driver leave the BWC (bandwidth control) bits alone on the 83xx controller, as well as making the external start feature available on 83xx.
Quoted 3 lines
Kumar, Leo,
Can I get your acked-by's for the current state of async_tx.git/next? =C2=
=A0I
Quoted 1 line
just pushed out Ira's latest so it may take a moment to mirror out.
However, the addition of arch/powerpc/include/asm/fsldma.h still needs the ack from Kumar. It doesn't seem to be a common practice though.
- Leo
Quoted 33 lines · Li Yang
Quoted 32 lines · Dan Williams
Quoted 20 lines · Ira Snyder
Use the
DMA_SLAVEcapability of the DMAEngine API to copy/from a scatterlist into an arbitrary list of hardware address/length pairs.This allows a single DMA transaction to copy data from several different devices into a scatterlist at the same time.
This also adds support to enable some controller-specific features such as external start and external pause for a DMA transaction.
Signed-off-by Ira W. Snyder <[email protected]>---
This patch depends on the "fsldma: split apart external pause and request count features" patch.
After discussion with Dan Williams, this is the third version of the
DMA_SLAVEAPI for the Freescale DMA controller. I've tested it heavily with both drivers I have written against this API, an FPGA programmer and an FPGA data grabber.Quoted 8 lines
Kumar, Dan asked me to add you to the CC list, so you can have a look at this patch before he adds it to his tree.
The other two small patches I posted earlier are very helpful in testing this functionality. They make the fsldma driver leave the BWC (bandwidth control) bits alone on the 83xx controller, as well as making the external start feature available on 83xx.
Kumar, Leo,
Quoted 7 lines
Quoted 2 lines
Can I get your acked-by's for the current state of async_tx.git/next? I just pushed out Ira's latest so it may take a moment to mirror out.
Acked-by Li Yang <[email protected]>However, the addition of
arch/powerpc/include/asm/fsldma.hstill needs the ack from Kumar. It doesn't seem to be a common practice though.
hmm, why are we moving fsldma.h?
- k
Quoted 10 lines · Kumar Gala
Quoted 8 lines
Quoted 4 lines
Kumar, Leo,
Can I get your acked-by's for the current state of async_tx.git/ next? I just pushed out Ira's latest so it may take a moment to mirror out.
Acked-by Li Yang <[email protected]>However, the addition of
arch/powerpc/include/asm/fsldma.hstill needs the ack from Kumar. It doesn't seem to be a common practice though.hmm, why are we moving
fsldma.h?
There are now two fsldma.h files.
drivers/dma/fsldma.h: no changes, houses the private driver implementation details.
arch/powerpc/include/asm/fsldma.h: adds some helper routines and definitions for the DMA_SLAVE capability of the driver. It defines an interface for other drivers to use fsldma to initiate device-to-memory dma. Any drivers that use the interface will depend on CONFIG_FSL_DMA hence placing this public header under arch/powerpc/include.
Quoted 9 lines · Dan Williams
Quoted 8 lines · Kumar Gala
Quoted 8 lines
Quoted 4 lines
Kumar, Leo,
Can I get your acked-by's for the current state of async_tx.git/ next? I just pushed out Ira's latest so it may take a moment to mirror out.
Acked-by Li Yang <[email protected]>However, the addition of
arch/powerpc/include/asm/fsldma.hstill needs the ack from Kumar. It doesn't seem to be a common practice though.
Quoted 8 lines
Quoted 1 line
hmm, why are we moving
fsldma.h?There are now two
fsldma.hfiles.
drivers/dma/fsldma.h: no changes, houses the private driver implementation details.
arch/powerpc/include/asm/fsldma.h: adds some helper routines and definitions for theDMA_SLAVEcapability of the driver. It defines an interface for other drivers to use fsldma to initiate device-to-memory dma. Any drivers that use the interface will depend onCONFIG_FSL_DMAhence placing this public header underarch/powerpc/include.
Kumar? Shall we push this decision off to 2.6.32, I would prefer not to as Ira had his initial patches available before the merge window opened?
Ira, aside from the pci read multiple patch are there any others that are suitable for 2.6.31 if the dma_slave implementation gets held back?
Thanks,
Dan
Quoted 10 lines · Dan Williams
Quoted 9 lines · Dan Williams
Quoted 8 lines · Kumar Gala
Quoted 8 lines
Quoted 4 lines
Kumar, Leo,
Can I get your acked-by's for the current state of async_tx.git/ next? I just pushed out Ira's latest so it may take a moment to mirror out.
Acked-by Li Yang <[email protected]>However, the addition of
arch/powerpc/include/asm/fsldma.hstill needs the ack from Kumar. It doesn't seem to be a common practice though.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
hmm, why are we moving
fsldma.h?There are now two
fsldma.hfiles.drivers/dma/fsldma.h: no changes, houses the private driver implementation details.arch/powerpc/include/asm/fsldma.h: adds some helper routines and definitions for theDMA_SLAVEcapability of the driver. It defines an interface for other drivers to use fsldma to initiate device-to-memory dma. Any drivers that use the interface will depend onCONFIG_FSL_DMAhence placing this public header underarch/powerpc/include.Kumar? Shall we push this decision off to 2.6.32, I would prefer not to as Ira had his initial patches available before the merge window opened?
Ira, aside from the pci read multiple patch are there any others that are suitable for 2.6.31 if the
dma_slaveimplementation gets held back?
Lets go ahead w/2.6.31 (if its ok w/you).
- k
Quoted 3 lines · Kumar Gala
On Jun 24, 2009, at 12:56 PM, Dan Williams wrote:
Lets go ahead w/2.6.31 (if its ok w/you).
Ok, I'll take this as an acked-by and send it off.
Thanks,
Dan