From d1401e1dc22606a91f577ad3dfd68ae7e60e0357 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 16 Jun 2010 09:12:10 +0000 Subject: Blackfin: fix DMA/cache bug when resuming from suspend to RAM The dma_memcpy() function takes care of flushing different caches for us. Normally this is what we want, but when resuming from mem, we don't yet have caches enabled. If these functions happen to be placed into L1 mem (which is what we're trying to relocate), then things aren't going to work. So define a non-cache dma_memcpy() variant to utilize in situations like this. Signed-off-by: Michael Hennerich Signed-off-by: Mike Frysinger --- arch/blackfin/kernel/bfin_dma_5xx.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'arch/blackfin/kernel/bfin_dma_5xx.c') diff --git a/arch/blackfin/kernel/bfin_dma_5xx.c b/arch/blackfin/kernel/bfin_dma_5xx.c index 26403d1c9e6..1e485dfdc9f 100644 --- a/arch/blackfin/kernel/bfin_dma_5xx.c +++ b/arch/blackfin/kernel/bfin_dma_5xx.c @@ -450,7 +450,6 @@ void *dma_memcpy(void *pdst, const void *psrc, size_t size) { unsigned long dst = (unsigned long)pdst; unsigned long src = (unsigned long)psrc; - size_t bulk, rest; if (bfin_addr_dcacheable(src)) blackfin_dcache_flush_range(src, src + size); @@ -458,6 +457,22 @@ void *dma_memcpy(void *pdst, const void *psrc, size_t size) if (bfin_addr_dcacheable(dst)) blackfin_dcache_invalidate_range(dst, dst + size); + return dma_memcpy_nocache(pdst, psrc, size); +} +EXPORT_SYMBOL(dma_memcpy); + +/** + * dma_memcpy_nocache - DMA memcpy under mutex lock + * - No cache flush/invalidate + * + * Do not check arguments before starting the DMA memcpy. Break the transfer + * up into two pieces. The first transfer is in multiples of 64k and the + * second transfer is the piece smaller than 64k. + */ +void *dma_memcpy_nocache(void *pdst, const void *psrc, size_t size) +{ + size_t bulk, rest; + bulk = size & ~0xffff; rest = size - bulk; if (bulk) @@ -465,7 +480,7 @@ void *dma_memcpy(void *pdst, const void *psrc, size_t size) _dma_memcpy(pdst + bulk, psrc + bulk, rest); return pdst; } -EXPORT_SYMBOL(dma_memcpy); +EXPORT_SYMBOL(dma_memcpy_nocache); /** * safe_dma_memcpy - DMA memcpy w/argument checking -- cgit v1.2.3-70-g09d2