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 75config ARCH_HAS_BATCHED_DMA_SYNC 76 bool 77 78# 79# Select this option if the architecture assumes DMA devices are coherent 80# by default. 81# 82config ARCH_DMA_DEFAULT_COHERENT 83 bool 84 85config SWIOTLB 86 bool 87 select NEED_DMA_MAP_STATE 88 89config SWIOTLB_DYNAMIC 90 bool "Dynamic allocation of DMA bounce buffers" 91 default n 92 depends on SWIOTLB 93 help 94 This enables dynamic resizing of the software IO TLB. The kernel 95 starts with one memory pool at boot and it will allocate additional 96 pools as needed. To reduce run-time kernel memory requirements, you 97 may have to specify a smaller size of the initial pool using 98 "swiotlb=" on the kernel command line. 99 100 If unsure, say N. 101 102config DMA_BOUNCE_UNALIGNED_KMALLOC 103 bool 104 depends on SWIOTLB 105 106config DMA_NEED_SYNC 107 def_bool ARCH_HAS_SYNC_DMA_FOR_DEVICE || ARCH_HAS_SYNC_DMA_FOR_CPU || \ 108 ARCH_HAS_SYNC_DMA_FOR_CPU_ALL || DMA_API_DEBUG || \ 109 ARCH_HAS_DMA_OPS || SWIOTLB 110 111config DMA_RESTRICTED_POOL 112 bool "DMA Restricted Pool" 113 depends on OF && OF_RESERVED_MEM && SWIOTLB 114 help 115 This enables support for restricted DMA pools which provide a level of 116 DMA memory protection on systems with limited hardware protection 117 capabilities, such as those lacking an IOMMU. 118 119 For more information see 120 <Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt> 121 and <kernel/dma/swiotlb.c>. 122 If unsure, say "n". 123 124# 125# Should be selected if we can mmap non-coherent mappings to userspace. 126# The only thing that is really required is a way to set an uncached bit 127# in the pagetables 128# 129config DMA_NONCOHERENT_MMAP 130 default y if !MMU 131 bool 132 133config DMA_COHERENT_POOL 134 select GENERIC_ALLOCATOR 135 bool 136 137config DMA_GLOBAL_POOL 138 select DMA_DECLARE_COHERENT 139 depends on !ARCH_HAS_DMA_SET_UNCACHED 140 depends on !DMA_DIRECT_REMAP 141 bool 142 143config DMA_DIRECT_REMAP 144 bool 145 select DMA_COHERENT_POOL 146 select DMA_NONCOHERENT_MMAP 147 148# 149# Fallback to arch code for DMA allocations. This should eventually go away. 150# 151config ARCH_HAS_DMA_ALLOC 152 depends on !ARCH_HAS_DMA_SET_UNCACHED 153 depends on !DMA_DIRECT_REMAP 154 depends on !DMA_GLOBAL_POOL 155 bool 156 157config DMA_CMA 158 bool "DMA Contiguous Memory Allocator" 159 depends on HAVE_DMA_CONTIGUOUS && CMA 160 help 161 This enables the Contiguous Memory Allocator which allows drivers 162 to allocate big physically-contiguous blocks of memory for use with 163 hardware components that do not support I/O map nor scatter-gather. 164 165 You can disable CMA by specifying "cma=0" on the kernel's command 166 line. 167 168 For more information see <kernel/dma/contiguous.c>. 169 If unsure, say "n". 170 171if DMA_CMA 172 173config DMA_NUMA_CMA 174 bool "Enable separate DMA Contiguous Memory Area for NUMA Node" 175 depends on NUMA 176 help 177 Enable this option to get numa CMA areas so that NUMA devices 178 can get local memory by DMA coherent APIs. 179 180 You can set the size of pernuma CMA by specifying "cma_pernuma=size" 181 or set the node id and its size of CMA by specifying "numa_cma= 182 <node>:size[,<node>:size]" on the kernel's command line. 183 184config CMA_SIZE_PERNUMA 185 bool "Default CMA area per NUMA node" 186 depends on DMA_NUMA_CMA 187 default y 188 help 189 On systems with more than one NUMA node, the selected CMA 190 area size will be also allocated on each additional node, 191 so that most devices may have benefit from better DMA 192 locality without an explicit command-line opt-in. 193 194comment "Default contiguous memory area size:" 195 196config CMA_SIZE_MBYTES 197 int "Size in Mega Bytes" 198 depends on !CMA_SIZE_SEL_PERCENTAGE 199 default 0 if X86 200 default 16 201 help 202 Defines the size (in MiB) of the default memory area for Contiguous 203 Memory Allocator. If the size of 0 is selected, CMA is disabled by 204 default, but it can be enabled by passing cma=size[MG] to the kernel. 205 206 207config CMA_SIZE_PERCENTAGE 208 int "Percentage of total memory" 209 depends on !CMA_SIZE_SEL_MBYTES 210 default 0 if X86 211 default 10 212 help 213 Defines the size of the default memory area for Contiguous Memory 214 Allocator as a percentage of the total memory in the system. 215 If 0 percent is selected, CMA is disabled by default, but it can be 216 enabled by passing cma=size[MG] to the kernel. 217 218choice 219 prompt "Selected region size" 220 default CMA_SIZE_SEL_MBYTES 221 222config CMA_SIZE_SEL_MBYTES 223 bool "Use mega bytes value only" 224 225config CMA_SIZE_SEL_PERCENTAGE 226 bool "Use percentage value only" 227 228config CMA_SIZE_SEL_MIN 229 bool "Use lower value (minimum)" 230 231config CMA_SIZE_SEL_MAX 232 bool "Use higher value (maximum)" 233 234endchoice 235 236config CMA_ALIGNMENT 237 int "Maximum PAGE_SIZE order of alignment for contiguous buffers" 238 range 2 12 239 default 8 240 help 241 DMA mapping framework by default aligns all buffers to the smallest 242 PAGE_SIZE order which is greater than or equal to the requested buffer 243 size. This works well for buffers up to a few hundreds kilobytes, but 244 for larger buffers it just a memory waste. With this parameter you can 245 specify the maximum PAGE_SIZE order for contiguous buffers. Larger 246 buffers will be aligned only to this specified order. The order is 247 expressed as a power of two multiplied by the PAGE_SIZE. 248 249 For example, if your system defaults to 4KiB pages, the order value 250 of 8 means that the buffers will be aligned up to 1MiB only. 251 252 If unsure, leave the default value "8". 253 254endif 255 256config DMA_API_DEBUG 257 bool "Enable debugging of DMA-API usage" 258 select NEED_DMA_MAP_STATE 259 help 260 Enable this option to debug the use of the DMA API by device drivers. 261 With this option you will be able to detect common bugs in device 262 drivers like double-freeing of DMA mappings or freeing mappings that 263 were never allocated. 264 265 This option causes a performance degradation. Use only if you want to 266 debug device drivers and dma interactions. 267 268 If unsure, say N. 269 270config DMA_MAP_BENCHMARK 271 bool "Enable benchmarking of streaming DMA mapping" 272 depends on DEBUG_FS 273 help 274 Provides /sys/kernel/debug/dma_map_benchmark that helps with testing 275 performance of dma_(un)map_page. 276 277 See tools/testing/selftests/dma/dma_map_benchmark.c 278