dma-mapping: merge <linux/dma-noncoherent.h> into <linux/dma-map-ops.h>
authorChristoph Hellwig <hch@lst.de>
Tue, 22 Sep 2020 13:36:11 +0000 (15:36 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 6 Oct 2020 05:07:06 +0000 (07:07 +0200)
Move more nitty gritty DMA implementation details into the common
internal header.

Signed-off-by: Christoph Hellwig <hch@lst.de>
29 files changed:
MAINTAINERS
arch/arc/mm/dma.c
arch/arm/mm/dma-mapping.c
arch/arm/xen/mm.c
arch/arm64/mm/dma-mapping.c
arch/c6x/mm/dma-coherent.c
arch/csky/mm/dma-mapping.c
arch/hexagon/kernel/dma.c
arch/ia64/mm/init.c
arch/m68k/kernel/dma.c
arch/microblaze/kernel/dma.c
arch/microblaze/mm/consistent.c
arch/mips/jazz/jazzdma.c
arch/mips/mm/dma-noncoherent.c
arch/nds32/kernel/dma.c
arch/openrisc/kernel/dma.c
arch/parisc/kernel/pci-dma.c
arch/powerpc/mm/dma-noncoherent.c
arch/sh/kernel/dma-coherent.c
arch/sparc/kernel/ioport.c
arch/xtensa/kernel/pci-dma.c
drivers/iommu/dma-iommu.c
drivers/xen/swiotlb-xen.c
include/linux/dma-direct.h
include/linux/dma-map-ops.h
include/linux/dma-noncoherent.h [deleted file]
kernel/dma/ops_helpers.c
kernel/dma/pool.c
kernel/dma/swiotlb.c

index b13fc17943079ae6510949ba0f7e161824caa33c..c0dbe6e9de6549271e004f5f015639a3d1ea5faa 100644 (file)
@@ -5203,7 +5203,6 @@ F:        include/asm-generic/dma-mapping.h
 F:     include/linux/dma-direct.h
 F:     include/linux/dma-mapping.h
 F:     include/linux/dma-map-ops.h
-F:     include/linux/dma-noncoherent.h
 F:     kernel/dma/
 
 DMA-BUF HEAPS FRAMEWORK
index a8c453e98d753b8f8404248340fda047e562da53..517988e60cfc4d145439e58dedbcfde91d9e08a7 100644 (file)
@@ -4,7 +4,6 @@
  */
 
 #include <linux/dma-map-ops.h>
-#include <linux/dma-noncoherent.h>
 #include <asm/cache.h>
 #include <asm/cacheflush.h>
 
index 911fc6ea26071eda7e2256d41cfdd70b3b9a9f21..c4b8df2ad32850123386dec4a1b59e6aa4d05f7f 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/device.h>
 #include <linux/dma-direct.h>
 #include <linux/dma-map-ops.h>
-#include <linux/dma-noncoherent.h>
 #include <linux/highmem.h>
 #include <linux/memblock.h>
 #include <linux/slab.h>
index 396797ffe2b1dfa651f54bb297938d0e4655c719..5c80088db13b59aa5fd4232c45d34bf75f230f8d 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <linux/cpu.h>
 #include <linux/dma-direct.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/gfp.h>
 #include <linux/highmem.h>
 #include <linux/export.h>
index 3afd3bd659d8dec2c9d03ab498e64d1cbd19442f..93e87b2875567e09427b4d5e60a947a0e33be77c 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/gfp.h>
 #include <linux/cache.h>
 #include <linux/dma-map-ops.h>
-#include <linux/dma-noncoherent.h>
 #include <linux/dma-iommu.h>
 #include <xen/xen.h>
 #include <xen/swiotlb-xen.h>
index a5909091cb14244f635d73a9b6ad76e3a03b6e19..03df07a831fc9910105f600c1ede7f2a71f186f4 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/memblock.h>
 
 #include <asm/cacheflush.h>
index 3d9ff26c4bb4d8fb05e3f3203cfedf8e03bb4ebc..c3a775a7e8f9d84c684cfd58e9cd54efe848931d 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <linux/cache.h>
 #include <linux/dma-map-ops.h>
-#include <linux/dma-noncoherent.h>
 #include <linux/genalloc.h>
 #include <linux/highmem.h>
 #include <linux/io.h>
index 25f388d9cfcc36650454ecd55217bff5c6eac7da..00b9a81075dd54a31cec478b4dfef9a0a4a0de4a 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
  */
 
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/memblock.h>
 #include <linux/genalloc.h>
 #include <linux/module.h>
index 02e5aa08294ee08b26722278277118b050b58b80..ccba04d12671829a9312584eee26fe9b00ce4b58 100644 (file)
@@ -8,7 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/dmar.h>
 #include <linux/efi.h>
 #include <linux/elf.h>
index b1ca3522eccc2fef030fdc9e2775d67e19ef1a68..1c1b875fadc180ec111f001bbc457af2e9fea487 100644 (file)
@@ -6,7 +6,7 @@
 
 #undef DEBUG
 
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
index a564863db06e98aca31a436d7efcc2651a38ca61..04d091ade4172b7600ee18b9fcd780092296dc4f 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include <linux/device.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/gfp.h>
 #include <linux/export.h>
 #include <linux/bug.h>
index e09b66e43cb63f436f68a0444b32aca7a71dcb5b..81dffe43b18c1e7bbbb6c2ce243c708b83fed8c9 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/init.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <asm/cpuinfo.h>
 #include <asm/cacheflush.h>
 
index b8fb42e56da0a8c7e71c0739c3c9217c21db6a31..461457b289828a502f4bb7b0751c68b152486e3a 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/spinlock.h>
 #include <linux/gfp.h>
 #include <linux/dma-map-ops.h>
-#include <linux/dma-noncoherent.h>
 #include <asm/mipsregs.h>
 #include <asm/jazz.h>
 #include <asm/io.h>
index 22d99ccc70c81eaead7a5a7c30e151769f609f75..38d3d9143b47fbc88de62bdb2bcb614ac703db37 100644 (file)
@@ -6,7 +6,6 @@
  */
 #include <linux/dma-direct.h>
 #include <linux/dma-map-ops.h>
-#include <linux/dma-noncoherent.h>
 #include <linux/highmem.h>
 
 #include <asm/cache.h>
index 69d762182d49bfbd23ff57bc64e11b9328214519..2ac8e6c82a61a50c89d9a31153a810fae6fb5ad7 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <linux/types.h>
 #include <linux/mm.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/cache.h>
 #include <linux/highmem.h>
 #include <asm/cacheflush.h>
index 345727638d52daccc92dd4bb793dd3067b549da9..1b16d97e7da7f96eb6ab80f4162eb9a581b8f9ab 100644 (file)
@@ -13,7 +13,7 @@
  * DMA mapping callbacks...
  */
 
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/pagewalk.h>
 
 #include <asm/cpuinfo.h>
index ce38c0b9158125d62222cc3f91181ef864cddc2d..36610a5c029fc2adf6f0b799644169afe28b4d7f 100644 (file)
@@ -26,7 +26,7 @@
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/dma-direct.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 
 #include <asm/cacheflush.h>
 #include <asm/dma.h>    /* for DMA_CHUNK_SIZE */
index 5ab4f868e919b8dd8f1efe75ddfefc94383a68e2..30260b5d146da37aef5d57e26d75ad059672bb3e 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/types.h>
 #include <linux/highmem.h>
 #include <linux/dma-direct.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 
 #include <asm/tlbflush.h>
 #include <asm/dma.h>
index cd46a9825e3c5921c8db72688cdd788a912af0f4..6a44c0e7ba40eff1101877ed75d3e7fff19b2c1c 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2004 - 2007  Paul Mundt
  */
 #include <linux/mm.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <asm/cacheflush.h>
 #include <asm/addrspace.h>
 
index d6874c9b639f8de480a0813c256c319c371076bf..8e1d72a16759494086c2e8fe85f3044e673f12ef 100644 (file)
@@ -38,7 +38,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/scatterlist.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/of_device.h>
 
 #include <asm/io.h>
index 790dbe022a07960428b3a4a143873a99097f2426..94955caa4488c8e8fc333fb881d721dd87e502d8 100644 (file)
@@ -12,7 +12,6 @@
  */
 
 #include <linux/dma-map-ops.h>
-#include <linux/dma-noncoherent.h>
 #include <linux/dma-direct.h>
 #include <linux/gfp.h>
 #include <linux/highmem.h>
index 22c221bba13e2fe632b61fa52c61b9f6fc1f44ea..3a00fb64477b0c9d9ee01cf8dc66de596b880236 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/device.h>
 #include <linux/dma-map-ops.h>
 #include <linux/dma-iommu.h>
-#include <linux/dma-noncoherent.h>
 #include <linux/gfp.h>
 #include <linux/huge_mm.h>
 #include <linux/iommu.h>
index 71ff4bf380738c1c8b0fb3b732234c04a5cd0b77..71ce1b7a23d1cc59bbe72755a60c4627f13c0c6d 100644 (file)
@@ -27,9 +27,8 @@
 #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
 
 #include <linux/memblock.h>
-#include <linux/dma-map-ops.h>
 #include <linux/dma-direct.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/export.h>
 #include <xen/swiotlb-xen.h>
 #include <xen/page.h>
index a2d6640c42c04e3c075a187207de19666d6e193e..18aade195884d7b3e3899dc89175e300f58434e0 100644 (file)
@@ -7,7 +7,7 @@
 #define _LINUX_DMA_DIRECT_H 1
 
 #include <linux/dma-mapping.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/memblock.h> /* for min_low_pfn */
 #include <linux/mem_encrypt.h>
 #include <linux/swiotlb.h>
index 9891def42da71fd522e4521299c90aa6d6113728..33c6e24707a94b610360744f57b16a1177c0a47a 100644 (file)
@@ -7,6 +7,7 @@
 #define _LINUX_DMA_MAP_OPS_H
 
 #include <linux/dma-mapping.h>
+#include <linux/pgtable.h>
 
 struct cma;
 
@@ -202,6 +203,107 @@ static inline int dma_mmap_from_global_coherent(struct vm_area_struct *vma,
 }
 #endif /* CONFIG_DMA_DECLARE_COHERENT */
 
+#ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H
+#include <asm/dma-coherence.h>
+#elif defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
+       defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
+       defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
+static inline bool dev_is_dma_coherent(struct device *dev)
+{
+       return dev->dma_coherent;
+}
+#else
+static inline bool dev_is_dma_coherent(struct device *dev)
+{
+       return true;
+}
+#endif /* CONFIG_ARCH_HAS_DMA_COHERENCE_H */
+
+/*
+ * Check if an allocation needs to be marked uncached to be coherent.
+ */
+static __always_inline bool dma_alloc_need_uncached(struct device *dev,
+               unsigned long attrs)
+{
+       if (dev_is_dma_coherent(dev))
+               return false;
+       if (attrs & DMA_ATTR_NO_KERNEL_MAPPING)
+               return false;
+       return true;
+}
+
+void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
+               gfp_t gfp, unsigned long attrs);
+void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
+               dma_addr_t dma_addr, unsigned long attrs);
+
+#ifdef CONFIG_MMU
+/*
+ * Page protection so that devices that can't snoop CPU caches can use the
+ * memory coherently.  We default to pgprot_noncached which is usually used
+ * for ioremap as a safe bet, but architectures can override this with less
+ * strict semantics if possible.
+ */
+#ifndef pgprot_dmacoherent
+#define pgprot_dmacoherent(prot)       pgprot_noncached(prot)
+#endif
+
+pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs);
+#else
+static inline pgprot_t dma_pgprot(struct device *dev, pgprot_t prot,
+               unsigned long attrs)
+{
+       return prot;    /* no protection bits supported without page tables */
+}
+#endif /* CONFIG_MMU */
+
+#ifdef CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE
+void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
+               enum dma_data_direction dir);
+#else
+static inline void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
+               enum dma_data_direction dir)
+{
+}
+#endif /* ARCH_HAS_SYNC_DMA_FOR_DEVICE */
+
+#ifdef CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU
+void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
+               enum dma_data_direction dir);
+#else
+static inline void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
+               enum dma_data_direction dir)
+{
+}
+#endif /* ARCH_HAS_SYNC_DMA_FOR_CPU */
+
+#ifdef CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
+void arch_sync_dma_for_cpu_all(void);
+#else
+static inline void arch_sync_dma_for_cpu_all(void)
+{
+}
+#endif /* CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL */
+
+#ifdef CONFIG_ARCH_HAS_DMA_PREP_COHERENT
+void arch_dma_prep_coherent(struct page *page, size_t size);
+#else
+static inline void arch_dma_prep_coherent(struct page *page, size_t size)
+{
+}
+#endif /* CONFIG_ARCH_HAS_DMA_PREP_COHERENT */
+
+#ifdef CONFIG_ARCH_HAS_DMA_MARK_CLEAN
+void arch_dma_mark_clean(phys_addr_t paddr, size_t size);
+#else
+static inline void arch_dma_mark_clean(phys_addr_t paddr, size_t size)
+{
+}
+#endif /* ARCH_HAS_DMA_MARK_CLEAN */
+
+void *arch_dma_set_uncached(void *addr, size_t size);
+void arch_dma_clear_uncached(void *addr, size_t size);
+
 #ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS
 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
                const struct iommu_ops *iommu, bool coherent);
