Skip to contentSkip to conversation

dma: dmaengine: add slave req id in slave_config

PATCH Superseded Laxman Dewangan 2 participants 3 messages May 23, 2012 – Jun 1, 2012

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Laxman Dewangan

author maintainer
#0 lore raw

PATCH v4 1/2 dma: dmaengine: add slave req id in slave_config

The DMA controller like Nvidia's Tegra Dma controller supports the different slave requestor id from different slave. This need to be configure in dma controller to handle the request properly.

Adding the slave-id in the slave configuration so that information can be passed from client when configuring for slave.

---
Changes from V2:
- Make slave_id as unsigned.

No Changes from V3.

 include/linux/dmaengine.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/linux/dmaengine.h +4 -0
index 56377df..ccec62f 100644
@@ -338,6 +338,9 @@ enum dma_slave_buswidth {
  * @device_fc: Flow Controller Settings. Only valid for slave channels. Fill
  * with 'true' if peripheral should be flow controller. Direction will be
  * selected at Runtime.
+ * @slave_id: Slave requester id. Only valid for slave channels. The dma
+ * slave peripheral will have unique id as dma requester which need to be
+ * pass as slave config.
  *
  * This struct is passed in as configuration data to a DMA engine
  * in order to set up a certain channel for DMA transport at runtime.
@@ -365,6 +368,7 @@ struct dma_slave_config {
 	u32 src_maxburst;
 	u32 dst_maxburst;
 	bool device_fc;
+	unsigned int slave_id;
 };
 
 static inline const char *dma_chan_name(struct dma_chan *chan)
Signature · 1 line
1.7.1.1
author maintainer
#1 lore raw

PATCH v4 2/2 dma: tegra: add dmaengine based dma driver

Adding dmaengine based NVIDIA's Tegra APB DMA driver. This driver support the slave mode of data transfer from peripheral to memory and vice versa.
The driver supports for the cyclic and non-cyclic mode of data transfer.

---
Changes from V1:
- Incorportaed review comments from Vinod.
- get rid of the tegra_dma header.
- Having clock control through runtime pm.
- Remove regmap support.

Changes from V2:
- Taken care of aall review comments provided by Vinod.
- Drop cyclic_half notify mode of dma and implemented as cyclic only. This will make the this patch as simple. Also this can be achive by cyclic once mode. If require, we will add later.
- Remove goto most of places.
- Remove the cookie_complete() in aborted case.
- Remove callback when terminating.
- Macro names are now namespaced.
- Message prints are well formated to have in 1 or 2 line.

Changes from V3:
- Taken care of Setphen's comment.
- No error if isr arrive before callback of prev isr did not get called.
- Simplyfy the desc allocation.
- Namespaced for all macros.
- Rename file and comments to say Tegra20 APB DMA.
- Changed as module_platform_driver().

 drivers/dma/Kconfig           |   14 +
 drivers/dma/Makefile          |    1 +
 drivers/dma/tegra20-apb-dma.c | 1413 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1428 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dma/tegra20-apb-dma.c
drivers/dma/Kconfig +14 -0
index aadeb5b..6f684f9 100644
@@ -148,6 +148,20 @@ config TXX9_DMAC
 	  Support the TXx9 SoC internal DMA controller.  This can be
 	  integrated in chips such as the Toshiba TX4927/38/39.
 
+config TEGRA20_APB_DMA
+	bool "NVIDIA Tegra20 APB DMA support"
+	depends on ARCH_TEGRA
+	select DMA_ENGINE
+	help
+	  Support for the NVIDIA Tegra20 APB DMA controller driver. The
+	  dma controller is having multiple dma channel which can be
+	  configured for different peripherals like audio, UART, SPI,
+	  I2C etc which is in APB bus.
+	  This dma controller transfers data from memory to peripheral fifo
+	  or vice versa. It does not support memory to memory data transfer.
+
+
+
 config SH_DMAE
 	tristate "Renesas SuperH DMAC support"
 	depends on (SUPERH && SH_DMA) || (ARM && ARCH_SHMOBILE)
drivers/dma/Makefile +1 -0
index 86b795b..d679ea3 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_MXS_DMA) += mxs-dma.o
 obj-$(CONFIG_TIMB_DMA) += timb_dma.o
 obj-$(CONFIG_SIRF_DMA) += sirf-dma.o
 obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o
+obj-$(CONFIG_TEGRA20_APB_DMA) += tegra20-apb-dma.o
 obj-$(CONFIG_PL330_DMA) += pl330.o
 obj-$(CONFIG_PCH_DMA) += pch_dma.o
 obj-$(CONFIG_AMBA_PL08X) += amba-pl08x.o
drivers/dma/tegra20-apb-dma.c new file +1413 -0

