Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: remove mips_swiotlb_ops

mips_swiotlb_ops differs from the generic swiotlb_dma_ops only in that
it contains a mb() barrier after each operations that maps or syncs
dma memory to the device.

The dma operations are defined to not be memory barriers, but instead
the write* operations to kick the DMA off are supposed to contain them.

For mips this handled by war_io_reorder_wmb(), which evaluates to the
stronger wmb() instead of the pure compiler barrier barrier() for
just those platforms that use swiotlb, so I think we are covered
properly.

[paul.burton@mips.com:
- Include linux/swiotlb.h to fix build failures for configs with
CONFIG_SWIOTLB=y.]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Patchwork: https://patchwork.linux-mips.org/patch/20038/
Cc: David Daney <ddaney@caviumnetworks.com>
Cc: Huacai Chen <chenhc@lemote.com>
Cc: linux-mips@linux-mips.org
Cc: iommu@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org

authored by

Christoph Hellwig and committed by
Paul Burton
a999933d d4da0e97

+3 -64
+3 -2
arch/mips/include/asm/dma-mapping.h
··· 2 2 #ifndef _ASM_DMA_MAPPING_H 3 3 #define _ASM_DMA_MAPPING_H 4 4 5 + #include <linux/swiotlb.h> 6 + 5 7 extern const struct dma_map_ops jazz_dma_ops; 6 - extern const struct dma_map_ops mips_swiotlb_ops; 7 8 8 9 static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) 9 10 { 10 11 #if defined(CONFIG_MACH_JAZZ) 11 12 return &jazz_dma_ops; 12 13 #elif defined(CONFIG_SWIOTLB) 13 - return &mips_swiotlb_ops; 14 + return &swiotlb_dma_ops; 14 15 #elif defined(CONFIG_DMA_NONCOHERENT_OPS) 15 16 return &dma_noncoherent_ops; 16 17 #else
-1
arch/mips/mm/Makefile
··· 18 18 obj-$(CONFIG_HIGHMEM) += highmem.o 19 19 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 20 20 obj-$(CONFIG_DMA_NONCOHERENT) += dma-noncoherent.o 21 - obj-$(CONFIG_SWIOTLB) += dma-swiotlb.o 22 21 23 22 obj-$(CONFIG_CPU_R4K_CACHE_TLB) += c-r4k.o cex-gen.o tlb-r4k.o 24 23 obj-$(CONFIG_CPU_R3000) += c-r3k.o tlb-r3k.o
-61
arch/mips/mm/dma-swiotlb.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <linux/dma-mapping.h> 3 - #include <linux/swiotlb.h> 4 - 5 - static void *mips_swiotlb_alloc(struct device *dev, size_t size, 6 - dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) 7 - { 8 - void *ret = swiotlb_alloc(dev, size, dma_handle, gfp, attrs); 9 - 10 - mb(); 11 - return ret; 12 - } 13 - 14 - static dma_addr_t mips_swiotlb_map_page(struct device *dev, 15 - struct page *page, unsigned long offset, size_t size, 16 - enum dma_data_direction dir, unsigned long attrs) 17 - { 18 - dma_addr_t daddr = swiotlb_map_page(dev, page, offset, size, 19 - dir, attrs); 20 - mb(); 21 - return daddr; 22 - } 23 - 24 - static int mips_swiotlb_map_sg(struct device *dev, struct scatterlist *sg, 25 - int nents, enum dma_data_direction dir, unsigned long attrs) 26 - { 27 - int r = swiotlb_map_sg_attrs(dev, sg, nents, dir, attrs); 28 - mb(); 29 - 30 - return r; 31 - } 32 - 33 - static void mips_swiotlb_sync_single_for_device(struct device *dev, 34 - dma_addr_t dma_handle, size_t size, enum dma_data_direction dir) 35 - { 36 - swiotlb_sync_single_for_device(dev, dma_handle, size, dir); 37 - mb(); 38 - } 39 - 40 - static void mips_swiotlb_sync_sg_for_device(struct device *dev, 41 - struct scatterlist *sg, int nents, enum dma_data_direction dir) 42 - { 43 - swiotlb_sync_sg_for_device(dev, sg, nents, dir); 44 - mb(); 45 - } 46 - 47 - const struct dma_map_ops mips_swiotlb_ops = { 48 - .alloc = mips_swiotlb_alloc, 49 - .free = swiotlb_free, 50 - .map_page = mips_swiotlb_map_page, 51 - .unmap_page = swiotlb_unmap_page, 52 - .map_sg = mips_swiotlb_map_sg, 53 - .unmap_sg = swiotlb_unmap_sg_attrs, 54 - .sync_single_for_cpu = swiotlb_sync_single_for_cpu, 55 - .sync_single_for_device = mips_swiotlb_sync_single_for_device, 56 - .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, 57 - .sync_sg_for_device = mips_swiotlb_sync_sg_for_device, 58 - .mapping_error = swiotlb_dma_mapping_error, 59 - .dma_supported = swiotlb_dma_supported, 60 - }; 61 - EXPORT_SYMBOL(mips_swiotlb_ops);