diff --git a/include/linux/dma-noncoherent.h b/include/linux/dma-noncoherent.h
deleted file mode 100644 (file)
index e61283e..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _LINUX_DMA_NONCOHERENT_H
-#define _LINUX_DMA_NONCOHERENT_H 1
-
-#include <linux/dma-mapping.h>
-#include <linux/pgtable.h>
-
-#ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H
-#include <asm/dma-coherence.h>
-#elif defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
-       defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
-       defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
-static inline bool dev_is_dma_coherent(struct device *dev)
-{
-       return dev->dma_coherent;
-}
-#else
-static inline bool dev_is_dma_coherent(struct device *dev)
-{
-       return true;
-}
-#endif /* CONFIG_ARCH_HAS_DMA_COHERENCE_H */
-
-/*
- * Check if an allocation needs to be marked uncached to be coherent.
- */
-static __always_inline bool dma_alloc_need_uncached(struct device *dev,
-               unsigned long attrs)
-{
-       if (dev_is_dma_coherent(dev))
-               return false;
-       if (attrs & DMA_ATTR_NO_KERNEL_MAPPING)
-               return false;
-       return true;
-}
-
-void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
-               gfp_t gfp, unsigned long attrs);
-void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
-               dma_addr_t dma_addr, unsigned long attrs);
-
-#ifdef CONFIG_MMU
-/*
- * Page protection so that devices that can't snoop CPU caches can use the
- * memory coherently.  We default to pgprot_noncached which is usually used
- * for ioremap as a safe bet, but architectures can override this with less
- * strict semantics if possible.
- */
-#ifndef pgprot_dmacoherent
-#define pgprot_dmacoherent(prot)       pgprot_noncached(prot)
-#endif
-
-pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs);
-#else
-static inline pgprot_t dma_pgprot(struct device *dev, pgprot_t prot,
-               unsigned long attrs)
-{
-       return prot;    /* no protection bits supported without page tables */
-}
-#endif /* CONFIG_MMU */
-
-#ifdef CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE
-void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
-               enum dma_data_direction dir);
-#else
-static inline void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
-               enum dma_data_direction dir)
-{
-}
-#endif /* ARCH_HAS_SYNC_DMA_FOR_DEVICE */
-
-#ifdef CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU
-void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
-               enum dma_data_direction dir);
-#else
-static inline void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
-               enum dma_data_direction dir)
-{
-}
-#endif /* ARCH_HAS_SYNC_DMA_FOR_CPU */
-
-#ifdef CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
-void arch_sync_dma_for_cpu_all(void);
-#else
-static inline void arch_sync_dma_for_cpu_all(void)
-{
-}
-#endif /* CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL */
-
-#ifdef CONFIG_ARCH_HAS_DMA_PREP_COHERENT
-void arch_dma_prep_coherent(struct page *page, size_t size);
-#else
-static inline void arch_dma_prep_coherent(struct page *page, size_t size)
-{
-}
-#endif /* CONFIG_ARCH_HAS_DMA_PREP_COHERENT */
-
-#ifdef CONFIG_ARCH_HAS_DMA_MARK_CLEAN
-void arch_dma_mark_clean(phys_addr_t paddr, size_t size);
-#else
-static inline void arch_dma_mark_clean(phys_addr_t paddr, size_t size)
-{
-}
-#endif /* ARCH_HAS_DMA_MARK_CLEAN */
-
-void *arch_dma_set_uncached(void *addr, size_t size);
-void arch_dma_clear_uncached(void *addr, size_t size);
-
-#endif /* _LINUX_DMA_NONCOHERENT_H */
index bc80fd2648bcf2f063529823f91e9102ae1c3188..910ae69cae7774dbd1639b8f0ff57a6d4060205e 100644 (file)
@@ -4,7 +4,6 @@
  * the allocated memory contains normal pages in the direct kernel mapping.
  */
 #include <linux/dma-map-ops.h>
-#include <linux/dma-noncoherent.h>
 
 /*
  * Create scatter-list for the already allocated DMA buffer.
index c9fb5c3d8bd002d0b4a2b2399f415d8d33d11f94..d4637f72239b404f4fbef822e74cb4c441062034 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/debugfs.h>
 #include <linux/dma-map-ops.h>
 #include <linux/dma-direct.h>
-#include <linux/dma-noncoherent.h>
 #include <linux/init.h>
 #include <linux/genalloc.h>
 #include <linux/set_memory.h>
index 4ea72d145cd27d2e698be79ae78942fe4aa8ddca..2be1e8b34ae3b9383b1a63e32f6e5db40a44ad61 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <linux/cache.h>
 #include <linux/dma-direct.h>
-#include <linux/dma-noncoherent.h>
+#include <linux/dma-map-ops.h>
 #include <linux/mm.h>
 #include <linux/export.h>
 #include <linux/spinlock.h>