Commit b1acd4b8 authored by Christoph Hellwig's avatar Christoph Hellwig

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: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarLey Foon Tan <ley.foon.tan@intel.com>
parent 6309513c
...@@ -4,6 +4,7 @@ config NIOS2 ...@@ -4,6 +4,7 @@ config NIOS2
select ARCH_32BIT_OFF_T select ARCH_32BIT_OFF_T
select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_HAS_UNCACHED_SEGMENT
select ARCH_NO_SWAP select ARCH_NO_SWAP
select TIMER_OF select TIMER_OF
select GENERIC_ATOMIC64 select GENERIC_ATOMIC64
......
...@@ -101,12 +101,6 @@ static inline bool pfn_valid(unsigned long pfn) ...@@ -101,12 +101,6 @@ static inline bool pfn_valid(unsigned long pfn)
# define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \ # define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
# define UNCAC_ADDR(addr) \
((void *)((unsigned)(addr) | CONFIG_NIOS2_IO_REGION_BASE))
# define CAC_ADDR(addr) \
((void *)(((unsigned)(addr) & ~CONFIG_NIOS2_IO_REGION_BASE) | \
CONFIG_NIOS2_KERNEL_REGION_BASE))
#include <asm-generic/memory_model.h> #include <asm-generic/memory_model.h>
#include <asm-generic/getorder.h> #include <asm-generic/getorder.h>
......
...@@ -60,32 +60,28 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, ...@@ -60,32 +60,28 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
} }
} }
void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, void arch_dma_prep_coherent(struct page *page, size_t size)
gfp_t gfp, unsigned long attrs)
{ {
void *ret; unsigned long start = (unsigned long)page_address(page);
/* optimized page clearing */ flush_dcache_range(start, start + size);
gfp |= __GFP_ZERO; }
if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff)) void *uncached_kernel_address(void *ptr)
gfp |= GFP_DMA; {
unsigned long addr = (unsigned long)ptr;
ret = (void *) __get_free_pages(gfp, get_order(size)); addr |= CONFIG_NIOS2_IO_REGION_BASE;
if (ret != NULL) {
*dma_handle = virt_to_phys(ret);
flush_dcache_range((unsigned long) ret,
(unsigned long) ret + size);
ret = UNCAC_ADDR(ret);
}
return ret; return (void *)ptr;
} }
void arch_dma_free(struct device *dev, size_t size, void *vaddr, void *cached_kernel_address(void *ptr)
dma_addr_t dma_handle, unsigned long attrs)
{ {
unsigned long addr = (unsigned long) CAC_ADDR((unsigned long) vaddr); unsigned long addr = (unsigned long)ptr;
addr &= ~CONFIG_NIOS2_IO_REGION_BASE;
addr |= CONFIG_NIOS2_KERNEL_REGION_BASE;
free_pages(addr, get_order(size)); return (void *)ptr;
} }
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