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

dma-mapping: merge <linux/dma-contiguous.h> into <linux/dma-map-ops.h>

Merge dma-contiguous.h into dma-map-ops.h, after removing the comment
describing the contiguous allocator into kernel/dma/contigous.c.

Signed-off-by: Christoph Hellwig <hch@lst.de>

+112 -164
+1 -1
Documentation/admin-guide/kernel-parameters.txt
··· 597 597 placement constraint by the physical address range of 598 598 memory allocations. A value of 0 disables CMA 599 599 altogether. For more information, see 600 - include/linux/dma-contiguous.h 600 + kernel/dma/contiguous.c 601 601 602 602 cma_pernuma=nn[MG] 603 603 [ARM64,KNL]
+1 -1
arch/arm/mach-davinci/devices-da8xx.c
··· 10 10 #include <linux/clk-provider.h> 11 11 #include <linux/clk.h> 12 12 #include <linux/clkdev.h> 13 - #include <linux/dma-contiguous.h> 13 + #include <linux/dma-map-ops.h> 14 14 #include <linux/dmaengine.h> 15 15 #include <linux/init.h> 16 16 #include <linux/io.h>
+1 -1
arch/arm/mach-shmobile/setup-rcar-gen2.c
··· 9 9 10 10 #include <linux/clocksource.h> 11 11 #include <linux/device.h> 12 - #include <linux/dma-contiguous.h> 12 + #include <linux/dma-map-ops.h> 13 13 #include <linux/io.h> 14 14 #include <linux/kernel.h> 15 15 #include <linux/memblock.h>
-1
arch/arm/mm/dma-mapping.c
··· 17 17 #include <linux/dma-direct.h> 18 18 #include <linux/dma-map-ops.h> 19 19 #include <linux/dma-noncoherent.h> 20 - #include <linux/dma-contiguous.h> 21 20 #include <linux/highmem.h> 22 21 #include <linux/memblock.h> 23 22 #include <linux/slab.h>
+1 -1
arch/arm/mm/init.c
··· 18 18 #include <linux/highmem.h> 19 19 #include <linux/gfp.h> 20 20 #include <linux/memblock.h> 21 - #include <linux/dma-contiguous.h> 21 + #include <linux/dma-map-ops.h> 22 22 #include <linux/sizes.h> 23 23 #include <linux/stop_machine.h> 24 24 #include <linux/swiotlb.h>
+1 -2
arch/arm64/mm/init.c
··· 21 21 #include <linux/of.h> 22 22 #include <linux/of_fdt.h> 23 23 #include <linux/dma-direct.h> 24 - #include <linux/dma-mapping.h> 25 - #include <linux/dma-contiguous.h> 24 + #include <linux/dma-map-ops.h> 26 25 #include <linux/efi.h> 27 26 #include <linux/swiotlb.h> 28 27 #include <linux/vmalloc.h>
+1 -1
arch/csky/kernel/setup.c
··· 7 7 #include <linux/of.h> 8 8 #include <linux/of_fdt.h> 9 9 #include <linux/start_kernel.h> 10 - #include <linux/dma-contiguous.h> 10 + #include <linux/dma-map-ops.h> 11 11 #include <linux/screen_info.h> 12 12 #include <asm/sections.h> 13 13 #include <asm/mmu_context.h>
+1 -2
arch/csky/mm/dma-mapping.c
··· 2 2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. 3 3 4 4 #include <linux/cache.h> 5 - #include <linux/dma-mapping.h> 6 - #include <linux/dma-contiguous.h> 5 + #include <linux/dma-map-ops.h> 7 6 #include <linux/dma-noncoherent.h> 8 7 #include <linux/genalloc.h> 9 8 #include <linux/highmem.h>
+1 -1
arch/microblaze/mm/init.c
··· 7 7 * for more details. 8 8 */ 9 9 10 - #include <linux/dma-contiguous.h> 10 + #include <linux/dma-map-ops.h> 11 11 #include <linux/memblock.h> 12 12 #include <linux/init.h> 13 13 #include <linux/kernel.h>
+1 -1
arch/mips/kernel/setup.c
··· 24 24 #include <linux/kexec.h> 25 25 #include <linux/sizes.h> 26 26 #include <linux/device.h> 27 - #include <linux/dma-contiguous.h> 27 + #include <linux/dma-map-ops.h> 28 28 #include <linux/decompress/generic.h> 29 29 #include <linux/of_fdt.h> 30 30 #include <linux/of_reserved_mem.h>
-1
arch/mips/mm/dma-noncoherent.c
··· 7 7 #include <linux/dma-direct.h> 8 8 #include <linux/dma-map-ops.h> 9 9 #include <linux/dma-noncoherent.h> 10 - #include <linux/dma-contiguous.h> 11 10 #include <linux/highmem.h> 12 11 13 12 #include <asm/cache.h>
+1 -1
arch/s390/kernel/setup.c
··· 37 37 #include <linux/root_dev.h> 38 38 #include <linux/console.h> 39 39 #include <linux/kernel_stat.h> 40 - #include <linux/dma-contiguous.h> 40 + #include <linux/dma-map-ops.h> 41 41 #include <linux/device.h> 42 42 #include <linux/notifier.h> 43 43 #include <linux/pfn.h>
-1
arch/x86/include/asm/dma-mapping.h
··· 11 11 #include <linux/dma-debug.h> 12 12 #include <asm/io.h> 13 13 #include <asm/swiotlb.h> 14 - #include <linux/dma-contiguous.h> 15 14 16 15 extern int iommu_merge; 17 16 extern int panic_on_overflow;
+1 -1
arch/x86/kernel/setup.c
··· 7 7 */ 8 8 #include <linux/console.h> 9 9 #include <linux/crash_dump.h> 10 - #include <linux/dma-contiguous.h> 10 + #include <linux/dma-map-ops.h> 11 11 #include <linux/dmi.h> 12 12 #include <linux/efi.h> 13 13 #include <linux/init_ohci1394_dma.h>
+1 -1
arch/xtensa/kernel/pci-dma.c
··· 11 11 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com> 12 12 */ 13 13 14 - #include <linux/dma-contiguous.h> 14 + #include <linux/dma-map-ops.h> 15 15 #include <linux/dma-noncoherent.h> 16 16 #include <linux/dma-direct.h> 17 17 #include <linux/gfp.h>
+1 -1
arch/xtensa/mm/init.c
··· 26 26 #include <linux/nodemask.h> 27 27 #include <linux/mm.h> 28 28 #include <linux/of_fdt.h> 29 - #include <linux/dma-contiguous.h> 29 + #include <linux/dma-map-ops.h> 30 30 31 31 #include <asm/bootparam.h> 32 32 #include <asm/page.h>
+1 -1
drivers/dma-buf/heaps/cma_heap.c
··· 10 10 #include <linux/device.h> 11 11 #include <linux/dma-buf.h> 12 12 #include <linux/dma-heap.h> 13 - #include <linux/dma-contiguous.h> 13 + #include <linux/dma-map-ops.h> 14 14 #include <linux/err.h> 15 15 #include <linux/errno.h> 16 16 #include <linux/highmem.h>
+1 -2
drivers/iommu/amd/iommu.c
··· 18 18 #include <linux/slab.h> 19 19 #include <linux/debugfs.h> 20 20 #include <linux/scatterlist.h> 21 - #include <linux/dma-mapping.h> 21 + #include <linux/dma-map-ops.h> 22 22 #include <linux/dma-direct.h> 23 23 #include <linux/dma-iommu.h> 24 24 #include <linux/iommu-helper.h> ··· 28 28 #include <linux/export.h> 29 29 #include <linux/irq.h> 30 30 #include <linux/msi.h> 31 - #include <linux/dma-contiguous.h> 32 31 #include <linux/irqdomain.h> 33 32 #include <linux/percpu.h> 34 33 #include <linux/iova.h>
-1
drivers/iommu/dma-iommu.c
··· 11 11 #include <linux/acpi_iort.h> 12 12 #include <linux/device.h> 13 13 #include <linux/dma-map-ops.h> 14 - #include <linux/dma-contiguous.h> 15 14 #include <linux/dma-iommu.h> 16 15 #include <linux/dma-noncoherent.h> 17 16 #include <linux/gfp.h>
+1 -1
drivers/iommu/intel/iommu.c
··· 37 37 #include <linux/dmi.h> 38 38 #include <linux/pci-ats.h> 39 39 #include <linux/memblock.h> 40 - #include <linux/dma-contiguous.h> 40 + #include <linux/dma-map-ops.h> 41 41 #include <linux/dma-direct.h> 42 42 #include <linux/crash_dump.h> 43 43 #include <linux/numa.h>
-1
drivers/media/platform/exynos4-is/fimc-is.c
··· 12 12 #include <linux/device.h> 13 13 #include <linux/debugfs.h> 14 14 #include <linux/delay.h> 15 - #include <linux/dma-contiguous.h> 16 15 #include <linux/errno.h> 17 16 #include <linux/firmware.h> 18 17 #include <linux/interrupt.h>
-135
include/linux/dma-contiguous.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - #ifndef __LINUX_CMA_H 3 - #define __LINUX_CMA_H 4 - 5 - /* 6 - * Contiguous Memory Allocator for DMA mapping framework 7 - * Copyright (c) 2010-2011 by Samsung Electronics. 8 - * Written by: 9 - * Marek Szyprowski <m.szyprowski@samsung.com> 10 - * Michal Nazarewicz <mina86@mina86.com> 11 - */ 12 - 13 - /* 14 - * Contiguous Memory Allocator 15 - * 16 - * The Contiguous Memory Allocator (CMA) makes it possible to 17 - * allocate big contiguous chunks of memory after the system has 18 - * booted. 19 - * 20 - * Why is it needed? 21 - * 22 - * Various devices on embedded systems have no scatter-getter and/or 23 - * IO map support and require contiguous blocks of memory to 24 - * operate. They include devices such as cameras, hardware video 25 - * coders, etc. 26 - * 27 - * Such devices often require big memory buffers (a full HD frame 28 - * is, for instance, more then 2 mega pixels large, i.e. more than 6 29 - * MB of memory), which makes mechanisms such as kmalloc() or 30 - * alloc_page() ineffective. 31 - * 32 - * At the same time, a solution where a big memory region is 33 - * reserved for a device is suboptimal since often more memory is 34 - * reserved then strictly required and, moreover, the memory is 35 - * inaccessible to page system even if device drivers don't use it. 36 - * 37 - * CMA tries to solve this issue by operating on memory regions 38 - * where only movable pages can be allocated from. This way, kernel 39 - * can use the memory for pagecache and when device driver requests 40 - * it, allocated pages can be migrated. 41 - * 42 - * Driver usage 43 - * 44 - * CMA should not be used by the device drivers directly. It is 45 - * only a helper framework for dma-mapping subsystem. 46 - * 47 - * For more information, see kernel-docs in kernel/dma/contiguous.c 48 - */ 49 - 50 - #ifdef __KERNEL__ 51 - 52 - #include <linux/device.h> 53 - #include <linux/mm.h> 54 - 55 - struct cma; 56 - struct page; 57 - 58 - #ifdef CONFIG_DMA_CMA 59 - 60 - extern struct cma *dma_contiguous_default_area; 61 - 62 - static inline struct cma *dev_get_cma_area(struct device *dev) 63 - { 64 - if (dev && dev->cma_area) 65 - return dev->cma_area; 66 - return dma_contiguous_default_area; 67 - } 68 - 69 - void dma_contiguous_reserve(phys_addr_t addr_limit); 70 - 71 - int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, 72 - phys_addr_t limit, struct cma **res_cma, 73 - bool fixed); 74 - 75 - struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, 76 - unsigned int order, bool no_warn); 77 - bool dma_release_from_contiguous(struct device *dev, struct page *pages, 78 - int count); 79 - struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp); 80 - void dma_free_contiguous(struct device *dev, struct page *page, size_t size); 81 - 82 - #else 83 - 84 - static inline struct cma *dev_get_cma_area(struct device *dev) 85 - { 86 - return NULL; 87 - } 88 - 89 - static inline void dma_contiguous_reserve(phys_addr_t limit) { } 90 - 91 - static inline int dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, 92 - phys_addr_t limit, struct cma **res_cma, 93 - bool fixed) 94 - { 95 - return -ENOSYS; 96 - } 97 - 98 - static inline 99 - struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, 100 - unsigned int order, bool no_warn) 101 - { 102 - return NULL; 103 - } 104 - 105 - static inline 106 - bool dma_release_from_contiguous(struct device *dev, struct page *pages, 107 - int count) 108 - { 109 - return false; 110 - } 111 - 112 - /* Use fallback alloc() and free() when CONFIG_DMA_CMA=n */ 113 - static inline struct page *dma_alloc_contiguous(struct device *dev, size_t size, 114 - gfp_t gfp) 115 - { 116 - return NULL; 117 - } 118 - 119 - static inline void dma_free_contiguous(struct device *dev, struct page *page, 120 - size_t size) 121 - { 122 - __free_pages(page, get_order(size)); 123 - } 124 - 125 - #endif 126 - 127 - #ifdef CONFIG_DMA_PERNUMA_CMA 128 - void dma_pernuma_cma_reserve(void); 129 - #else 130 - static inline void dma_pernuma_cma_reserve(void) { } 131 - #endif 132 - 133 - #endif 134 - 135 - #endif
+65
include/linux/dma-map-ops.h
··· 8 8 9 9 #include <linux/dma-mapping.h> 10 10 11 + struct cma; 12 + 11 13 struct dma_map_ops { 12 14 void *(*alloc)(struct device *dev, size_t size, 13 15 dma_addr_t *dma_handle, gfp_t gfp, ··· 95 93 { 96 94 } 97 95 #endif /* CONFIG_DMA_OPS */ 96 + 97 + #ifdef CONFIG_DMA_CMA 98 + extern struct cma *dma_contiguous_default_area; 99 + 100 + static inline struct cma *dev_get_cma_area(struct device *dev) 101 + { 102 + if (dev && dev->cma_area) 103 + return dev->cma_area; 104 + return dma_contiguous_default_area; 105 + } 106 + 107 + void dma_contiguous_reserve(phys_addr_t addr_limit); 108 + int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, 109 + phys_addr_t limit, struct cma **res_cma, bool fixed); 110 + 111 + struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, 112 + unsigned int order, bool no_warn); 113 + bool dma_release_from_contiguous(struct device *dev, struct page *pages, 114 + int count); 115 + struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp); 116 + void dma_free_contiguous(struct device *dev, struct page *page, size_t size); 117 + #else /* CONFIG_DMA_CMA */ 118 + static inline struct cma *dev_get_cma_area(struct device *dev) 119 + { 120 + return NULL; 121 + } 122 + static inline void dma_contiguous_reserve(phys_addr_t limit) 123 + { 124 + } 125 + static inline int dma_contiguous_reserve_area(phys_addr_t size, 126 + phys_addr_t base, phys_addr_t limit, struct cma **res_cma, 127 + bool fixed) 128 + { 129 + return -ENOSYS; 130 + } 131 + static inline struct page *dma_alloc_from_contiguous(struct device *dev, 132 + size_t count, unsigned int order, bool no_warn) 133 + { 134 + return NULL; 135 + } 136 + static inline bool dma_release_from_contiguous(struct device *dev, 137 + struct page *pages, int count) 138 + { 139 + return false; 140 + } 141 + /* Use fallback alloc() and free() when CONFIG_DMA_CMA=n */ 142 + static inline struct page *dma_alloc_contiguous(struct device *dev, size_t size, 143 + gfp_t gfp) 144 + { 145 + return NULL; 146 + } 147 + static inline void dma_free_contiguous(struct device *dev, struct page *page, 148 + size_t size) 149 + { 150 + __free_pages(page, get_order(size)); 151 + } 152 + #endif /* CONFIG_DMA_CMA*/ 153 + 154 + #ifdef CONFIG_DMA_PERNUMA_CMA 155 + void dma_pernuma_cma_reserve(void); 156 + #else 157 + static inline void dma_pernuma_cma_reserve(void) { } 158 + #endif /* CONFIG_DMA_PERNUMA_CMA */ 98 159 99 160 #ifdef CONFIG_DMA_DECLARE_COHERENT 100 161 int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
+1 -1
kernel/dma/Kconfig
··· 118 118 You can disable CMA by specifying "cma=0" on the kernel's command 119 119 line. 120 120 121 - For more information see <include/linux/dma-contiguous.h>. 121 + For more information see <kernel/dma/contiguous.c>. 122 122 If unsure, say "n". 123 123 124 124 if DMA_CMA
+29 -1
kernel/dma/contiguous.c
··· 5 5 * Written by: 6 6 * Marek Szyprowski <m.szyprowski@samsung.com> 7 7 * Michal Nazarewicz <mina86@mina86.com> 8 + * 9 + * Contiguous Memory Allocator 10 + * 11 + * The Contiguous Memory Allocator (CMA) makes it possible to 12 + * allocate big contiguous chunks of memory after the system has 13 + * booted. 14 + * 15 + * Why is it needed? 16 + * 17 + * Various devices on embedded systems have no scatter-getter and/or 18 + * IO map support and require contiguous blocks of memory to 19 + * operate. They include devices such as cameras, hardware video 20 + * coders, etc. 21 + * 22 + * Such devices often require big memory buffers (a full HD frame 23 + * is, for instance, more then 2 mega pixels large, i.e. more than 6 24 + * MB of memory), which makes mechanisms such as kmalloc() or 25 + * alloc_page() ineffective. 26 + * 27 + * At the same time, a solution where a big memory region is 28 + * reserved for a device is suboptimal since often more memory is 29 + * reserved then strictly required and, moreover, the memory is 30 + * inaccessible to page system even if device drivers don't use it. 31 + * 32 + * CMA tries to solve this issue by operating on memory regions 33 + * where only movable pages can be allocated from. This way, kernel 34 + * can use the memory for pagecache and when device driver requests 35 + * it, allocated pages can be migrated. 8 36 */ 9 37 10 38 #define pr_fmt(fmt) "cma: " fmt ··· 49 21 #include <linux/memblock.h> 50 22 #include <linux/err.h> 51 23 #include <linux/sizes.h> 52 - #include <linux/dma-contiguous.h> 24 + #include <linux/dma-map-ops.h> 53 25 #include <linux/cma.h> 54 26 55 27 #ifdef CONFIG_CMA_SIZE_MBYTES
-1
kernel/dma/direct.c
··· 10 10 #include <linux/dma-direct.h> 11 11 #include <linux/dma-map-ops.h> 12 12 #include <linux/scatterlist.h> 13 - #include <linux/dma-contiguous.h> 14 13 #include <linux/pfn.h> 15 14 #include <linux/vmalloc.h> 16 15 #include <linux/set_memory.h>
-1
kernel/dma/ops_helpers.c
··· 3 3 * Helpers for DMA ops implementations. These generally rely on the fact that 4 4 * the allocated memory contains normal pages in the direct kernel mapping. 5 5 */ 6 - #include <linux/dma-contiguous.h> 7 6 #include <linux/dma-map-ops.h> 8 7 #include <linux/dma-noncoherent.h> 9 8
+1 -1
kernel/dma/pool.c
··· 5 5 */ 6 6 #include <linux/cma.h> 7 7 #include <linux/debugfs.h> 8 - #include <linux/dma-contiguous.h> 8 + #include <linux/dma-map-ops.h> 9 9 #include <linux/dma-direct.h> 10 10 #include <linux/dma-noncoherent.h> 11 11 #include <linux/init.h>