diff options
author | Sam Nelson <sam.nelson@ti.com> | 2016-09-07 12:49:57 -0400 |
---|---|---|
committer | Sam Nelson <sam.nelson@ti.com> | 2016-09-07 13:08:27 -0400 |
commit | 6fe825e95c50e603c3981400cc823e11f145eea8 (patch) | |
tree | fd75cb5a815f369fff9ef4bee8f6511cd844f2d1 | |
parent | 1e3b0b5fc9e12211d92a7c6d9ff3834e4d578e73 (diff) | |
download | linuxutils-6fe825e95c50e603c3981400cc823e11f145eea8.tar.gz |
cmemk: Update to use local assembly for cache operations
dmac_map_area and associated assembly functions are no longer available
for use in kernel modules in kernel version >= 4.4 and there are no
equivalent higher level function available for cache operations.
Use of dma_sync_single* function creates additional issues with address
translation and does not really solve the problem for memory range > 4
GB and hence reverting back that change.
Reverting back to local assembly functions. Modified code to add
local functions for all kernels versions where dmac_map_area is not
available.
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
-rw-r--r-- | src/cmem/module/cmemk.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/cmem/module/cmemk.c b/src/cmem/module/cmemk.c index 0942c29..dc01f02 100644 --- a/src/cmem/module/cmemk.c +++ b/src/cmem/module/cmemk.c @@ -236,6 +236,13 @@ static struct device *cmem_cma_dev_0; #define KEYSTONE_DMA_PFN_OFFSET 0x780000UL #endif +#if !defined(dmac_map_area) +#if !defined(MULTI_CACHE) +/* Add prototypes for dmac_map_area */ +#define dmac_map_area __glue(_CACHE,_dma_map_area) +void dmac_map_area(const void *, size_t, int); +#endif +#endif /* * For CMA allocations we treat p_objs[NBLOCKS] as a special "pool" array. */ @@ -1426,10 +1433,8 @@ alloc: * HeapMem_free() */ virtp_end = virtp + size; - dma_sync_single_for_cpu(dev, - virt_to_dma(dev, virtp), - size, DMA_FROM_DEVICE); - + outer_inv_range(physp, physp + size); + dmac_map_area(virtp, size, DMA_FROM_DEVICE); __D("FREEHEAP: invalidated user virtual " "0x%p -> 0x%p\n", virtp, virtp_end); } @@ -1698,30 +1703,25 @@ alloc: switch (cmd & ~CMEM_IOCMAGIC) { case CMEM_IOCCACHEWB: - dma_sync_single_for_device(dev, - virt_to_dma(dev, virtp), - block.size, DMA_TO_DEVICE); + dmac_map_area(virtp, block.size, DMA_TO_DEVICE); + outer_clean_range(physp, physp + block.size); __D("CACHEWB: cleaned user virtual 0x%p -> 0x%p\n", virtp, virtp_end); break; case CMEM_IOCCACHEINV: - dma_sync_single_for_cpu(dev, - virt_to_dma(dev, virtp), - block.size, DMA_FROM_DEVICE); - + outer_inv_range(physp, physp + block.size); + dmac_map_area(virtp, block.size, DMA_FROM_DEVICE); __D("CACHEINV: invalidated user virtual 0x%p -> 0x%p\n", virtp, virtp_end); break; case CMEM_IOCCACHEWBINV: - dma_sync_single_for_cpu(dev, - virt_to_dma(dev, virtp), - block.size, DMA_BIDIRECTIONAL); - + __cpuc_flush_dcache_area(virtp, size); + outer_flush_range(physp, physp + block.size); __D("CACHEWBINV: flushed user virtual 0x%p -> 0x%p\n", virtp, virtp_end); @@ -2627,12 +2627,11 @@ MODULE_LICENSE("GPL"); module_init(cmem_init); module_exit(cmem_exit); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0) +#if !defined(dmac_map_range) #if !defined(MULTI_CACHE) -#warning "MULTI_CACHE is *not* #defined, using work-around for asm cache functions" +//#warning "dmac_map_range is *not* #defined, using work-around for asm cache functions" #ifdef CONFIG_CPU_ARM926T @@ -2889,4 +2888,4 @@ v7_dma_unmap_area:\n \ #endif /* !defined(MULTI_CACHE) */ -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0) */ +#endif /* dmac_map_range */
\ No newline at end of file |