Re: [PATCH] fsl-dma: allow Freescale Elo DMA driver to be compiled as a module

Previous thread: [PATCH v2] dmatest: properly handle duplicate DMA channels by Timur Tabi on Thursday, September 18, 2008 - 9:10 am. (2 messages)

Next thread: [PATCH] fix an example of scatterlists handling in DMA-API.txt by FUJITA Tomonori on Thursday, September 18, 2008 - 9:29 am. (2 messages)
From: Timur Tabi
Date: Thursday, September 18, 2008 - 9:24 am

Modify the Freescale Elo / Elo Plus DMA driver so that it can be compiled as
a module.

The primary change is to stop treating the DMA controller as a bus, and the
DMA channels as devices on the bus.  This is because the Open Firmware (OF)
kernel code does not allow busses to be removed, so although we can call
of_platform_bus_probe() to probe the DMA channels, there is no
of_platform_bus_remove().  Therefore, the DMA channels must be manually probed.

Signed-off-by: Timur Tabi <timur@freescale.com>
---

This patch is for the 2.6.28 kernel.  This patch exposes a bug in the dmatest
module, so my other patch "dmatest: properly handle duplicate DMA channels"
should be applied if this patch is applied.

 drivers/dma/Kconfig  |   10 ++--
 drivers/dma/fsldma.c |  165 ++++++++++++++++++++++++++++++++++----------------
 drivers/dma/fsldma.h |    2 +
 3 files changed, 119 insertions(+), 58 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index cd30390..9dfd502 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -48,13 +48,13 @@ config DW_DMAC
 	  can be integrated in chips such as the Atmel AT32ap7000.
 
 config FSL_DMA
-	bool "Freescale MPC85xx/MPC83xx DMA support"
-	depends on PPC
+	tristate "Freescale Elo and Elo Plus DMA support"
+	depends on PPC_83xx || PPC_85xx || PPC_86xx
 	select DMA_ENGINE
 	---help---
-	  Enable support for the Freescale DMA engine. Now, it support
-	  MPC8560/40, MPC8555, MPC8548 and MPC8641 processors.
-	  The MPC8349, MPC8360 is also supported.
+	  Enable support for the Freescale Elo and Elo Plus DMA controllers.
+	  The Elo is the DMA controller on 83xx parts, and the Elo Plus is
+	  the DMA controller on 85xx and 86xx parts.
 
 config MV_XOR
 	bool "Marvell XOR engine support"
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index c0059ca..327c485 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -372,6 +372,10 @@ static int fsl_dma_alloc_chan_resources(struct dma_chan *chan,
 	struct ...
From: Dan Williams
Date: Saturday, September 20, 2008 - 2:32 pm

[ added Li Yang to the cc ]


I am not familiar with the Open Firmware interface so I'll trust you
on that piece, but please see 2 comments below.

Thanks,

The last three hunks should be broken out into a separate 'fix' patch

removing a NULL fchan should be an error right?  Perhaps move the
--

From: Timur Tabi
Date: Monday, September 22, 2008 - 1:59 pm

Can you be more specific?  I can see how "return 0" -> "return -ENOMEM" could be
separated out, but the Kconfig hunk is integral to the patch, and the "if
(fsl_chan->desc_pool) return 1;" is needed to prevent a memory leak if the

No, this is a side-effect of not using a linked-list to store the channels found
by the driver.  The driver has a 4-element array to store the channel info.
Normally, all four channels are defined in the OF device tree, so all four
elements are defined.  But it's not a requirement, so in those cases, the
non-defined channels will have NULL for fchan.

I have plans to replace the array with a linked list.  This change will fix a

I can do that.

-- 
Timur Tabi
Linux kernel developer at Freescale
--

From: Dan Williams
Date: Tuesday, September 23, 2008 - 1:46 pm

Sorry, I miscounted.  I was indeed referring to the just the "return 0
--> return -ENOMEM" fix.

--
Dan
--

Previous thread: [PATCH v2] dmatest: properly handle duplicate DMA channels by Timur Tabi on Thursday, September 18, 2008 - 9:10 am. (2 messages)

Next thread: [PATCH] fix an example of scatterlists handling in DMA-API.txt by FUJITA Tomonori on Thursday, September 18, 2008 - 9:29 am. (2 messages)