MIPS: Implement dma_map_ops::get_cache_alignment()
Subsystems (3)
PATCH v10 2/4 MIPS: Implement dma_map_ops::get_cache_alignment()
Currently, MIPS is an architecture which support coherent & noncoherent devices co-exist. So implement get_cache_alignment() function pointer in 'struct dma_map_ops' to return different dma alignments.
Signed-off-by Huacai Chen <[email protected]>
--- arch/mips/cavium-octeon/dma-octeon.c | 3 ++- arch/mips/include/asm/dma-coherence.h | 2 ++ arch/mips/include/asm/mach-loongson64/kmalloc.h | 6 ++++++ arch/mips/loongson64/common/dma-swiotlb.c | 1 + arch/mips/mm/dma-default.c | 9 +++++++++ arch/mips/netlogic/common/nlm-dma.c | 3 ++- 6 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson64/kmalloc.h
arch/mips/cavium-octeon/dma-octeon.c +2 -1
@@ -324,7 +324,8 @@ static struct octeon_dma_map_ops _octeon_pci_dma_map_ops = { .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, .sync_sg_for_device = octeon_dma_sync_sg_for_device, .mapping_error = swiotlb_dma_mapping_error, - .dma_supported = swiotlb_dma_supported + .dma_supported = swiotlb_dma_supported, + .get_cache_alignment = mips_dma_get_cache_alignment }, };
arch/mips/include/asm/dma-coherence.h +2 -0
@@ -29,4 +29,6 @@ extern int hw_coherentio;#define hw_coherentio 0#endif /* CONFIG_DMA_MAYBE_COHERENT */ +int mips_dma_get_cache_alignment (struct device *dev); +#endif
arch/mips/include/asm/mach-loongson64/kmalloc.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ASM_MACH_LOONGSON64_KMALLOC_H +#define __ASM_MACH_LOONGSON64_KMALLOC_H + +#define ARCH_DMA_MINALIGN L1_CACHE_BYTES + +#endif /* __ASM_MACH_LOONGSON64_KMALLOC_H */
arch/mips/loongson64/common/dma-swiotlb.c +1 -0
@@ -121,6 +121,7 @@ static const struct dma_map_ops loongson_dma_map_ops = { .mapping_error = swiotlb_dma_mapping_error, .dma_supported = loongson_dma_supported, .cache_sync = mips_dma_cache_sync, + .get_cache_alignment = mips_dma_get_cache_alignment };void __init plat_swiotlb_setup (void )
arch/mips/mm/dma-default.c +9 -0
@@ -392,6 +392,14 @@ void mips_dma_cache_sync(struct device *dev, void *vaddr, size_t size,__dma_sync_virtual (vaddr, size, direction); } +int mips_dma_get_cache_alignment (struct device *dev) +{ +if (plat_device_is_coherent (dev)) +return 1 ; +else +return ARCH_DMA_MINALIGN ; +} +static const struct dma_map_ops mips_default_dma_map_ops = { .alloc = mips_dma_alloc_coherent, .free = mips_dma_free_coherent,
@@ -407,6 +415,7 @@ static const struct dma_map_ops mips_default_dma_map_ops = { .mapping_error = mips_dma_mapping_error, .dma_supported = mips_dma_supported, .cache_sync = mips_dma_cache_sync, + .get_cache_alignment = mips_dma_get_cache_alignment };const struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops;
arch/mips/netlogic/common/nlm-dma.c +2 -1
@@ -79,7 +79,8 @@ const struct dma_map_ops nlm_swiotlb_dma_ops = { .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, .sync_sg_for_device = swiotlb_sync_sg_for_device, .mapping_error = swiotlb_dma_mapping_error, - .dma_supported = swiotlb_dma_supported + .dma_supported = swiotlb_dma_supported, + .get_cache_alignment = mips_dma_get_cache_alignment };void __init plat_swiotlb_setup (void )
Signature · 1 line
2.7.0