Skip to contentSkip to conversation

Convert JZ4740 to dmaengine

PATCH In review Lars-Peter Clausen 3 participants 18 messages May 30, 2013 – Jun 21, 2013

Subsystems (5)
Sound MIPS ASoC dmaengine +1 more subsystems
lore
Share & tools
lore
#0 lore raw

cover Convert JZ4740 to dmaengine

Hi,

This series replaces the custom JZ4740 DMA API with a dmaengine driver. This is done in 3 steps:
1) Add a dmaengine driver which wraps the custom JZ4740 DMA API
2) Update all users of the JZ4740 DMA API to use dmaengine instead
3) Remove the custom API and move all direct hardware access to the dmaengine driver.

The first two patches in the series also make sure that the clock of the DMA core is enabled.

Since the patches in this series depend on each other I'd prefer if they could all go through the DMA tree.

There are a few minor changes to the patch 3 in v2 of this series, all other patches are identical to v1.

- Lars

Lars-Peter Clausen (4):
dma: Add a jz4740 dmaengine driver
MIPS: jz4740: Register jz4740 DMA device
ASoC: jz4740: Use the generic dmaengine PCM driver
MIPS: jz4740: Remove custom DMA API

Maarten ter Huurne (2):
MIPS: jz4740: Correct clock gate bit for DMA controller
MIPS: jz4740: Acquire and enable DMA controller clock

 arch/mips/include/asm/mach-jz4740/dma.h      |  56 ---
 arch/mips/include/asm/mach-jz4740/platform.h |   1 +
 arch/mips/jz4740/Makefile                    |   2 +-
 arch/mips/jz4740/board-qi_lb60.c             |   1 +
 arch/mips/jz4740/clock.c                     |   2 +-
 arch/mips/jz4740/dma.c                       | 287 -------------
 arch/mips/jz4740/platform.c                  |  21 +
 drivers/dma/Kconfig                          |   6 +
 drivers/dma/Makefile                         |   1 +
 drivers/dma/dma-jz4740.c                     | 617 +++++++++++++++++++++++++++
 sound/soc/jz4740/Kconfig                     |   1 +
 sound/soc/jz4740/jz4740-i2s.c                |  48 +--
 sound/soc/jz4740/jz4740-pcm.c                | 310 +-------------
 sound/soc/jz4740/jz4740-pcm.h                |  20 -
 14 files changed, 676 insertions(+), 697 deletions(-)
 delete mode 100644 arch/mips/jz4740/dma.c
 create mode 100644 drivers/dma/dma-jz4740.c
 delete mode 100644 sound/soc/jz4740/jz4740-pcm.h
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH v2 1/6 MIPS: jz4740: Correct clock gate bit for DMA controller

From: Maarten ter Huurne <[email protected]>

---
No changes since v1

---
 arch/mips/jz4740/clock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/jz4740/clock.c +1 -1
index 484d38a..1b5f554 100644
@@ -687,7 +687,7 @@ static struct clk jz4740_clock_simple_clks[] = {
 	[3] = {
 		.name = "dma",
 		.parent = &jz_clk_high_speed_peripheral.clk,
-		.gate_bit = JZ_CLOCK_GATE_UART0,
+		.gate_bit = JZ_CLOCK_GATE_DMAC,
 		.ops = &jz_clk_simple_ops,
 	},
 	[4] = {
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH v2 2/6 MIPS: jz4740: Acquire and enable DMA controller clock

In reply to Lars-Peter Clausen

From: Maarten ter Huurne <[email protected]>

Previously, it was assumed that the DMA controller clock is not gated when the kernel starts running. While that is the power-on state, it is safer to not rely on that.

---
No changes since v1

---
 arch/mips/jz4740/dma.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
arch/mips/jz4740/dma.c +22 -2
index 317ec6f..0e34b97 100644
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/clk.h>
 #include <linux/interrupt.h>
 
 #include <linux/dma-mapping.h>
@@ -268,6 +269,7 @@ static irqreturn_t jz4740_dma_irq(int irq, void *dev_id)
 
 static int jz4740_dma_init(void)
 {
+	struct clk *clk;
 	unsigned int ret;
 
 	jz4740_dma_base = ioremap(JZ4740_DMAC_BASE_ADDR, 0x400);
@@ -277,11 +279,29 @@ static int jz4740_dma_init(void)
 
 	spin_lock_init(&jz4740_dma_lock);
 
-	ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, "DMA", NULL);
+	clk = clk_get(NULL, "dma");
+	if (IS_ERR(clk)) {
+		ret = PTR_ERR(clk);
+		printk(KERN_ERR "JZ4740 DMA: Failed to request clock: %d\n",
+				ret);
+		goto err_iounmap;
+	}
 
-	if (ret)
+	ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, "DMA", NULL);
+	if (ret) {
 		printk(KERN_ERR "JZ4740 DMA: Failed to request irq: %d\n", ret);
+		goto err_clkput;
+	}
+
+	clk_prepare_enable(clk);
+
+	return 0;
+
+err_clkput:
+	clk_put(clk);
 
+err_iounmap:
+	iounmap(jz4740_dma_base);
 	return ret;
 }
 arch_initcall(jz4740_dma_init);
