Skip to content

Commit 2d64560

Browse files
mlauss2tsbogend
authored andcommitted
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: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent f204170 commit 2d64560

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

arch/mips/alchemy/common/dbdma.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
*/
3232

33+
#include <linux/dma-map-ops.h> /* for dma_default_coherent */
3334
#include <linux/init.h>
3435
#include <linux/kernel.h>
3536
#include <linux/slab.h>
@@ -623,17 +624,18 @@ u32 au1xxx_dbdma_put_source(u32 chanid, dma_addr_t buf, int nbytes, u32 flags)
623624
dp->dscr_cmd0 &= ~DSCR_CMD0_IE;
624625

625626
/*
626-
* There is an errata on the Au1200/Au1550 parts that could result
627-
* in "stale" data being DMA'ed. It has to do with the snoop logic on
628-
* the cache eviction buffer. DMA_NONCOHERENT is on by default for
629-
* these parts. If it is fixed in the future, these dma_cache_inv will
630-
* just be nothing more than empty macros. See io.h.
627+
* There is an erratum on certain Au1200/Au1550 revisions that could
628+
* result in "stale" data being DMA'ed. It has to do with the snoop
629+
* logic on the cache eviction buffer. dma_default_coherent is set
630+
* to false on these parts.
631631
*/
632-
dma_cache_wback_inv((unsigned long)buf, nbytes);
632+
if (!dma_default_coherent)
633+
dma_cache_wback_inv(KSEG0ADDR(buf), nbytes);
633634
dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
634635
wmb(); /* drain writebuffer */
635636
dma_cache_wback_inv((unsigned long)dp, sizeof(*dp));
636637
ctp->chan_ptr->ddma_dbell = 0;
638+
wmb(); /* force doorbell write out to dma engine */
637639

638640
/* Get next descriptor pointer. */
639641
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)
685687
dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1);
686688
#endif
687689
/*
688-
* There is an errata on the Au1200/Au1550 parts that could result in
689-
* "stale" data being DMA'ed. It has to do with the snoop logic on the
690-
* cache eviction buffer. DMA_NONCOHERENT is on by default for these
691-
* parts. If it is fixed in the future, these dma_cache_inv will just
692-
* be nothing more than empty macros. See io.h.
690+
* There is an erratum on certain Au1200/Au1550 revisions that could
691+
* result in "stale" data being DMA'ed. It has to do with the snoop
692+
* logic on the cache eviction buffer. dma_default_coherent is set
693+
* to false on these parts.
693694
*/
694-
dma_cache_inv((unsigned long)buf, nbytes);
695+
if (!dma_default_coherent)
696+
dma_cache_inv(KSEG0ADDR(buf), nbytes);
695697
dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
696698
wmb(); /* drain writebuffer */
697699
dma_cache_wback_inv((unsigned long)dp, sizeof(*dp));
698700
ctp->chan_ptr->ddma_dbell = 0;
701+
wmb(); /* force doorbell write out to dma engine */
699702

700703
/* Get next descriptor pointer. */
701704
ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));

0 commit comments

Comments
 (0)