Skip to contentSkip to conversation

dma: Add Xilinx AXI Central Direct Memory Access Engine driver support

PATCH Superseded Kedareswara rao Appana 2 participants 5 messages Jun 9, 2015 – Jul 7, 2015

Subsystems (2)

v5 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 2/2 dma: Add Xilinx AXI Central Direct Memory Access Engine driver support

This is the driver for the AXI Central Direct Memory Access (AXI CDMA) core, which is a soft Xilinx IP core that provides high-bandwidth Direct Memory Access (DMA) between a memory-mapped source address and a memory-mapped destination address.

This module works on Zynq (ARM Based SoC) and Microblaze platforms.

---
This patch is rebased on the commit
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Changes in v5:
- updated license in the driver as suggested by Paul.
- Corrected return value in is_idle funtion.
Changes in v4:
- used GFP_NOWAIT instead of GFP_KERNEL during the desc allocation
- Modified spin_lock handling moved the spin_lock to the appropriate functions
- device_control api is removed and updated driver as per newer APi's. Changes in v3:
- Check for CDMA idle condition before changing the configuration.
- Modified the xilinx_dma.h header file location to the include/linux/dma/xilinx_dma.h
Changes in v2:
- Rebased on 3.16-rc7.

 drivers/dma/Kconfig              |  12 +
 drivers/dma/xilinx/Makefile      |   1 +
 drivers/dma/xilinx/xilinx_cdma.c | 988 +++++++++++++++++++++++++++++++++++++++
 include/linux/dma/xilinx_dma.h   |  14 +
 4 files changed, 1015 insertions(+)
 create mode 100644 drivers/dma/xilinx/xilinx_cdma.c
drivers/dma/Kconfig +12 -0
index bda2cb0..c42cf24 100644
@@ -492,4 +492,16 @@ config QCOM_BAM_DMA
 	  Enable support for the QCOM BAM DMA controller.  This controller
 	  provides DMA capabilities for a variety of on-chip devices.
 
+config XILINX_CDMA
+        tristate "Xilinx AXI CDMA Engine"
+        depends on (ARCH_ZYNQ || MICROBLAZE)
+	select DMA_ENGINE
+	help
+          Enable support for Xilinx AXI CDMA Soft IP.
+
+          The AXI CDMA is a soft IP which provides high-bandwidth
+          Direct Memory Access (DMA) between a memory-mapped source
+          address and a memory-mapped destination address using the
+          AXI4 protocol.
+
 endif
drivers/dma/xilinx/Makefile +1 -0
index 3c4e9f2..e1dee77 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_XILINX_VDMA) += xilinx_vdma.o
+obj-$(CONFIG_XILINX_CDMA) += xilinx_cdma.o
drivers/dma/xilinx/xilinx_cdma.c new file +988 -0

988 lines not on this page · raw message

include/linux/dma/xilinx_dma.h +14 -0
index 34b98f2..90d3d0b 100644
@@ -41,7 +41,21 @@ struct xilinx_vdma_config {
 	int ext_fsync;
 };
 
+/**
+ * struct xilinx_cdma_config - CDMA Configuration structure
+ * @coalesc: Interrupt coalescing threshold
+ * @delay: Delay counter
+ * @reset: Reset Channel
+ */
+struct xilinx_cdma_config {
+	int coalesc;
+	int delay;
+	int reset;
+};
+
 int xilinx_vdma_channel_set_config(struct dma_chan *dchan,
 					struct xilinx_vdma_config *cfg);
+int xilinx_cdma_channel_set_config(struct dma_chan *dchan,
+					struct xilinx_cdma_config *cfg);
 
 #endif
Signature · 1 line
2.1.2
#1 lore raw

On Tue, Jun 09, 2015 at 02:18:10PM +0530, Kedareswara rao Appana wrote:

pls conform to the subsystem naming convention which git log on subsystem should have told you that it is dmaengine: xxx......

Quoted 5 lines

This is the driver for the AXI Central Direct Memory Access (AXI CDMA) core, which is a soft Xilinx IP core that provides high-bandwidth Direct Memory Access (DMA) between a memory-mapped source address and a memory-mapped destination address.

Quoted 7 lines

This module works on Zynq (ARM Based SoC) and Microblaze platforms.

---
This patch is rebased on the commit
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

why a random, unrelated commit? and no mention of tree..

Quoted 9 lines
drivers/dma/xilinx/xilinx_cdma.c new file +9 -0
+static struct dma_async_tx_descriptor *
+xilinx_cdma_prep_memcpy(struct dma_chan *dchan, dma_addr_t dma_dst,
+			dma_addr_t dma_src, size_t len, unsigned long flags)
+{
+	struct xilinx_cdma_chan *chan = to_xilinx_chan(dchan);
+	struct xilinx_cdma_desc_hw *hw;
+	struct xilinx_cdma_tx_descriptor *desc;
+	struct xilinx_cdma_tx_segment *segment, *prev;
+

drivers/dma/xilinx/xilinx_cdma.c line 663

Quoted 10 lines
drivers/dma/xilinx/xilinx_cdma.c new file +10 -0
+	if (!len || len > XILINX_CDMA_MAX_TRANS_LEN)
+		return NULL;
+
+	desc = xilinx_cdma_alloc_tx_descriptor(chan);
+	if (!desc)
+		return NULL;
+
+	dma_async_tx_descriptor_init(&desc->async_tx, &chan->common);
+	desc->async_tx.tx_submit = xilinx_cdma_tx_submit;
+	async_tx_ack(&desc->async_tx);

and why are you doing this ?

drivers/dma/xilinx/xilinx_cdma.c line 736

Quoted 8 lines
drivers/dma/xilinx/xilinx_cdma.c new file +8 -0
+int xilinx_cdma_channel_set_config(struct dma_chan *dchan,
+					struct xilinx_cdma_config *cfg)
+{
+	struct xilinx_cdma_chan *chan = to_xilinx_chan(dchan);
+	u32 reg = cdma_read(chan, XILINX_CDMA_CONTROL_OFFSET);
+
+	if (!xilinx_cdma_is_idle(chan))
+		return -EBUSY;

Why cant it be like dma_slave_config and take effect on next descriptor prepare?

drivers/dma/xilinx/xilinx_cdma.c line 739

Quoted 3 lines
drivers/dma/xilinx/xilinx_cdma.c new file +3 -0
+
+	if (cfg->reset)
+		return xilinx_cdma_chan_reset(chan);

Why do you want to reset this externally, that sounds bad to me

drivers/dma/xilinx/xilinx_cdma.c line 744

Quoted 5 lines
drivers/dma/xilinx/xilinx_cdma.c new file +5 -0
+
+	if (cfg->coalesc <= XILINX_CDMA_COALESCE_MAX) {
+		reg &= ~XILINX_CDMA_XR_COALESCE_MASK;
+		reg |= cfg->coalesc << XILINX_CDMA_COALESCE_SHIFT;
+	}

Can you explain what coalesc means here?

drivers/dma/xilinx/xilinx_cdma.c line 751

Quoted 7 lines
drivers/dma/xilinx/xilinx_cdma.c new file +7 -0
+
+	if (cfg->delay <= XILINX_CDMA_DELAY_MAX) {
+		reg &= ~XILINX_CDMA_XR_DELAY_MASK;
+		reg |= cfg->delay << XILINX_CDMA_DELAY_SHIFT;
+	}
+
+	cdma_write(chan, XILINX_CDMA_CONTROL_OFFSET, reg);

Shouldn't you save it apply for a descriptor?

drivers/dma/xilinx/xilinx_cdma.c line 755

Quoted 4 lines
drivers/dma/xilinx/xilinx_cdma.c new file +4 -0
+
+	return 0;
+}
+EXPORT_SYMBOL(xilinx_cdma_channel_set_config);

not EXPORT_SYMBOL_GPL?

drivers/dma/xilinx/xilinx_cdma.c line 798

Quoted 10 lines
drivers/dma/xilinx/xilinx_cdma.c new file +10 -0
+static int xilinx_cdma_chan_probe(struct xilinx_cdma_device *xdev,
+					struct device_node *node)
+{
+	struct xilinx_cdma_chan *chan;
+	bool has_dre;
+	u32 value, width;
+	int err;
+
+	/* Alloc channel */
+	chan = devm_kzalloc(xdev->dev, sizeof(*chan), GFP_NOWAIT);

Why do you use GFP_NOWAIT in probe?

Signature · 5 lines
~Vinod

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/
#2 lore raw

Hi Vinod,

Quoted 12 lines

-----Original Message-----
From: dmaengine-owner at vger.kernel.org [mailto:dmaengine-
owner at vger.kernel.org] On Behalf Of Vinod Koul
Sent: Monday, June 22, 2015 3:45 PM
To: Appana Durga Kedareswara Rao
Cc: dan.j.williams at intel.com; Michal Simek; Soren Brinkmann; Appana Durga Kedareswara Rao; Anirudha Sarangi; Punnaiah Choudary Kalluri; dmaengine at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux- kernel at vger.kernel.org; Srikanth Thokala
Subject: Re: [PATCH v5 2/2] dma: Add Xilinx AXI Central Direct Memory Access Engine driver support

Quoted 4 lines

On Tue, Jun 09, 2015 at 02:18:10PM +0530, Kedareswara rao Appana wrote:

pls conform to the subsystem naming convention which git log on subsystem should have told you that it is dmaengine: xxx......

Ok Sure will take care of it in the next version of the patch.

Quoted 7 lines
Quoted 4 lines

This is the driver for the AXI Central Direct Memory Access (AXI CDMA) core, which is a soft Xilinx IP core that provides high-bandwidth Direct Memory Access (DMA) between a memory-

mapped

Quoted 2 lines

source address and a memory-mapped destination address.

Quoted 8 lines
Quoted 7 lines

This module works on Zynq (ARM Based SoC) and Microblaze platforms.

---
This patch is rebased on the commit
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

why a random, unrelated commit? and no mention of tree..

Ok will fix in the next iteration of the patch.

Quoted 6 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+static struct dma_async_tx_descriptor *
+xilinx_cdma_prep_memcpy(struct dma_chan *dchan, dma_addr_t

dma_dst,

Quoted 1 line

+ dma_addr_t dma_src, size_t len, unsigned long flags)

{

Quoted 16 lines
Quoted 5 lines
drivers/dma/xilinx/xilinx_cdma.c new file +5 -0
+   struct xilinx_cdma_chan *chan = to_xilinx_chan(dchan);
+   struct xilinx_cdma_desc_hw *hw;
+   struct xilinx_cdma_tx_descriptor *desc;
+   struct xilinx_cdma_tx_segment *segment, *prev;
+

drivers/dma/xilinx/xilinx_cdma.c line 663

Quoted 10 lines
drivers/dma/xilinx/xilinx_cdma.c new file +10 -0
+   if (!len || len > XILINX_CDMA_MAX_TRANS_LEN)
+           return NULL;
+
+   desc = xilinx_cdma_alloc_tx_descriptor(chan);
+   if (!desc)
+           return NULL;
+
+   dma_async_tx_descriptor_init(&desc->async_tx, &chan->common);
+   desc->async_tx.tx_submit = xilinx_cdma_tx_submit;
+   async_tx_ack(&desc->async_tx);

and why are you doing this ?

Ok will remove.

Quoted 11 lines

drivers/dma/xilinx/xilinx_cdma.c line 736

Quoted 9 lines
drivers/dma/xilinx/xilinx_cdma.c new file +8 -0
+int xilinx_cdma_channel_set_config(struct dma_chan *dchan,
+                                   struct xilinx_cdma_config *cfg)
+{
+   struct xilinx_cdma_chan *chan = to_xilinx_chan(dchan);
+   u32 reg = cdma_read(chan, XILINX_CDMA_CONTROL_OFFSET);
+
+   if (!xilinx_cdma_is_idle(chan))
+           return -EBUSY;

Why cant it be like dma_slave_config and take effect on next descriptor prepare?

Will fix this part.

Quoted 5 lines

drivers/dma/xilinx/xilinx_cdma.c line 739

Quoted 4 lines
drivers/dma/xilinx/xilinx_cdma.c new file +3 -0
+
+   if (cfg->reset)
+           return xilinx_cdma_chan_reset(chan);

Why do you want to reset this externally, that sounds bad to me

If someone (client driver) want to reset the controller externally. It will be useful right?

Quoted 7 lines

drivers/dma/xilinx/xilinx_cdma.c line 744

Quoted 6 lines
drivers/dma/xilinx/xilinx_cdma.c new file +5 -0
+
+   if (cfg->coalesc <= XILINX_CDMA_COALESCE_MAX) {
+           reg &= ~XILINX_CDMA_XR_COALESCE_MASK;
+           reg |= cfg->coalesc << XILINX_CDMA_COALESCE_SHIFT;
+   }

Can you explain what coalesc means here?

Coalesc means interrupt threshold
This value is used for setting the interrupt threshold. When IOC (interrupt on complete) interrupt events occur, an internal counter Counts down from the Interrupt Threshold setting. When the count reaches zero, an interrupt out is generated by the DMA engine. This will be useful in case of SG transfer.

Quoted 9 lines

drivers/dma/xilinx/xilinx_cdma.c line 751

Quoted 8 lines
drivers/dma/xilinx/xilinx_cdma.c new file +7 -0
+
+   if (cfg->delay <= XILINX_CDMA_DELAY_MAX) {
+           reg &= ~XILINX_CDMA_XR_DELAY_MASK;
+           reg |= cfg->delay << XILINX_CDMA_DELAY_SHIFT;
+   }
+
+   cdma_write(chan, XILINX_CDMA_CONTROL_OFFSET, reg);

Shouldn't you save it apply for a descriptor?

Currently I am not making efficient use of it will use take care of it.

Quoted 5 lines

drivers/dma/xilinx/xilinx_cdma.c line 755

Quoted 4 lines
drivers/dma/xilinx/xilinx_cdma.c new file +4 -0
+
+   return 0;
+}
+EXPORT_SYMBOL(xilinx_cdma_channel_set_config);

not EXPORT_SYMBOL_GPL?

Ok will modify.

Quoted 13 lines

drivers/dma/xilinx/xilinx_cdma.c line 798

Quoted 12 lines
drivers/dma/xilinx/xilinx_cdma.c new file +10 -0
+static int xilinx_cdma_chan_probe(struct xilinx_cdma_device *xdev,
+                                   struct device_node *node)
+{
+   struct xilinx_cdma_chan *chan;
+   bool has_dre;
+   u32 value, width;
+   int err;
+
+   /* Alloc channel */
+   chan = devm_kzalloc(xdev->dev, sizeof(*chan), GFP_NOWAIT);

Why do you use GFP_NOWAIT in probe?

Ok will fix in the next version of patch.

Thanks for the review.

Regards,
Kedar.

Quoted 6 lines

--
~Vinod

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#3 lore raw

On Wed, Jun 24, 2015 at 05:12:12PM +0000, Appana Durga Kedareswara Rao wrote:

Please *fix* you MUA to wrap lines properly

Quoted 5 lines
Quoted 4 lines

drivers/dma/xilinx/xilinx_cdma.c line 739

Quoted 3 lines
drivers/dma/xilinx/xilinx_cdma.c new file +3 -0
+
+   if (cfg->reset)
+           return xilinx_cdma_chan_reset(chan);

Why do you want to reset this externally, that sounds bad to me

If someone (client driver) want to reset the controller externally. It will be useful right?

And why would they want to do that? There might be some other clients using other channels, doesnt sound good design to me. What is the motivation here...

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/dma/xilinx/xilinx_cdma.c new file +5 -0
+
+   if (cfg->coalesc <= XILINX_CDMA_COALESCE_MAX) {
+           reg &= ~XILINX_CDMA_XR_COALESCE_MASK;
+           reg |= cfg->coalesc << XILINX_CDMA_COALESCE_SHIFT;
+   }
Quoted 6 lines
Quoted 1 line

Can you explain what coalesc means here?

Coalesc means interrupt threshold
This value is used for setting the interrupt threshold. When IOC (interrupt on complete) interrupt events occur, an internal counter Counts down from the Interrupt Threshold setting. When the count reaches zero, an interrupt out is generated by the DMA engine. This will be useful in case of SG transfer.

IIUC, on IOC controller will count this threshold and then generate interrupt out?

Quoted 3 lines

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

Thats cute!

Signature · 1 line
~Vinod
#4 lore raw

Hi Vinod,

Quoted 10 lines

-----Original Message-----
From: Vinod Koul [mailto:vinod.koul at intel.com]
Sent: Saturday, June 27, 2015 7:49 PM
To: Appana Durga Kedareswara Rao
Cc: dan.j.williams at intel.com; Michal Simek; Soren Brinkmann; Anirudha Sarangi; Punnaiah Choudary Kalluri; dmaengine at vger.kernel.org; linux-arm- kernel at lists.infradead.org; linux-kernel at vger.kernel.org; Srikanth Thokala
Subject: Re: [PATCH v5 2/2] dma: Add Xilinx AXI Central Direct Memory Access Engine driver support

Quoted 4 lines

On Wed, Jun 24, 2015 at 05:12:12PM +0000, Appana Durga Kedareswara Rao wrote:

Please *fix* you MUA to wrap lines properly

Ok will take care next time onwards

Quoted 11 lines
Quoted 6 lines
Quoted 5 lines

drivers/dma/xilinx/xilinx_cdma.c line 739

Quoted 4 lines
drivers/dma/xilinx/xilinx_cdma.c new file +3 -0
+
+   if (cfg->reset)
+           return xilinx_cdma_chan_reset(chan);

Why do you want to reset this externally, that sounds bad to me

If someone (client driver) want to reset the controller externally. It will be

useful right?
And why would they want to do that? There might be some other clients using
other channels, doesnt sound good design to me. What is the motivation here...

If the client want to reset the channel in case of errors I thought providing this API may be helpful. Any way terminate_all API will do the resetting of the channel And does the cleanup of the lists that will be useful in case of errors. Will remove this API.

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

drivers/dma/xilinx/xilinx_cdma.c line 744

Quoted 9 lines
drivers/dma/xilinx/xilinx_cdma.c new file +5 -0
+
+   if (cfg->coalesc <= XILINX_CDMA_COALESCE_MAX) {
+           reg &= ~XILINX_CDMA_XR_COALESCE_MASK;
+           reg |= cfg->coalesc << XILINX_CDMA_COALESCE_SHIFT;
+   }

Can you explain what coalesc means here?

Quoted 9 lines
Quoted 2 lines

Coalesc means interrupt threshold
This value is used for setting the interrupt threshold. When IOC (interrupt

on complete) interrupt events occur, an internal counter

Quoted 1 line

Counts down from the Interrupt Threshold setting. When the count

reaches zero, an interrupt out is generated by the DMA engine.

Quoted 1 line

This will be useful in case of SG transfer.

IIUC, on IOC controller will count this threshold and then generate interrupt out?

Yes IOC controller will count this threshold.

Quoted 9 lines
Quoted 3 lines

This email and any attachments are intended for the sole use of the named

recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

Quoted 1 line

Thats cute!

I have fixed it now sorry for the noise.

Regards,
Kedar.

Quoted 3 lines

--
~Vinod