Skip to contentSkip to conversation

fsl-dma: allow Freescale Elo DMA driver to be compiled as a module

PATCH Applied Timur Tabi 4 participants 9 messages Sep 24, 2008 – Sep 27, 2008

Subsystems (2)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH v2 1/1 fsl-dma: allow Freescale Elo DMA driver to be compiled as a module

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(). Instead, the DMA channels are manually probed, similar to what fsl_elbc_nand.c does.

---

v2: updated per comments

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 |  138 ++++++++++++++++++++++++++++++++------------------
 drivers/dma/fsldma.h |    1 +
 3 files changed, 94 insertions(+), 55 deletions(-)
drivers/dma/Kconfig +5 -5
index cd30390..904e575 100644
@@ -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 FSL_SOC
 	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 some 82xx and 83xx parts, and the
+	  Elo Plus is the DMA controller on 85xx and 86xx parts.
 
 config MV_XOR
 	bool "Marvell XOR engine support"
drivers/dma/fsldma.c +88 -50

242 lines not on this page · raw message

drivers/dma/fsldma.h +1 -0
index 6faf07b..4f21a51 100644
@@ -114,6 +114,7 @@ struct fsl_dma_device {
 	struct dma_device common;
 	struct fsl_dma_chan *chan[FSL_DMA_MAX_CHANS_PER_DEVICE];
 	u32 feature;		/* The same as DMA channels */
+	int irq;		/* Channel IRQ */
 };
 
 /* Define macros for fsl_dma_chan->feature property */
Signature · 1 line
1.5.5
Acked-by on v2 1/1
#1 lore raw
Quoted 18 lines · Timur Tabi

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(). Instead, the DMA channels are manually probed, similar to what fsl_elbc_nand.c does.

---

v2: updated per comments

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.

[snip]

drivers/dma/fsldma.c static struct of_device_id of_fsl_dma_ids[] = { · line 1032

Quoted 7 lines
drivers/dma/fsldma.c +3 -1
+static void __exit of_fsl_dma_exit(void)
+{
+       of_unregister_platform_driver(&of_fsl_dma_driver);
 }
 
-subsys_initcall(of_fsl_dma_chan_init);
 subsys_initcall(of_fsl_dma_init);

Not a critical problem. But module_init() are preferred for modules.

drivers/dma/fsldma.c static struct of_device_id of_fsl_dma_ids[] = { · line 1036

Quoted 4 lines
drivers/dma/fsldma.c +4 -0
+module_exit(of_fsl_dma_exit);
+
+MODULE_DESCRIPTION("Freescale Elo / Elo Plus DMA driver");
+MODULE_LICENSE("GPL");

- Leo

author
#2 lore raw
Quoted 4 lines · Li Yang
Quoted 2 lines

-subsys_initcall(of_fsl_dma_chan_init);
subsys_initcall(of_fsl_dma_init);

Not a critical problem. But module_init() are preferred for modules.

This was intentional. When compiled as a module, subsys_initcall becomes module_init(). When compiled in-kernel, this code is initialized before most drivers, so it's ready when the drivers are loaded.

Quoted 1 line

Thanks.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#3 lore raw
Quoted 10 lines · Timur Tabi
Quoted 4 lines · Li Yang
Quoted 2 lines

-subsys_initcall(of_fsl_dma_chan_init);
subsys_initcall(of_fsl_dma_init);

Not a critical problem. But module_init() are preferred for modules.

This was intentional. When compiled as a module, subsys_initcall becomes module_init(). When compiled in-kernel, this code is initialized before most drivers, so it's ready when the drivers are loaded.

If there's a dependency there, how will it work when this is built as a module?

-Scott

author
#4 lore raw
Quoted 2 lines · Scott Wood

If there's a dependency there, how will it work when this is built as a module?

There are no dependencies. fsldma registers with the DMA engine, which is always built in-kernel. The DMA engine is what handles linking DMA clients to DMA drivers. The DMA clients get a callback whenever a DMA driver registers with the DMA engine. If the DMA driver is already registered when the client registers, then the client will get a callback immediately after it registers.

I chose subsys_initcall() to increase the probability that fsldma is already present when DMA clients are loaded/initialized and register.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#5 lore raw
Quoted 9 lines · Timur Tabi

There are no dependencies. fsldma registers with the DMA engine, which is always built in-kernel. The DMA engine is what handles linking DMA clients to DMA drivers. The DMA clients get a callback whenever a DMA driver registers with the DMA engine. If the DMA driver is already registered when the client registers, then the client will get a callback immediately after it registers.

I chose subsys_initcall() to increase the probability that fsldma is already present when DMA clients are loaded/initialized and register.

If there's no dependency, why does it matter whether fsldma is already present?

-Scott

author
#6 lore raw
Quoted 5 lines · Scott Wood
Quoted 2 lines

I chose subsys_initcall() to increase the probability that fsldma is already present when DMA clients are loaded/initialized and register.

If there's no dependency, why does it matter whether fsldma is already present?

Re-read my explanation, please. Technically, it doesn't *matter* in that nothing will break, but so what? It's nicer if the DMA driver is already available when the client drivers load, so that they can use the DMA facilities right away.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#7 lore raw
Quoted 7 lines · Timur Tabi
Quoted 3 lines · Scott Wood
Quoted 2 lines

I chose subsys_initcall() to increase the probability that fsldma is already present when DMA clients are loaded/initialized and register.

If there's no dependency, why does it matter whether fsldma is already present?

Re-read my explanation, please.

I read it just fine the first time.

Quoted 4 lines

Technically, it doesn't *matter* in that
nothing will break, but so what? It's nicer if the DMA driver is already available when the client drivers load, so that they can use the DMA facilities right away.

It's not nicer to people reading the code and wondering why, or to people who use it as a module and execute less-well-tested code paths, and I doubt it's a significant addition to boot time to do things in the normal way.

I'm not particularly worried about the code going on strike because we're not being "nice" to it.

-Scott

Applied
#8 lore raw
In reply to Timur Tabi
Quoted 11 lines · Timur Tabi

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(). Instead, the DMA channels are manually probed, similar to what fsl_elbc_nand.c does.

Applied to async_tx.git/next.

--
Dan