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