xref: /linux/kernel/dma/Kconfig (revision e2683c8868d03382da7e1ce8453b543a043066d1)
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
184comment "Default contiguous memory area size:"
185
186config CMA_SIZE_MBYTES
187	int "Size in Mega Bytes"
188	depends on !CMA_SIZE_SEL_PERCENTAGE
189	default 0 if X86
190	default 16
191	help
192	  Defines the size (in MiB) of the default memory area for Contiguous
193	  Memory Allocator.  If the size of 0 is selected, CMA is disabled by
194	  default, but it can be enabled by passing cma=size[MG] to the kernel.
195
196
197config CMA_SIZE_PERCENTAGE
198	int "Percentage of total memory"
199	depends on !CMA_SIZE_SEL_MBYTES
200	default 0 if X86
201	default 10
202	help
203	  Defines the size of the default memory area for Contiguous Memory
204	  Allocator as a percentage of the total memory in the system.
205	  If 0 percent is selected, CMA is disabled by default, but it can be
206	  enabled by passing cma=size[MG] to the kernel.
207
208choice
209	prompt "Selected region size"
210	default CMA_SIZE_SEL_MBYTES
211
212config CMA_SIZE_SEL_MBYTES
213	bool "Use mega bytes value only"
214
215config CMA_SIZE_SEL_PERCENTAGE
216	bool "Use percentage value only"
217
218config CMA_SIZE_SEL_MIN
219	bool "Use lower value (minimum)"
220
221config CMA_SIZE_SEL_MAX
222	bool "Use higher value (maximum)"
223
224endchoice
225
226config CMA_ALIGNMENT
227	int "Maximum PAGE_SIZE order of alignment for contiguous buffers"
228	range 2 12
229	default 8
230	help
231	  DMA mapping framework by default aligns all buffers to the smallest
232	  PAGE_SIZE order which is greater than or equal to the requested buffer
233	  size. This works well for buffers up to a few hundreds kilobytes, but
234	  for larger buffers it just a memory waste. With this parameter you can
235	  specify the maximum PAGE_SIZE order for contiguous buffers. Larger
236	  buffers will be aligned only to this specified order. The order is
237	  expressed as a power of two multiplied by the PAGE_SIZE.
238
239	  For example, if your system defaults to 4KiB pages, the order value
240	  of 8 means that the buffers will be aligned up to 1MiB only.
241
242	  If unsure, leave the default value "8".
243
244endif
245
246config DMA_API_DEBUG
247	bool "Enable debugging of DMA-API usage"
248	select NEED_DMA_MAP_STATE
249	help
250	  Enable this option to debug the use of the DMA API by device drivers.
251	  With this option you will be able to detect common bugs in device
252	  drivers like double-freeing of DMA mappings or freeing mappings that
253	  were never allocated.
254
255	  This option causes a performance degradation.  Use only if you want to
256	  debug device drivers and dma interactions.
257
258	  If unsure, say N.
259
260config DMA_MAP_BENCHMARK
261	bool "Enable benchmarking of streaming DMA mapping"
262	depends on DEBUG_FS
263	help
264	  Provides /sys/kernel/debug/dma_map_benchmark that helps with testing
265	  performance of dma_(un)map_page.
266
267	  See tools/testing/selftests/dma/dma_map_benchmark.c
268