diff options
author | Christoph Hellwig <hch@lst.de> | 2019-04-28 15:00:52 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2019-06-25 08:28:06 -0400 |
commit | b1acd4b8a8942f614053e516c56c88e1716562d6 (patch) | |
tree | b8951a3c62f573aa7445bf695a19f66a282fd578 /arch/nios2/mm | |
parent | 6309513c1be47cd3805a6ceae60ab70285df36ae (diff) |
nios2: use the generic uncached segment support in dma-direct
Stop providing our own arch alloc/free hooks and just expose the segment
offset and use the generic dma-direct allocator.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Ley Foon Tan <ley.foon.tan@intel.com>
Diffstat (limited to 'arch/nios2/mm')
-rw-r--r-- | arch/nios2/mm/dma-mapping.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/arch/nios2/mm/dma-mapping.c b/arch/nios2/mm/dma-mapping.c index 4af9e5b5ba1c..9cb238664584 100644 --- a/arch/nios2/mm/dma-mapping.c +++ b/arch/nios2/mm/dma-mapping.c | |||
@@ -60,32 +60,28 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, | |||
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, | 63 | void arch_dma_prep_coherent(struct page *page, size_t size) |
64 | gfp_t gfp, unsigned long attrs) | ||
65 | { | 64 | { |
66 | void *ret; | 65 | unsigned long start = (unsigned long)page_address(page); |
67 | 66 | ||
68 | /* optimized page clearing */ | 67 | flush_dcache_range(start, start + size); |
69 | gfp |= __GFP_ZERO; | 68 | } |
70 | 69 | ||
71 | if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff)) | 70 | void *uncached_kernel_address(void *ptr) |
72 | gfp |= GFP_DMA; | 71 | { |
72 | unsigned long addr = (unsigned long)ptr; | ||
73 | 73 | ||
74 | ret = (void *) __get_free_pages(gfp, get_order(size)); | 74 | addr |= CONFIG_NIOS2_IO_REGION_BASE; |
75 | if (ret != NULL) { | ||
76 | *dma_handle = virt_to_phys(ret); | ||
77 | flush_dcache_range((unsigned long) ret, | ||
78 | (unsigned long) ret + size); | ||
79 | ret = UNCAC_ADDR(ret); | ||
80 | } | ||
81 | 75 | ||
82 | return ret; | 76 | return (void *)ptr; |
83 | } | 77 | } |
84 | 78 | ||
85 | void arch_dma_free(struct device *dev, size_t size, void *vaddr, | 79 | void *cached_kernel_address(void *ptr) |
86 | dma_addr_t dma_handle, unsigned long attrs) | ||
87 | { | 80 | { |
88 | unsigned long addr = (unsigned long) CAC_ADDR((unsigned long) vaddr); | 81 | unsigned long addr = (unsigned long)ptr; |
82 | |||
83 | addr &= ~CONFIG_NIOS2_IO_REGION_BASE; | ||
84 | addr |= CONFIG_NIOS2_KERNEL_REGION_BASE; | ||
89 | 85 | ||
90 | free_pages(addr, get_order(size)); | 86 | return (void *)ptr; |
91 | } | 87 | } |