1,413 lines not on this page · raw message

Signature · 1 line
1.7.1.1
Acked-by on v4 2/2
#2 lore raw

Re: [PATCH V4 2/2] dma: tegra: add dmaengine based dma driver

Quoted 5 lines · Laxman Dewangan

Adding dmaengine based NVIDIA's Tegra APB DMA driver. This driver support the slave mode of data transfer from peripheral to memory and vice versa.
The driver supports for the cyclic and non-cyclic mode of data transfer.

A few minor/nit-picky comments below. Apart from those,

Quoted 3 lines
drivers/dma/Kconfig +1 -0
 
+config TEGRA20_APB_DMA

...

drivers/dma/Kconfig config TXX9_DMAC · line 157

Quoted 3 lines
drivers/dma/Kconfig +3 -0
+	help
+	  Support for the NVIDIA Tegra20 APB DMA controller driver. The
+	  dma controller is having multiple dma channel which can be

It would be nice if DMA was correctly capitalized everywhere, but I guess I won't hold my ack for that.

drivers/dma/tegra20-apb-dma.c

Quoted 1 line
drivers/dma/tegra20-apb-dma.c +0 -0

Some of the register names don't exactly match the names in the TRM. But, it's fairly obvious what the mapping is, so I won't hold my ack for that.

drivers/dma/tegra20-apb-dma.c line 263

Quoted 4 lines
drivers/dma/tegra20-apb-dma.c +3 -0
+static struct tegra_dma_desc *tegra_dma_desc_get(
 
+	if (!list_empty(&tdc->free_dma_desc)) {
+

Unnecessary blank line.

Quoted 2 lines
drivers/dma/tegra20-apb-dma.c +2 -0
+		/* Do not allocate if desc are waiting for ack */
+		list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) {

...

drivers/dma/tegra20-apb-dma.c

Quoted 2 lines
drivers/dma/tegra20-apb-dma.c +2 -0
+		}
+	}

Doesn't list_for_each_entry() handle empty lists correctly? If so, you can just remove the outer if(){} here, and in both loops in tegra_dma_tx_status().

Quoted 6 lines
drivers/dma/tegra20-apb-dma.c +6 -0
+	spin_unlock_irqrestore(&tdc->lock, flags);
+
+	/* Allocate dma desc */
+	dma_desc = kzalloc(sizeof(*dma_desc), GFP_ATOMIC);
+	if (!dma_desc) {
+		dev_err(tdc2dev(tdc), "dma_desc alloc failed\n");

drivers/dma/tegra20-apb-dma.c line 337

Quoted 10 lines
drivers/dma/tegra20-apb-dma.c +9 -0
+		return NULL;
+	}
+
+	dma_async_tx_descriptor_init(&dma_desc->txd, &tdc->dma_chan);
+	dma_desc->txd.tx_submit = tegra_dma_tx_submit;
+	dma_desc->txd.flags = 0;
+	return dma_desc;
+}
 
+static void tegra_dma_gloabl_pause(struct tegra_dma_channel *tdc,

s/gloabl/global/

Quoted 1 line

+static inline int get_bus_width(enum dma_slave_buswidth slave_bw)

...

Quoted 1 line
drivers/dma/tegra20-apb-dma.c +1 -0
+	BUG_ON(!slave_bw);

...

drivers/dma/tegra20-apb-dma.c

Quoted 2 lines
drivers/dma/tegra20-apb-dma.c +2 -0
+	default:
+		BUG();

Maybe just return errors in those 2 cases?

Quoted 1 line

+static int __devinit tegra_dma_probe(struct platform_device *pdev)

...

drivers/dma/tegra20-apb-dma.c line 1240

Quoted 1 line
drivers/dma/tegra20-apb-dma.c +1 -0
+	tdma->dma_clk = clk_get(&pdev->dev, NULL);

Given this is going into 3.6, there's now devm_clk_get which you could use. However, fixing this up can be done in a later patch if you want.

drivers/dma/tegra20-apb-dma.c line 1260

Quoted 3 lines
drivers/dma/tegra20-apb-dma.c +3 -0
+	/* Reset DMA controller */
+	tegra_periph_reset_assert(tdma->dma_clk);
+	tegra_periph_reset_deassert(tdma->dma_clk);

This happens inside clk_enable() the first time it is called, so it may not really be necessary. It might negatively impact the conversion to common clock which might be more difficult with these APIs being used.

Also, don't you need to sleep between those two calls?

drivers/dma/tegra20-apb-dma.c

Quoted 2 lines
drivers/dma/tegra20-apb-dma.c +2 -0
+err_pm_disable:
+	pm_runtime_disable(&pdev->dev);

Don't you also need to cover the case where tegra_dma_runtime_resume() was called, and you need to reverse that?