summaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-06-25 05:01:34 -0400
committerGeert Uytterhoeven <geert@linux-m68k.org>2019-07-01 05:17:00 -0400
commit34dc63a5fb9b7f5dcb49f61552226c6314f347f6 (patch)
tree4be03bb9fe2baeaffa36d75ed60c84d369b99f76 /arch/m68k
parentf67d667213ba03db66230735d354f2a286c1cbda (diff)
m68k: Use the generic dma coherent remap allocator
This switches m68k to using common code for the DMA allocations, including potential use of the CMA allocator if configured. Also add a comment where the existing behavior seems to be lacking. Switching to the generic code enables DMA allocations from atomic context, which is required by the DMA API documentation, and also adds various other minor features drivers start relying upon. It also makes sure we have a tested code base for all architectures that require uncached pte bits for coherent DMA allocations. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/Kconfig2
-rw-r--r--arch/m68k/kernel/dma.c56
2 files changed, 10 insertions, 48 deletions
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 218e037ef901..3a52bf46e043 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -3,10 +3,12 @@ config M68K
3 bool 3 bool
4 default y 4 default y
5 select ARCH_32BIT_OFF_T 5 select ARCH_32BIT_OFF_T
6 select ARCH_HAS_DMA_MMAP_PGPROT if MMU && !COLDFIRE
6 select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA 7 select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
7 select ARCH_MIGHT_HAVE_PC_PARPORT if ISA 8 select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
8 select ARCH_NO_COHERENT_DMA_MMAP if !MMU 9 select ARCH_NO_COHERENT_DMA_MMAP if !MMU
9 select ARCH_NO_PREEMPT if !COLDFIRE 10 select ARCH_NO_PREEMPT if !COLDFIRE
11 select DMA_DIRECT_REMAP if HAS_DMA && MMU && !COLDFIRE
10 select HAVE_IDE 12 select HAVE_IDE
11 select HAVE_AOUT if MMU 13 select HAVE_AOUT if MMU
12 select HAVE_DEBUG_BUGVERBOSE 14 select HAVE_DEBUG_BUGVERBOSE
diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
index b4aa853051bd..e7bf355589e7 100644
--- a/arch/m68k/kernel/dma.c
+++ b/arch/m68k/kernel/dma.c
@@ -18,57 +18,17 @@
18#include <asm/pgalloc.h> 18#include <asm/pgalloc.h>
19 19
20#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE) 20#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
21 21pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot,
22void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, 22 unsigned long attrs)
23 gfp_t flag, unsigned long attrs)
24{ 23{
25 struct page *page, **map; 24 if (CPU_IS_040_OR_060) {
26 pgprot_t pgprot; 25 pgprot_val(prot) &= ~_PAGE_CACHE040;
27 void *addr; 26 pgprot_val(prot) |= _PAGE_GLOBAL040 | _PAGE_NOCACHE_S;
28 int i, order; 27 } else {
29 28 pgprot_val(prot) |= _PAGE_NOCACHE030;
30 pr_debug("dma_alloc_coherent: %d,%x\n", size, flag);
31
32 size = PAGE_ALIGN(size);
33 order = get_order(size);
34
35 page = alloc_pages(flag | __GFP_ZERO, order);
36 if (!page)
37 return NULL;
38
39 *handle = page_to_phys(page);
40 map = kmalloc(sizeof(struct page *) << order, flag & ~__GFP_DMA);
41 if (!map) {
42 __free_pages(page, order);
43 return NULL;
44 } 29 }
45 split_page(page, order); 30 return prot;
46
47 order = 1 << order;
48 size >>= PAGE_SHIFT;
49 map[0] = page;
50 for (i = 1; i < size; i++)
51 map[i] = page + i;
52 for (; i < order; i++)
53 __free_page(page + i);
54 pgprot = __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY);
55 if (CPU_IS_040_OR_060)
56 pgprot_val(pgprot) |= _PAGE_GLOBAL040 | _PAGE_NOCACHE_S;
57 else
58 pgprot_val(pgprot) |= _PAGE_NOCACHE030;
59 addr = vmap(map, size, VM_MAP, pgprot);
60 kfree(map);
61
62 return addr;
63} 31}
64
65void arch_dma_free(struct device *dev, size_t size, void *addr,
66 dma_addr_t handle, unsigned long attrs)
67{
68 pr_debug("dma_free_coherent: %p, %x\n", addr, handle);
69 vfree(addr);
70}
71
72#else 32#else
73 33
74#include <asm/cacheflush.h> 34#include <asm/cacheflush.h>