1# SPDX-License-Identifier: GPL-2.0-only 2 3config NO_DMA 4 bool 5 6config HAS_DMA 7 bool 8 depends on !NO_DMA 9 default y 10 11config DMA_OPS_HELPERS 12 bool 13 14# 15# IOMMU drivers that can bypass the IOMMU code and optionally use the direct 16# mapping fast path should select this option and set the dma_ops_bypass 17# flag in struct device where applicable 18# 19config DMA_OPS_BYPASS 20 bool 21 22# Lets platform IOMMU driver choose between bypass and IOMMU 23config ARCH_HAS_DMA_MAP_DIRECT 24 bool 25 26config NEED_SG_DMA_FLAGS 27 bool 28 29config NEED_SG_DMA_LENGTH 30 bool 31 32config NEED_DMA_MAP_STATE 33 bool 34 35config ARCH_DMA_ADDR_T_64BIT 36 def_bool 64BIT || PHYS_ADDR_T_64BIT 37 38config ARCH_HAS_DMA_SET_MASK 39 bool 40 41# 42# Select this option if the architecture needs special handling for 43# DMA_ATTR_WRITE_COMBINE. Normally the "uncached" mapping should be what 44# people think of when saying write combine, so very few platforms should 45# need to enable this. 46# 47config ARCH_HAS_DMA_WRITE_COMBINE 48 bool 49 50config DMA_DECLARE_COHERENT 51 bool 52 53config ARCH_HAS_SETUP_DMA_OPS 54 bool 55 56config ARCH_HAS_TEARDOWN_DMA_OPS 57 bool 58 59config ARCH_HAS_SYNC_DMA_FOR_DEVICE 60 bool 61 62config ARCH_HAS_SYNC_DMA_FOR_CPU 63 bool 64 select NEED_DMA_MAP_STATE 65 66config ARCH_HAS_SYNC_DMA_FOR_CPU_ALL 67 bool 68 69config ARCH_HAS_DMA_PREP_COHERENT 70 bool 71 72config ARCH_HAS_FORCE_DMA_UNENCRYPTED 73 bool 74 75# 76# Select this option if the architecture assumes DMA devices are coherent 77# by default. 78# 79config ARCH_DMA_DEFAULT_COHERENT 80 bool 81 82config SWIOTLB 83 bool 84 select NEED_DMA_MAP_STATE 85 86config SWIOTLB_DYNAMIC 87 bool "Dynamic allocation of DMA bounce buffers" 88 default n 89 depends on SWIOTLB 90 help 91 This enables dynamic resizing of the software IO TLB. The kernel 92 starts with one memory pool at boot and it will allocate additional 93 pools as needed. To reduce run-time kernel memory requirements, you 94 may have to specify a smaller size of the initial pool using 95 "swiotlb=" on the kernel command line. 96 97 If unsure, say N. 98 99config DMA_BOUNCE_UNALIGNED_KMALLOC 100 bool 101 depends on SWIOTLB 102 103config DMA_NEED_SYNC 104 def_bool ARCH_HAS_SYNC_DMA_FOR_DEVICE || ARCH_HAS_SYNC_DMA_FOR_CPU || \ 105 ARCH_HAS_SYNC_DMA_FOR_CPU_ALL || DMA_API_DEBUG || \ 106 ARCH_HAS_DMA_OPS || SWIOTLB 107 108config DMA_RESTRICTED_POOL 109 bool "DMA Restricted Pool" 110 depends on OF && OF_RESERVED_MEM && SWIOTLB 111 help 112 This enables support for restricted DMA pools which provide a level of 113 DMA memory protection on systems with limited hardware protection 114 capabilities, such as those lacking an IOMMU. 115 116 For more information see 117 <Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt> 118 and <kernel/dma/swiotlb.c>. 119 If unsure, say "n". 120 121# 122# Should be selected if we can mmap non-coherent mappings to userspace. 123# The only thing that is really required is a way to set an uncached bit 124# in the pagetables 125# 126config DMA_NONCOHERENT_MMAP 127 default y if !MMU 128 bool 129 130config DMA_COHERENT_POOL 131 select GENERIC_ALLOCATOR 132 bool 133 134config DMA_GLOBAL_POOL 135 select DMA_DECLARE_COHERENT 136 depends on !ARCH_HAS_DMA_SET_UNCACHED 137 depends on !DMA_DIRECT_REMAP 138 bool 139 140config DMA_DIRECT_REMAP 141 bool 142 select DMA_COHERENT_POOL 143 select DMA_NONCOHERENT_MMAP 144 145# 146# Fallback to arch code for DMA allocations. This should eventually go away. 147# 148config ARCH_HAS_DMA_ALLOC 149 depends on !ARCH_HAS_DMA_SET_UNCACHED 150 depends on !DMA_DIRECT_REMAP 151 depends on !DMA_GLOBAL_POOL 152 bool 153 154config DMA_CMA 155 bool "DMA Contiguous Memory Allocator" 156 depends on HAVE_DMA_CONTIGUOUS && CMA 157 help 158 This enables the Contiguous Memory Allocator which allows drivers 159 to allocate big physically-contiguous blocks of memory for use with 160 hardware components that do not support I/O map nor scatter-gather. 161 162 You can disable CMA by specifying "cma=0" on the kernel's command 163 line. 164 165 For more information see <kernel/dma/contiguous.c>. 166 If unsure, say "n". 167 168if DMA_CMA 169 170config DMA_NUMA_CMA 171 bool "Enable separate DMA Contiguous Memory Area for NUMA Node" 172 depends on NUMA 173 help 174 Enable this option to get numa CMA areas so that NUMA devices 175 can get local memory by DMA coherent APIs. 176 177 You can set the size of pernuma CMA by specifying "cma_pernuma=size" 178 or set the node id and its size of CMA by specifying "numa_cma= 179 <node>:size[,<node>:size]" on the kernel's command line. 180 181comment "Default contiguous memory area size:" 182 183config CMA_SIZE_MBYTES 184 int "Size in Mega Bytes" 185 depends on !CMA_SIZE_SEL_PERCENTAGE 186 default 0 if X86 187 default 16 188 help 189 Defines the size (in MiB) of the default memory area for Contiguous 190 Memory Allocator. If the size of 0 is selected, CMA is disabled by 191 default, but it can be enabled by passing cma=size[MG] to the kernel. 192 193 194config CMA_SIZE_PERCENTAGE 195 int "Percentage of total memory" 196 depends on !CMA_SIZE_SEL_MBYTES 197 default 0 if X86 198 default 10 199 help 200 Defines the size of the default memory area for Contiguous Memory 201 Allocator as a percentage of the total memory in the system. 202 If 0 percent is selected, CMA is disabled by default, but it can be 203 enabled by passing cma=size[MG] to the kernel. 204 205choice 206 prompt "Selected region size" 207 default CMA_SIZE_SEL_MBYTES 208 209config CMA_SIZE_SEL_MBYTES 210 bool "Use mega bytes value only" 211 212config CMA_SIZE_SEL_PERCENTAGE 213 bool "Use percentage value only" 214 215config CMA_SIZE_SEL_MIN 216 bool "Use lower value (minimum)" 217 218config CMA_SIZE_SEL_MAX 219 bool "Use higher value (maximum)" 220 221endchoice 222 223config CMA_ALIGNMENT 224 int "Maximum PAGE_SIZE order of alignment for contiguous buffers" 225 range 2 12 226 default 8 227 help 228 DMA mapping framework by default aligns all buffers to the smallest 229 PAGE_SIZE order which is greater than or equal to the requested buffer 230 size. This works well for buffers up to a few hundreds kilobytes, but 231 for larger buffers it just a memory waste. With this parameter you can 232 specify the maximum PAGE_SIZE order for contiguous buffers. Larger 233 buffers will be aligned only to this specified order. The order is 234 expressed as a power of two multiplied by the PAGE_SIZE. 235 236 For example, if your system defaults to 4KiB pages, the order value 237 of 8 means that the buffers will be aligned up to 1MiB only. 238 239 If unsure, leave the default value "8". 240 241endif 242 243config DMA_API_DEBUG 244 bool "Enable debugging of DMA-API usage" 245 select NEED_DMA_MAP_STATE 246 help 247 Enable this option to debug the use of the DMA API by device drivers. 248 With this option you will be able to detect common bugs in device 249 drivers like double-freeing of DMA mappings or freeing mappings that 250 were never allocated. 251 252 This option causes a performance degradation. Use only if you want to 253 debug device drivers and dma interactions. 254 255 If unsure, say N. 256 257config DMA_MAP_BENCHMARK 258 bool "Enable benchmarking of streaming DMA mapping" 259 depends on DEBUG_FS 260 help 261 Provides /sys/kernel/debug/dma_map_benchmark that helps with testing 262 performance of dma_(un)map_page. 263 264 See tools/testing/selftests/dma/dma_map_benchmark.c 265