Commit 2d645604 authored by Manuel Lauss's avatar Manuel Lauss Committed by Thomas Bogendoerfer

MIPS: Alchemy: fix dbdma2

Various fixes for the Au1200/Au1550/Au1300 DBDMA2 code:

- skip cache invalidation if chip has working coherency circuitry.
- invalidate KSEG0-portion of the (physical) data address.
- force the dma channel doorbell write out to bus immediately with
  a sync.
Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
parent f2041708
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
* *
*/ */
#include <linux/dma-map-ops.h> /* for dma_default_coherent */
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -623,17 +624,18 @@ u32 au1xxx_dbdma_put_source(u32 chanid, dma_addr_t buf, int nbytes, u32 flags) ...@@ -623,17 +624,18 @@ u32 au1xxx_dbdma_put_source(u32 chanid, dma_addr_t buf, int nbytes, u32 flags)
dp->dscr_cmd0 &= ~DSCR_CMD0_IE; dp->dscr_cmd0 &= ~DSCR_CMD0_IE;
/* /*
* There is an errata on the Au1200/Au1550 parts that could result * There is an erratum on certain Au1200/Au1550 revisions that could
* in "stale" data being DMA'ed. It has to do with the snoop logic on * result in "stale" data being DMA'ed. It has to do with the snoop
* the cache eviction buffer. DMA_NONCOHERENT is on by default for * logic on the cache eviction buffer. dma_default_coherent is set
* these parts. If it is fixed in the future, these dma_cache_inv will * to false on these parts.
* just be nothing more than empty macros. See io.h.
*/ */
dma_cache_wback_inv((unsigned long)buf, nbytes); if (!dma_default_coherent)
dma_cache_wback_inv(KSEG0ADDR(buf), nbytes);
dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
wmb(); /* drain writebuffer */ wmb(); /* drain writebuffer */
dma_cache_wback_inv((unsigned long)dp, sizeof(*dp)); dma_cache_wback_inv((unsigned long)dp, sizeof(*dp));
ctp->chan_ptr->ddma_dbell = 0; ctp->chan_ptr->ddma_dbell = 0;
wmb(); /* force doorbell write out to dma engine */
/* Get next descriptor pointer. */ /* Get next descriptor pointer. */
ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
...@@ -685,17 +687,18 @@ u32 au1xxx_dbdma_put_dest(u32 chanid, dma_addr_t buf, int nbytes, u32 flags) ...@@ -685,17 +687,18 @@ u32 au1xxx_dbdma_put_dest(u32 chanid, dma_addr_t buf, int nbytes, u32 flags)
dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1); dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1);
#endif #endif
/* /*
* There is an errata on the Au1200/Au1550 parts that could result in * There is an erratum on certain Au1200/Au1550 revisions that could
* "stale" data being DMA'ed. It has to do with the snoop logic on the * result in "stale" data being DMA'ed. It has to do with the snoop
* cache eviction buffer. DMA_NONCOHERENT is on by default for these * logic on the cache eviction buffer. dma_default_coherent is set
* parts. If it is fixed in the future, these dma_cache_inv will just * to false on these parts.
* be nothing more than empty macros. See io.h.
*/ */
dma_cache_inv((unsigned long)buf, nbytes); if (!dma_default_coherent)
dma_cache_inv(KSEG0ADDR(buf), nbytes);
dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
wmb(); /* drain writebuffer */ wmb(); /* drain writebuffer */
dma_cache_wback_inv((unsigned long)dp, sizeof(*dp)); dma_cache_wback_inv((unsigned long)dp, sizeof(*dp));
ctp->chan_ptr->ddma_dbell = 0; ctp->chan_ptr->ddma_dbell = 0;
wmb(); /* force doorbell write out to dma engine */
/* Get next descriptor pointer. */ /* Get next descriptor pointer. */
ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment