Skip to contentSkip to conversation

DMAENGINE: driver for the ARM PL080/PL081 PrimeCells

PATCH In review Linus Walleij 6 participants 13 messages Jun 29, 2010 – Aug 9, 2010 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 DMAENGINE: driver for the ARM PL080/PL081 PrimeCells

This creates a DMAengine driver for the ARM PL080/PL081 PrimeCells based on the implementation earlier submitted by Peter Pearse. This is working like a charm for memcpy and slave DMA to the PL011 PrimeCell on the PB11MPCore.

This DMA controller is used in mostly unmodified form in the ARM RealView and Versatile platforms, in the ST-Ericsson Nomadik, and in the ST SPEAr platform.

It has been converted to use the header from the Samsung PL080 derivate instead of its own defintions. The Samsungs have a custom driver in their mach-* folders though, atleast we can share the register definitions.

Cc Peter Pearse <[email protected]>
Cc Ben Dooks <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Alessandro Rubini <[email protected]>
Cc Viresh Kumar <[email protected]>

---
Changes since last revision: this has now been successfully tested with PL011 UART on the PB11MPCore.

It now uses the generic runtime slave control and not the PrimeCell extensions, and thus depends only on that patch set. With the previous patch to the header file this is cleanly separated from the ARM tree and any PrimeCell drivers and can go into the async_tx tree as it is without further dependencies.

---
 drivers/dma/Kconfig        |    8 +
 drivers/dma/Makefile       |    1 +
 drivers/dma/amba-pl08x.c   | 2027 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/amba/pl08x.h |  183 ++++
 4 files changed, 2219 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dma/amba-pl08x.c
 create mode 100644 include/linux/amba/pl08x.h
drivers/dma/Kconfig +8 -0
index 8344375..8acb284 100644
@@ -36,6 +36,14 @@ comment "DMA Devices"
 config ASYNC_TX_DISABLE_CHANNEL_SWITCH
 	bool
 
+config AMBA_PL08X
+	bool "ARM PrimeCell PL080 or PL081 support"
+	depends on ARM_AMBA && EXPERIMENTAL
+	select DMA_ENGINE
+	help
+	  Platform has a PL08x DMAC device
+	  which can provide DMA engine support
+
 config INTEL_IOATDMA
 	tristate "Intel I/OAT DMA support"
 	depends on PCI && X86
drivers/dma/Makefile +1 -0
index 0fe5ebb..c51dbc8 100644
@@ -23,3 +23,4 @@ obj-$(CONFIG_AMCC_PPC440SPE_ADMA) += ppc4xx/
 obj-$(CONFIG_TIMB_DMA) += timb_dma.o
 obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o
 obj-$(CONFIG_PL330_DMA) += pl330.o
+obj-$(CONFIG_AMBA_PL08X) += amba-pl08x.o
drivers/dma/amba-pl08x.c new file +2027 -0

2,027 lines not on this page · raw message

include/linux/amba/pl08x.h new file +183 -0

183 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#1 lore raw
Quoted 24 lines · Linus Walleij

This creates a DMAengine driver for the ARM PL080/PL081 PrimeCells based on the implementation earlier submitted by Peter Pearse. This is working like a charm for memcpy and slave DMA to the PL011 PrimeCell on the PB11MPCore.

This DMA controller is used in mostly unmodified form in the ARM RealView and Versatile platforms, in the ST-Ericsson Nomadik, and in the ST SPEAr platform.

It has been converted to use the header from the Samsung PL080 derivate instead of its own defintions. The Samsungs have a custom driver in their mach-* folders though, atleast we can share the register definitions.

Cc Peter Pearse <[email protected]>
Cc Ben Dooks <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Alessandro Rubini <[email protected]>
Cc Viresh Kumar <[email protected]>

---
Changes since last revision: this has now been successfully tested with PL011 UART on the PB11MPCore.

Quoted 6 lines

It now uses the generic runtime slave control and not the PrimeCell extensions, and thus depends only on that patch set. With the previous patch to the header file this is cleanly separated from the ARM tree and any PrimeCell drivers and can go into the async_tx tree as it is without further dependencies.
---

Russell I am assuming this implementation and testing is sufficient to allay your prior nak [1]? Linus is oversubscribing virtual channels to physical channels to handle muxing.

drivers/dma/amba-pl08x.c line 141

