Skip to content

Commit

Permalink
c6x: use generic dma_noncoherent_ops
Browse files Browse the repository at this point in the history
Switch to the generic noncoherent direct mapping implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Mark Salter <msalter@redhat.com>
  • Loading branch information
Christoph Hellwig committed May 19, 2018
1 parent 6c3e71d commit 7f5c1ea
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 170 deletions.
3 changes: 3 additions & 0 deletions arch/c6x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

config C6X
def_bool y
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select CLKDEV_LOOKUP
select DMA_NONCOHERENT_OPS
select GENERIC_ATOMIC64
select GENERIC_IRQ_SHOW
select HAVE_ARCH_TRACEHOOK
Expand Down
1 change: 1 addition & 0 deletions arch/c6x/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ generic-y += current.h
generic-y += device.h
generic-y += div64.h
generic-y += dma.h
generic-y += dma-mapping.h
generic-y += emergency-restart.h
generic-y += exec.h
generic-y += extable.h
Expand Down
28 changes: 0 additions & 28 deletions arch/c6x/include/asm/dma-mapping.h

This file was deleted.

2 changes: 2 additions & 0 deletions arch/c6x/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ extern unsigned char c6x_fuse_mac[6];
extern void machine_init(unsigned long dt_ptr);
extern void time_init(void);

extern void coherent_mem_init(u32 start, u32 size);

#endif /* !__ASSEMBLY__ */
#endif /* _ASM_C6X_SETUP_H */
2 changes: 1 addition & 1 deletion arch/c6x/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ extra-y := head.o vmlinux.lds
obj-y := process.o traps.o irq.o signal.o ptrace.o
obj-y += setup.o sys_c6x.o time.o devicetree.o
obj-y += switch_to.o entry.o vectors.o c6x_ksyms.o
obj-y += soc.o dma.o
obj-y += soc.o

obj-$(CONFIG_MODULES) += module.o
138 changes: 0 additions & 138 deletions arch/c6x/kernel/dma.c

This file was deleted.

40 changes: 37 additions & 3 deletions arch/c6x/mm/dma-coherent.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
#include <linux/bitops.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/dma-noncoherent.h>
#include <linux/memblock.h>

#include <asm/cacheflush.h>
#include <asm/page.h>
#include <asm/setup.h>

/*
* DMA coherent memory management, can be redefined using the memdma=
Expand Down Expand Up @@ -73,7 +75,7 @@ static void __free_dma_pages(u32 addr, int order)
* Allocate DMA coherent memory space and return both the kernel
* virtual and DMA address for that space.
*/
void *c6x_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
gfp_t gfp, unsigned long attrs)
{
u32 paddr;
Expand All @@ -98,7 +100,7 @@ void *c6x_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
/*
* Free DMA coherent memory as defined by the above mapping.
*/
void c6x_dma_free(struct device *dev, size_t size, void *vaddr,
void arch_dma_free(struct device *dev, size_t size, void *vaddr,
dma_addr_t dma_handle, unsigned long attrs)
{
int order;
Expand Down Expand Up @@ -139,3 +141,35 @@ void __init coherent_mem_init(phys_addr_t start, u32 size)
dma_bitmap = phys_to_virt(bitmap_phys);
memset(dma_bitmap, 0, dma_pages * PAGE_SIZE);
}

static void c6x_dma_sync(struct device *dev, phys_addr_t paddr, size_t size,
enum dma_data_direction dir)
{
BUG_ON(!valid_dma_direction(dir));

switch (dir) {
case DMA_FROM_DEVICE:
L2_cache_block_invalidate(paddr, paddr + size);
break;
case DMA_TO_DEVICE:
L2_cache_block_writeback(paddr, paddr + size);
break;
case DMA_BIDIRECTIONAL:
L2_cache_block_writeback_invalidate(paddr, paddr + size);
break;
default:
break;
}
}

void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr,
size_t size, enum dma_data_direction dir)
{
return c6x_dma_sync(dev, paddr, size, dir);
}

void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
size_t size, enum dma_data_direction dir)
{
return c6x_dma_sync(dev, paddr, size, dir);
}

0 comments on commit 7f5c1ea

Please sign in to comment.