Signature · 1 line
1.8.2.1
#3 lore raw

PATCH v2 3/6 dma: Add a jz4740 dmaengine driver

In reply to Lars-Peter Clausen

This patch adds dmaengine support for the JZ4740 DMA controller. For now the driver will be a wrapper around the custom JZ4740 DMA API. Once all users of the custom JZ4740 DMA API have been converted to the dmaengine API the custom API will be removed and direct hardware access will be added to the dmaengine driver.

---
Changes since v1:
* Only save the fifo addr instead of the full slave config
* #define JZ4740_DMA_NR_CHANS 6
* Return ENOSYS for unsuppored commands in the device_control() callback

---
 drivers/dma/Kconfig      |   6 +
 drivers/dma/Makefile     |   1 +
 drivers/dma/dma-jz4740.c | 433 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 440 insertions(+)
 create mode 100644 drivers/dma/dma-jz4740.c
drivers/dma/Kconfig +6 -0
index e992489..b3e8952 100644
@@ -312,6 +312,12 @@ config MMP_PDMA
 	help
 	  Support the MMP PDMA engine for PXA and MMP platfrom.
 
+config DMA_JZ4740
+	tristate "JZ4740 DMA support"
+	depends on MACH_JZ4740
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+
 config DMA_ENGINE
 	bool
 
drivers/dma/Makefile +1 -0
index a2b0df5..6127a61 100644
@@ -38,3 +38,4 @@ obj-$(CONFIG_DMA_SA11X0) += sa11x0-dma.o
 obj-$(CONFIG_MMP_TDMA) += mmp_tdma.o
 obj-$(CONFIG_DMA_OMAP) += omap-dma.o
 obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o
+obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o
drivers/dma/dma-jz4740.c new file +433 -0

433 lines not on this page · raw message

Signature · 1 line
1.8.2.1
#10 lore raw

PATCH v2 4/6 MIPS: jz4740: Register jz4740 DMA device

In reply to Lars-Peter Clausen

Register a device for the newly added jz4740 dmaengine driver.

---
No changes since v1

---
 arch/mips/include/asm/mach-jz4740/platform.h |  1 +
 arch/mips/jz4740/board-qi_lb60.c             |  1 +
 arch/mips/jz4740/platform.c                  | 21 +++++++++++++++++++++
 3 files changed, 23 insertions(+)
arch/mips/include/asm/mach-jz4740/platform.h +1 -0
index 72cfebd..05988c2 100644
@@ -32,6 +32,7 @@ extern struct platform_device jz4740_codec_device;
 extern struct platform_device jz4740_adc_device;
 extern struct platform_device jz4740_wdt_device;
 extern struct platform_device jz4740_pwm_device;
+extern struct platform_device jz4740_dma_device;
 
 void jz4740_serial_device_register(void);
 