Quoted 11 lines
drivers/dma/amba-pl08x.c new file +11 -0
+#ifdef MODULE
+
+# error "AMBA PL08X DMA CANNOT BE COMPILED AS A LOADABLE MODULE AT PRESENT"
+
+/*
+       a) Some devices might make use of DMA during boot
+          (esp true for DMAENGINE implementation)
+       b) Memory allocation will need much more attention
+          before load/unload can be supported
+ */
+#endif

This is taken care of by being "config bool", but I assume you want this for documentation purposes?

Quoted 1 line

+ txd = kzalloc(sizeof(struct pl08x_txd), GFP_KERNEL);

...appears in the prep routines. Will this driver be used by any storage controllers on the platfom? Might we deadlock waiting on i/o that needs to allocate a descriptor to complete?

--
Dan

[1]: http://marc.info/?l=linux-arm-kernel&m=127350477914098&w=2

#2 lore raw

2010/7/28 Dan Williams <[email protected]>:

Quoted 10 lines
Quoted 4 lines · Linus Walleij

This creates a DMAengine driver for the ARM PL080/PL081 PrimeCells based on the implementation earlier submitted by Peter Pearse. This is working like a charm for memcpy and slave DMA to the PL011 PrimeCell on the PB11MPCore.

Russell I am assuming this implementation and testing is sufficient to allay your prior nak [1]? ?Linus is oversubscribing virtual channels to physical channels to handle muxing.

I don't think Russell has ever NAK:ed the PL08x driver(s). The NAK was about the PrimeCell DMA extenstions to amba-pl011.c etc. (Still I'm happy if Russell looks at this thing of course.)

This patch along with the generic channel control removed the cross-dependency between the PrimeCell DMA patchset and the drivers/dma DMA engine framework (yay!) so there is no arch/arm or AMBA stuff involved anymore, other than the fact that this driver sits on the AMBA/PrimeCell bus.

Quoted 6 lines
Quoted 6 lines
drivers/dma/amba-pl08x.c new file +6 -0
+#ifdef MODULE
+
+# error "AMBA PL08X DMA CANNOT BE COMPILED AS A LOADABLE MODULE AT PRESENT"
+
+/*
+ ? ? ? a) Some devices might make use of DMA during boot
Quoted 8 lines
Quoted 5 lines

+ ? ? ? ? ?(esp true for DMAENGINE implementation)
+ ? ? ? b) Memory allocation will need much more attention
+ ? ? ? ? ?before load/unload can be supported
+ */
+#endif

This is taken care of by being "config bool", but I assume you want this for documentation purposes?

Peter had that in and I didn't remove it. If you don't like it you can remove it or I can send a new patch.

Quoted 5 lines
Quoted 1 line

+ ? ? ? txd = kzalloc(sizeof(struct pl08x_txd), GFP_KERNEL);

...appears in the prep routines. ?Will this driver be used by any storage controllers on the platfom? ?Might we deadlock waiting on i/o that needs to allocate a descriptor to complete?

I haven't noticed anything but a descriptor pool is on my list of things to look into and fix.

Yours,
Linus Walleij

#3 lore raw
Quoted 9 lines · Linus Walleij

2010/7/28 Dan Williams <[email protected]>:

Quoted 5 lines
Quoted 1 line

+ ? ? ? txd = kzalloc(sizeof(struct pl08x_txd), GFP_KERNEL);

...appears in the prep routines. ?Will this driver be used by any storage controllers on the platfom? ?Might we deadlock waiting on i/o that needs to allocate a descriptor to complete?

I haven't noticed anything but a descriptor pool is on my list of things to look into and fix.

If there is a list of things to fix and no acked-by's from anyone on the cc list I assume you want to wait for 2.6.37?? I'm sending the dmaengine/async_tx pull request this Friday.

--
Dan

#4 lore raw

2010/8/4 Dan Williams <[email protected]>:

Quoted 3 lines

If there is a list of things to fix and no acked-by's from anyone on the cc list I assume you want to wait for 2.6.37?? ?I'm sending the dmaengine/async_tx pull request this Friday.

There are no blockers for merging this AFAICT, but some ACK:s would be nice of course.

Peter, Alessandro and Viresh especially: you will hopefully use this driver for ARM refboards, Nomadik and SPEAr, can you provide an Acked-by:?

Yours,
Linus Walleij

#5 lore raw
Quoted 3 lines

Peter, Alessandro and Viresh especially: you will hopefully use this driver for ARM refboards, Nomadik and SPEAr, can you provide an Acked-by:?

