projects/linux·blob master · refs

301 lines · 8.0 KiB

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