arch/mips/jz4740/board-qi_lb60.c +1 -0
index be2b3de..8a5ec0e 100644
@@ -438,6 +438,7 @@ static struct platform_device *jz_platform_devices[] __initdata = {
 	&jz4740_rtc_device,
 	&jz4740_adc_device,
 	&jz4740_pwm_device,
+	&jz4740_dma_device,
 	&qi_lb60_gpio_keys,
 	&qi_lb60_pwm_beeper,
 	&qi_lb60_charger_device,
arch/mips/jz4740/platform.c +21 -0
index e9348fd..35a9d8c 100644
@@ -329,3 +329,24 @@ struct platform_device jz4740_pwm_device = {
 	.name = "jz4740-pwm",
 	.id   = -1,
 };
+
+/* DMA */
+static struct resource jz4740_dma_resources[] = {
+	{
+		.start	= JZ4740_DMAC_BASE_ADDR,
+		.end	= JZ4740_DMAC_BASE_ADDR + 0x400 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= JZ4740_IRQ_DMAC,
+		.end	= JZ4740_IRQ_DMAC,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device jz4740_dma_device = {
+	.name	= "jz4740-dma",
+	.id	= -1,
+	.num_resources = ARRAY_SIZE(jz4740_dma_resources),
+	.resource      = jz4740_dma_resources,
+};
Signature · 1 line
1.8.2.1
#13 lore raw

PATCH v2 5/6 ASoC: jz4740: Use the generic dmaengine PCM driver

In reply to Lars-Peter Clausen

Since there is a dmaengine driver for the jz4740 DMA controller now we can use the generic dmaengine PCM driver instead of a custom one.

---
No changes since v1

---
 sound/soc/jz4740/Kconfig      |   1 +
 sound/soc/jz4740/jz4740-i2s.c |  48 +++----
 sound/soc/jz4740/jz4740-pcm.c | 310 ++----------------------------------------
 sound/soc/jz4740/jz4740-pcm.h |  20 ---
 4 files changed, 27 insertions(+), 352 deletions(-)
 delete mode 100644 sound/soc/jz4740/jz4740-pcm.h
sound/soc/jz4740/Kconfig +1 -0
index 5351cba..29f76af 100644
@@ -1,6 +1,7 @@
 config SND_JZ4740_SOC
 	tristate "SoC Audio for Ingenic JZ4740 SoC"
 	depends on MACH_JZ4740 && SND_SOC
+	select SND_SOC_GENERIC_DMAENGINE_PCM
 	help
 	  Say Y or M if you want to add support for codecs attached to
 	  the JZ4740 I2S interface. You will also need to select the audio
sound/soc/jz4740/jz4740-i2s.c +17 -31

106 lines not on this page · raw message

sound/soc/jz4740/jz4740-pcm.c +9 -301

337 lines not on this page · raw message

sound/soc/jz4740/jz4740-pcm.h deleted +0 -20
deleted file mode 100644
index 1220cbb..0000000
@@ -1,20 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _JZ4740_PCM_H
-#define _JZ4740_PCM_H
-
-#include <linux/dma-mapping.h>
-#include <asm/mach-jz4740/dma.h>
-
-
-struct jz4740_pcm_config {
-	struct jz4740_dma_config dma_config;
-	phys_addr_t fifo_addr;
-};
-
-#endif
Signature · 1 line
1.8.2.1
#14 lore raw

PATCH v2 6/6 MIPS: jz4740: Remove custom DMA API

In reply to Lars-Peter Clausen

Now that all users of the custom jz4740 DMA API have been converted to use the dmaengine API instead we can remove the custom API and move all the code talking to the hardware to the dmaengine driver.

---
No changes since v1

---
 arch/mips/include/asm/mach-jz4740/dma.h |  56 ------
 arch/mips/jz4740/Makefile               |   2 +-
 arch/mips/jz4740/dma.c                  | 307 --------------------------------
 drivers/dma/dma-jz4740.c                | 258 +++++++++++++++++++++++----
 4 files changed, 222 insertions(+), 401 deletions(-)
 delete mode 100644 arch/mips/jz4740/dma.c
arch/mips/include/asm/mach-jz4740/dma.h +0 -56
index 98b4e7c..509cd58 100644
@@ -16,8 +16,6 @@
 #ifndef __ASM_MACH_JZ4740_DMA_H__
 #define __ASM_MACH_JZ4740_DMA_H__
 
-struct jz4740_dma_chan;
-
 enum jz4740_dma_request_type {
 	JZ4740_DMA_TYPE_AUTO_REQUEST	= 8,
 	JZ4740_DMA_TYPE_UART_TRANSMIT	= 20,
@@ -33,58 +31,4 @@ enum jz4740_dma_request_type {
 	JZ4740_DMA_TYPE_SLCD		= 30,
 };
 
-enum jz4740_dma_width {
-	JZ4740_DMA_WIDTH_32BIT	= 0,
-	JZ4740_DMA_WIDTH_8BIT	= 1,
-	JZ4740_DMA_WIDTH_16BIT	= 2,
-};
-
-enum jz4740_dma_transfer_size {
-	JZ4740_DMA_TRANSFER_SIZE_4BYTE	= 0,
-	JZ4740_DMA_TRANSFER_SIZE_1BYTE	= 1,
-	JZ4740_DMA_TRANSFER_SIZE_2BYTE	= 2,
-	JZ4740_DMA_TRANSFER_SIZE_16BYTE = 3,
-	JZ4740_DMA_TRANSFER_SIZE_32BYTE = 4,
-};
-
-enum jz4740_dma_flags {
-	JZ4740_DMA_SRC_AUTOINC = 0x2,
-	JZ4740_DMA_DST_AUTOINC = 0x1,
-};
-
-enum jz4740_dma_mode {
-	JZ4740_DMA_MODE_SINGLE	= 0,
-	JZ4740_DMA_MODE_BLOCK	= 1,
-};
-
-struct jz4740_dma_config {
-	enum jz4740_dma_width src_width;
-	enum jz4740_dma_width dst_width;
-	enum jz4740_dma_transfer_size transfer_size;
-	enum jz4740_dma_request_type request_type;
-	enum jz4740_dma_flags flags;
-	enum jz4740_dma_mode mode;
-};
-
-typedef void (*jz4740_dma_complete_callback_t)(struct jz4740_dma_chan *, int, void *);
-
-struct jz4740_dma_chan *jz4740_dma_request(void *dev, const char *name);
-void jz4740_dma_free(struct jz4740_dma_chan *dma);
-
-void jz4740_dma_configure(struct jz4740_dma_chan *dma,
-	const struct jz4740_dma_config *config);
-
-
-void jz4740_dma_enable(struct jz4740_dma_chan *dma);
-void jz4740_dma_disable(struct jz4740_dma_chan *dma);
-
-void jz4740_dma_set_src_addr(struct jz4740_dma_chan *dma, dma_addr_t src);
-void jz4740_dma_set_dst_addr(struct jz4740_dma_chan *dma, dma_addr_t dst);
-void jz4740_dma_set_transfer_count(struct jz4740_dma_chan *dma, uint32_t count);
-
-uint32_t jz4740_dma_get_residue(const struct jz4740_dma_chan *dma);
-
-void jz4740_dma_set_complete_cb(struct jz4740_dma_chan *dma,
-	jz4740_dma_complete_callback_t cb);
-
 #endif	/* __ASM_JZ4740_DMA_H__ */
arch/mips/jz4740/Makefile +1 -1
index 63bad0e..28e5535 100644
@@ -4,7 +4,7 @@
 
 # Object file lists.
 
-obj-y += prom.o irq.o time.o reset.o setup.o dma.o \
+obj-y += prom.o irq.o time.o reset.o setup.o \
 	gpio.o clock.o platform.o timer.o serial.o
 
 obj-$(CONFIG_DEBUG_FS) += clock-debugfs.o
arch/mips/jz4740/dma.c deleted +0 -307

307 lines not on this page · raw message

drivers/dma/dma-jz4740.c +221 -37

412 lines not on this page · raw message

Signature · 1 line
1.8.2.1
#15 lore raw

Re: [PATCH v2 6/6] MIPS: jz4740: Remove custom DMA API

Quoted 8 lines · Lars-Peter Clausen

Now that all users of the custom jz4740 DMA API have been converted to use the dmaengine API instead we can remove the custom API and move all the code talking to the hardware to the dmaengine driver.

---
No changes since v1

Quoted 7 lines
---
 arch/mips/include/asm/mach-jz4740/dma.h |  56 ------
 arch/mips/jz4740/Makefile               |   2 +-
 arch/mips/jz4740/dma.c                  | 307 --------------------------------
 drivers/dma/dma-jz4740.c                | 258 +++++++++++++++++++++++----
 4 files changed, 222 insertions(+), 401 deletions(-)
 delete mode 100644 arch/mips/jz4740/dma.c

only dma.c, you should remove the dma.h or relocate it to linux/

rest of the series looks fine, and once we have acks from repsective subsystem mainatiners, we should be good to merge

--
~Vinod

#11 lore raw

Re: [PATCH v2 4/6] MIPS: jz4740: Register jz4740 DMA device

In reply to Lars-Peter Clausen

Hello.

Quoted 4 lines · Lars-Peter Clausen

Register a device for the newly added jz4740 dmaengine driver.

[...]

Quoted 6 lines
  3 files changed, 23 insertions(+)
arch/mips/jz4740/platform.c +0 -0
index e9348fd..35a9d8c 100644
@@ -329,3 +329,24 @@ struct platform_device jz4740_pwm_device = {

[...]

arch/mips/jz4740/platform.c struct platform_device jz4740_pwm_device = { · line 349

Quoted 3 lines
arch/mips/jz4740/platform.c +3 -0
+struct platform_device jz4740_dma_device = {
+	.name	= "jz4740-dma",
+	.id	= -1,

Why not align all = in this structure?

Quoted 3 lines
arch/mips/jz4740/platform.c +3 -0
+	.num_resources = ARRAY_SIZE(jz4740_dma_resources),
+	.resource      = jz4740_dma_resources,
+};
#4 lore raw

Re: [PATCH v2 3/6] dma: Add a jz4740 dmaengine driver

In reply to Lars-Peter Clausen

Review

Quoted 8 lines · Lars-Peter Clausen

This patch adds dmaengine support for the JZ4740 DMA controller. For now the driver will be a wrapper around the custom JZ4740 DMA API. Once all users of the custom JZ4740 DMA API have been converted to the dmaengine API the custom API will be removed and direct hardware access will be added to the dmaengine driver.

(quoted diff) +2 -0
+
+#include <asm/mach-jz4740/dma.h>

Am bit worried about having header in arch. Why cant we have this drivers header in linux/. That way same IP block cna be reused across archs.
I was hoping that you would have move it in 6th patch, but that isnt the case

drivers/dma/dma-jz4740.c line 353

Quoted 11 lines
drivers/dma/dma-jz4740.c new file +11 -0
+static int jz4740_dma_alloc_chan_resources(struct dma_chan *c)
+{
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);
+
+	chan->jz_chan = jz4740_dma_request(chan, NULL);
+	if (!chan->jz_chan)
+		return -EBUSY;
+
+	jz4740_dma_set_complete_cb(chan->jz_chan, jz4740_dma_complete_cb);
+
+	return 0;

Sorry, I didnt reply on this one. The API expects you to allocate a pool of descriptors. These descriptors are to be used in .device_prep_xxx calls later.

--
~Vinod

#5 lore raw

Re: [PATCH v2 3/6] dma: Add a jz4740 dmaengine driver

Quoted 7 lines · Vinod Koul
Quoted 6 lines · Lars-Peter Clausen

This patch adds dmaengine support for the JZ4740 DMA controller. For now the driver will be a wrapper around the custom JZ4740 DMA API. Once all users of the custom JZ4740 DMA API have been converted to the dmaengine API the custom API will be removed and direct hardware access will be added to the dmaengine driver.

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+#include <asm/mach-jz4740/dma.h>

Am bit worried about having header in arch. Why cant we have this drivers header in linux/. That way same IP block cna be reused across archs.
I was hoping that you would have move it in 6th patch, but that isnt the case

At the end of this series the header only contains the slave ids used by the various cores on the JZ4740. Since these ids differ from SoC to SoC it doesn't make much sense to move the header to a generic location.

Quoted 15 lines

drivers/dma/dma-jz4740.c line 353

Quoted 13 lines
drivers/dma/dma-jz4740.c new file +11 -0
+static int jz4740_dma_alloc_chan_resources(struct dma_chan *c)
+{
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);
+
+	chan->jz_chan = jz4740_dma_request(chan, NULL);
+	if (!chan->jz_chan)
+		return -EBUSY;
+
+	jz4740_dma_set_complete_cb(chan->jz_chan, jz4740_dma_complete_cb);
+
+	return 0;

Sorry, I didnt reply on this one. The API expects you to allocate a pool of descriptors. These descriptors are to be used in .device_prep_xxx calls later.

The size of the descriptor is not fixed, so they can not be pre-allocated. And this is nothing new either, most of the more recently added dmaengine drivers allocate their descriptors on demand.

- Lars

#16 lore raw

Re: [PATCH v2 6/6] MIPS: jz4740: Remove custom DMA API

In reply to Vinod Koul
Quoted 16 lines · Vinod Koul
Quoted 8 lines · Lars-Peter Clausen

Now that all users of the custom jz4740 DMA API have been converted to use the dmaengine API instead we can remove the custom API and move all the code talking to the hardware to the dmaengine driver.

---
No changes since v1

Quoted 7 lines
---
 arch/mips/include/asm/mach-jz4740/dma.h |  56 ------
 arch/mips/jz4740/Makefile               |   2 +-
 arch/mips/jz4740/dma.c                  | 307 --------------------------------
 drivers/dma/dma-jz4740.c                | 258 +++++++++++++++++++++++----
 4 files changed, 222 insertions(+), 401 deletions(-)
 delete mode 100644 arch/mips/jz4740/dma.c
Quoted 1 line

only dma.c, you should remove the dma.h or relocate it to linux/

As I said the header only contains the slave ids at this point and the dmaengine driver doesn't need it anymore. So I should remove the #include from the driver as well.

Quoted 4 lines

rest of the series looks fine, and once we have acks from repsective subsystem mainatiners, we should be good to merge

We already have acks from the maintainers.

- Lars

#6 lore raw

Re: [PATCH v2 3/6] dma: Add a jz4740 dmaengine driver

In reply to Lars-Peter Clausen
Quoted 14 lines · Lars-Peter Clausen
Quoted 5 lines
Quoted 5 lines
drivers/dma/dma-jz4740.c new file +5 -0
+static int jz4740_dma_alloc_chan_resources(struct dma_chan *c)
+{
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);
+
+	chan->jz_chan = jz4740_dma_request(chan, NULL);
Quoted 8 lines

drivers/dma/dma-jz4740.c line 353

Quoted 6 lines
drivers/dma/dma-jz4740.c new file +6 -0
+	if (!chan->jz_chan)
+		return -EBUSY;
+
+	jz4740_dma_set_complete_cb(chan->jz_chan, jz4740_dma_complete_cb);
+
+	return 0;

Sorry, I didnt reply on this one. The API expects you to allocate a pool of descriptors. These descriptors are to be used in .device_prep_xxx calls later.

Quoted 3 lines

The size of the descriptor is not fixed, so they can not be pre-allocated. And this is nothing new either, most of the more recently added dmaengine drivers allocate their descriptors on demand.

Vinod, are you ok with this explanation?

- Lars

#12 lore raw

Re: [PATCH v2 4/6] MIPS: jz4740: Register jz4740 DMA device

In reply to Sergei Shtylyov
Quoted 16 lines · Sergei Shtylyov

Hello.

Quoted 4 lines · Lars-Peter Clausen

Register a device for the newly added jz4740 dmaengine driver.

[...]

Quoted 6 lines
  3 files changed, 23 insertions(+)
arch/mips/jz4740/platform.c +0 -0
index e9348fd..35a9d8c 100644
@@ -329,3 +329,24 @@ struct platform_device jz4740_pwm_device = {

[...]

Quoted 6 lines

arch/mips/jz4740/platform.c struct platform_device jz4740_pwm_device = { · line 349

Quoted 3 lines
arch/mips/jz4740/platform.c +3 -0
+struct platform_device jz4740_dma_device = {
+    .name    = "jz4740-dma",
+    .id    = -1,

Why not align all = in this structure?

Will fix that in the next version, thanks.

- Lars

#7 lore raw

Re: [PATCH v2 3/6] dma: Add a jz4740 dmaengine driver

In reply to Lars-Peter Clausen
Quoted 15 lines · Lars-Peter Clausen
Quoted 14 lines · Lars-Peter Clausen
Quoted 13 lines

drivers/dma/dma-jz4740.c line 353

Quoted 11 lines
drivers/dma/dma-jz4740.c new file +11 -0
+static int jz4740_dma_alloc_chan_resources(struct dma_chan *c)
+{
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);
+
+	chan->jz_chan = jz4740_dma_request(chan, NULL);
+	if (!chan->jz_chan)
+		return -EBUSY;
+
+	jz4740_dma_set_complete_cb(chan->jz_chan, jz4740_dma_complete_cb);
+
+	return 0;

Sorry, I didnt reply on this one. The API expects you to allocate a pool of descriptors. These descriptors are to be used in .device_prep_xxx calls later.

Quoted 5 lines
Quoted 3 lines

The size of the descriptor is not fixed, so they can not be pre-allocated. And this is nothing new either, most of the more recently added dmaengine drivers allocate their descriptors on demand.

Vinod, are you ok with this explanation?

Sorry, I was travelling...

Can you explain more of a bit when you say size is not fixed. Why would it be issue if we allocate descriptors at the alloc_chan. The idea is that you preallocated pool at alloc_chan and since the .device_prep_xxx calls can be called from atomic context as well, you dont need to do this later. You can use use these descriptors at that time. The idea is keep rotating the descriptors from free poll to used one

--
~Vinod

#8 lore raw

Re: [alsa-devel] [PATCH v2 3/6] dma: Add a jz4740 dmaengine driver

Quoted 16 lines · Vinod Koul
Quoted 15 lines · Lars-Peter Clausen
Quoted 14 lines · Lars-Peter Clausen
Quoted 13 lines

drivers/dma/dma-jz4740.c line 353

Quoted 11 lines
drivers/dma/dma-jz4740.c new file +11 -0
+static int jz4740_dma_alloc_chan_resources(struct dma_chan *c)
+{
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);
+
+	chan->jz_chan = jz4740_dma_request(chan, NULL);
+	if (!chan->jz_chan)
+		return -EBUSY;
+
+	jz4740_dma_set_complete_cb(chan->jz_chan, jz4740_dma_complete_cb);
+
+	return 0;

Sorry, I didnt reply on this one. The API expects you to allocate a pool of descriptors. These descriptors are to be used in .device_prep_xxx calls later.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The size of the descriptor is not fixed, so they can not be pre-allocated. And this is nothing new either, most of the more recently added dmaengine drivers allocate their descriptors on demand.

Vinod, are you ok with this explanation?

Sorry, I was travelling...

Can you explain more of a bit when you say size is not fixed.

This is the function that allocates the descriptor:

static struct jz4740_dma_desc *jz4740_dma_alloc_desc(unsigned int num_sgs)

{
	return kzalloc(sizeof(struct jz4740_dma_desc) +
		sizeof(struct jz4740_dma_sg) * num_sgs, GFP_ATOMIC);
}

So the size depends on the entries in the sg list.

Quoted 6 lines

Why would it be
issue if we allocate descriptors at the alloc_chan. The idea is that you preallocated pool at alloc_chan and since the .device_prep_xxx calls can be called from atomic context as well, you dont need to do this later. You can use use these descriptors at that time. The idea is keep rotating the descriptors from free poll to used one

Yes, I know all that. And it makes sense to use a pool in certain situations, e.g. if the hardware only supports a limited set of physical descriptors. But in this case the descriptors are completely virtual. Forcing the driver to use a pool would make it more complex, use more memory and also a bit slower (although probably not noticeable).

- Lars

#9 lore raw

Re: [alsa-devel] [PATCH v2 3/6] dma: Add a jz4740 dmaengine driver

Quoted 44 lines · Lars-Peter Clausen
Quoted 16 lines · Vinod Koul
Quoted 15 lines · Lars-Peter Clausen
Quoted 14 lines · Lars-Peter Clausen
Quoted 13 lines

drivers/dma/dma-jz4740.c line 353

Quoted 11 lines
drivers/dma/dma-jz4740.c new file +11 -0
+static int jz4740_dma_alloc_chan_resources(struct dma_chan *c)
+{
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);
+
+	chan->jz_chan = jz4740_dma_request(chan, NULL);
+	if (!chan->jz_chan)
+		return -EBUSY;
+
+	jz4740_dma_set_complete_cb(chan->jz_chan, jz4740_dma_complete_cb);
+
+	return 0;

Sorry, I didnt reply on this one. The API expects you to allocate a pool of descriptors. These descriptors are to be used in .device_prep_xxx calls later.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The size of the descriptor is not fixed, so they can not be pre-allocated. And this is nothing new either, most of the more recently added dmaengine drivers allocate their descriptors on demand.

Vinod, are you ok with this explanation?

Sorry, I was travelling...

Can you explain more of a bit when you say size is not fixed.

This is the function that allocates the descriptor:

static struct jz4740_dma_desc *jz4740_dma_alloc_desc(unsigned int num_sgs)

{
	return kzalloc(sizeof(struct jz4740_dma_desc) +
		sizeof(struct jz4740_dma_sg) * num_sgs, GFP_ATOMIC);
}

So the size depends on the entries in the sg list.

Quoted 6 lines

Why would it be
issue if we allocate descriptors at the alloc_chan. The idea is that you preallocated pool at alloc_chan and since the .device_prep_xxx calls can be called from atomic context as well, you dont need to do this later. You can use use these descriptors at that time. The idea is keep rotating the descriptors from free poll to used one

Quoted 5 lines

Yes, I know all that. And it makes sense to use a pool in certain situations, e.g. if the hardware only supports a limited set of physical descriptors. But in this case the descriptors are completely virtual. Forcing the driver to use a pool would make it more complex, use more memory and also a bit slower (although probably not noticeable).

Okay, I am going to try applying these now

--
~Vinod

#17 lore raw
In reply to Lars-Peter Clausen
Quoted 9 lines · Lars-Peter Clausen

Hi,

This series replaces the custom JZ4740 DMA API with a dmaengine driver. This is done in 3 steps:
1) Add a dmaengine driver which wraps the custom JZ4740 DMA API
2) Update all users of the JZ4740 DMA API to use dmaengine instead
3) Remove the custom API and move all direct hardware access to the dmaengine driver.

Quoted 8 lines

The first two patches in the series also make sure that the clock of the DMA core is enabled.

Since the patches in this series depend on each other I'd prefer if they could all go through the DMA tree.

There are a few minor changes to the patch 3 in v2 of this series, all other patches are identical to v1.

Applied all expect the "ASoC: jz4740: Use the generic dmaengine PCM driver". Can you rebase that on slave dma-next and resend

Fixed up struct alignment manually in 4th one

--
~Vinod

Quoted 35 lines

- Lars

Lars-Peter Clausen (4):
dma: Add a jz4740 dmaengine driver
MIPS: jz4740: Register jz4740 DMA device
ASoC: jz4740: Use the generic dmaengine PCM driver
MIPS: jz4740: Remove custom DMA API

Maarten ter Huurne (2):
MIPS: jz4740: Correct clock gate bit for DMA controller
MIPS: jz4740: Acquire and enable DMA controller clock

 arch/mips/include/asm/mach-jz4740/dma.h      |  56 ---
 arch/mips/include/asm/mach-jz4740/platform.h |   1 +
 arch/mips/jz4740/Makefile                    |   2 +-
 arch/mips/jz4740/board-qi_lb60.c             |   1 +
 arch/mips/jz4740/clock.c                     |   2 +-
 arch/mips/jz4740/dma.c                       | 287 -------------
 arch/mips/jz4740/platform.c                  |  21 +
 drivers/dma/Kconfig                          |   6 +
 drivers/dma/Makefile                         |   1 +
 drivers/dma/dma-jz4740.c                     | 617 +++++++++++++++++++++++++++
 sound/soc/jz4740/Kconfig                     |   1 +
 sound/soc/jz4740/jz4740-i2s.c                |  48 +--
 sound/soc/jz4740/jz4740-pcm.c                | 310 +-------------
 sound/soc/jz4740/jz4740-pcm.h                |  20 -
 14 files changed, 676 insertions(+), 697 deletions(-)
 delete mode 100644 arch/mips/jz4740/dma.c
 create mode 100644 drivers/dma/dma-jz4740.c
 delete mode 100644 sound/soc/jz4740/jz4740-pcm.h
Signature · 1 line
1.8.2.1