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 <peter.pearse@arm.com> Cc: Ben Dooks <ben-linux@fluff.org> Cc: Kukjin Kim <kgene.kim@samsung.com> Cc: Alessandro Rubini <rubini@unipv.it> Cc: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Linus Walleij <linus.walleij@stericsson.com> --- 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 diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 8344375..8acb284 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -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 ...
On Tue, Jun 29, 2010 at 4:36 AM, Linus Walleij Russell I am assuming this implementation and testing is sufficient to allay your prior nak [1]? Linus is oversubscribing virtual channels This is taken care of by being "config bool", but I assume you want ...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 --
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 Peter had that in and I didn't remove it. If you don't like it you I haven't noticed anything but a descriptor pool is on my list of things to look into and fix. Yours, Linus Walleij --
On Wed, Jul 28, 2010 at 4:12 PM, Linus Walleij 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 --
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 --
I'm sorry I can't test it these times, I must delay stuff to the last week of August. /alessandro --
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 --
On Thu, Aug 5, 2010 at 12:30 AM, Linus Walleij
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 ......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 --
Hm the v3 version works fine with me, but anyway, I mailed out a v4 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 --
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 --
On Tue, Jun 29, 2010 at 5:06 PM, Linus Walleij Acked-by: Viresh Kumar <viresh.kumar@st.com> regards, viresh. --