I'm sorry I can't test it these times, I must delay stuff to the last week of August.

/alessandro

#6 lore raw

2010/8/5 Alessandro Rubini <[email protected]>:

Quoted 6 lines
Quoted 3 lines

Peter, Alessandro and Viresh especially: you will hopefully use this driver for ARM refboards, Nomadik and SPEAr, can you provide an Acked-by:?

I'm sorry I can't test it these times, I must delay stuff to the last week of August.

That's be a Tested-by: tag, Acked-by: was more about whether you think it looks sane I believe, see Documentation/SubmittingPatches.

Yours,
Linus Walleij

#7 lore raw
Quoted 11 lines · Linus Walleij

2010/8/5 Alessandro Rubini <[email protected]>:

Quoted 6 lines
Quoted 3 lines

Peter, Alessandro and Viresh especially: you will hopefully use this driver for ARM refboards, Nomadik and SPEAr, can you provide an Acked-by:?

I'm sorry I can't test it these times, I must delay stuff to the last week of August.

That's be a Tested-by: tag, Acked-by: was more about whether you think it looks sane I believe, see Documentation/SubmittingPatches.

We have the Acked-by from Viresh, Alessandro looks like he is interested in trying it out, the driver is self contained, marked experimental, and you have a track-record of fixing things up, so I'll include it with the idea it will be easier to fixup in-tree. One thing that should be on the todo list is to review the usage of memory barriers. I don't think they are serving the purpose that you think they are. For example in pl08x_irq() there is:

+ /*
+ * Clear only the terminal interrupts on channels we processed
+ */
+ writel(mask, pl08x->base + PL080_TC_CLEAR);
+ mb();
+
+ return mask ? IRQ_HANDLED : IRQ_NONE;

Which seems to imply you want to ensure the interrupt bits are cleared before the handler returns. But the only way you can guarantee that the write has actually taken effect is to read back the register. Does the amba bus interface make this guarantee with a barrier? If so then we need a comment about why we need a full barrier versus just a wmb()?

+static void pl08x_pause_phy_chan(struct pl08x_phy_chan *ch) +{
+ u32 val;
+

+       /* Set the HALT bit and wait for the FIFO to drain */
+       val = readl(ch->base + PL080_CH_CONFIG);
+       val |= PL080_CONFIG_HALT;
+       writel(val, ch->base + PL080_CH_CONFIG);

+
+ /* Wait for channel inactive */
+ while (pl08x_phy_channel_busy(ch))
+ ;
+ mb();
+}

Doesn't the while loop guarantee that the write has taken effect?

+static void pl08x_ensure_on(struct pl08x_driver_data *pl08x) +{
+ u32 val;
+

+       val = readl(pl08x->base + PL080_CONFIG);
+       val &= ~(PL080_CONFIG_M2_BE | PL080_CONFIG_M1_BE | PL080_CONFIG_ENABLE);
+       /* We implictly clear bit 1 and that means little-endian mode */
+       val |= PL080_CONFIG_ENABLE;
+       mb();
+       writel(val, pl08x->base + PL080_CONFIG);
+       mb();

+}

This almost looks like you are using mb() as a compiler barrier, but that is taken care of by readl / writel. Speaking of which is amba always little-endian, should we instead be using __raw_{read|write}l in this driver?

--
Dan

#8 lore raw
Quoted 11 lines · Dan Williams
Quoted 9 lines · Linus Walleij

2010/8/5 Alessandro Rubini <[email protected]>:

Quoted 6 lines
Quoted 3 lines

Peter, Alessandro and Viresh especially: you will hopefully use this driver for ARM refboards, Nomadik and SPEAr, can you provide an Acked-by:?

I'm sorry I can't test it these times, I must delay stuff to the last week of August.

Quoted 7 lines
Quoted 2 lines

That's be a Tested-by: tag, Acked-by: was more about whether you think it looks sane I believe, see Documentation/SubmittingPatches.

We have the Acked-by from Viresh, Alessandro looks like he is interested in trying it out, the driver is self contained, marked experimental, and you have a track-record of fixing things up, so I'll include it with the idea it will be easier to fixup in-tree.

...except this version no longer compiles:

drivers/dma/amba-pl08x.c: In function 'dma_set_runtime_config':
drivers/dma/amba-pl08x.c:1399: error: 'struct dma_slave_config' has no member named 'maxburst'
drivers/dma/amba-pl08x.c:1405: error: 'struct dma_slave_config' has no member named 'addr'
drivers/dma/amba-pl08x.c:1408: error: 'struct dma_slave_config' has no member named 'addr_width'
drivers/dma/amba-pl08x.c:1464: error: 'struct dma_slave_config' has no member named 'addr_width'
drivers/dma/amba-pl08x.c:1464: error: 'struct dma_slave_config' has no member named 'maxburst'

Fix that up and we can try to get it in the second half of the merge window.

--
Dan

#9 lore raw

2010/8/6 Dan Williams <[email protected]>:

Quoted 1 line

...except this version no longer compiles:

Hm the v3 version works fine with me, but anyway, I mailed out a v4 that also removes the unneeded mb() macros.

Quoted 1 line

Fix that up and we can try to get it in the second half of the merge window.

Great, thanks.

I'll work on getting this in place to run with the PrimeCell extensions and proof-of-concept for ARM RealView reference designs next.

Yours,
Linus Walleij

#10 lore raw
In reply to Dan Williams

2010/8/6 Dan Williams <[email protected]>:

Quoted 4 lines

?One
thing that should be on the todo list is to review the usage of memory barriers. ?I don't think they are serving the purpose that you think they are.

All of those are from Peters original implementation, I never use any barriers so they actually looked alien to me. Unless I get a clear rationale from Peter I'll just remove them all for the time being in the fix-up version due after updating to generic slave control.

Yours,
Linus Walleij

#11 lore raw

PATCH 2/2 DMAENGINE: driver for the ARM PL080/PL081 PrimeCells

Linus

Barriers probably just me being ultra cautious

Given you've tested on multicore, feel free to remove them

Peter

Quoted 29 lines

-----Original Message-----
From: Linus Walleij [mailto:linus.ml.walleij at gmail.com]
Sent: 06 August 2010 23:55
To: Dan Williams
Cc: Alessandro Rubini; Peter Pearse; viresh.kumar at st.com; linux-arm-kernel at lists.infradead.org;
linux-kernel at vger.kernel.org; yuanyabin1978 at sina.com; ben-linux at fluff.org; kgene.kim at samsung.com; rmk at arm.linux.org.uk
Subject: Re: [PATCH 2/2] DMAENGINE: driver for the ARM PL080/PL081 PrimeCells

2010/8/6 Dan Williams <[email protected]>:

Quoted 2 lines

?One
thing that should be on the todo list is to review the

usage of memory

Quoted 1 line

barriers. ?I don't think they are serving the purpose that

you think

Quoted 1 line

they are.

All of those are from Peters original implementation, I never use any barriers so they actually looked alien to me. Unless I get a clear rationale from Peter I'll just remove them all for the time being in the fix-up version due after updating to generic slave control.

Yours,
Linus Walleij

Acked-by on v1 2/2
#12 lore raw
In reply to Linus Walleij
Quoted 30 lines · Linus Walleij

This creates a DMAengine driver for the ARM PL080/PL081 PrimeCells based on the implementation earlier submitted by Peter Pearse. This is working like a charm for memcpy and slave DMA to the PL011 PrimeCell on the PB11MPCore.

This DMA controller is used in mostly unmodified form in the ARM RealView and Versatile platforms, in the ST-Ericsson Nomadik, and in the ST SPEAr platform.

It has been converted to use the header from the Samsung PL080 derivate instead of its own defintions. The Samsungs have a custom driver in their mach-* folders though, atleast we can share the register definitions.

Cc Peter Pearse <[email protected]>
Cc Ben Dooks <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Alessandro Rubini <[email protected]>
Cc Viresh Kumar <[email protected]>

---
Changes since last revision: this has now been successfully tested with PL011 UART on the PB11MPCore.

It now uses the generic runtime slave control and not the PrimeCell extensions, and thus depends only on that patch set. With the previous patch to the header file this is cleanly separated from the ARM tree and any PrimeCell drivers and can go into the async_tx tree as it is without further dependencies.
---

Quoted 8 lines
?drivers/dma/Kconfig ? ? ? ?| ? ?8 +
?drivers/dma/Makefile ? ? ? | ? ?1 +
?drivers/dma/amba-pl08x.c ? | 2027 ++++++++++++++++++++++++++++++++++++++++++++
?include/linux/amba/pl08x.h | ?183 ++++

?4 files changed, 2219 insertions(+), 0 deletions(-) ?create mode 100644 drivers/dma/amba-pl08x.c ?create mode 100644 include/linux/amba/pl08x.h

regards,
viresh.