xref: /linux/kernel/dma/Kconfig (revision 22e4a348f87c59df2c02f1efb7ba9a56b622c7b8)
1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only
2cf65a0f6SChristoph Hellwig
3846f9e1fSChristoph Hellwigconfig NO_DMA
4846f9e1fSChristoph Hellwig	bool
5846f9e1fSChristoph Hellwig
6cf65a0f6SChristoph Hellwigconfig HAS_DMA
7cf65a0f6SChristoph Hellwig	bool
8cf65a0f6SChristoph Hellwig	depends on !NO_DMA
9cf65a0f6SChristoph Hellwig	default y
10cf65a0f6SChristoph Hellwig
112f9237d4SChristoph Hellwigconfig DMA_OPS
12ef1a85b6SChristoph Hellwig	depends on HAS_DMA
132f9237d4SChristoph Hellwig	bool
142f9237d4SChristoph Hellwig
15d35834c6SChristoph Hellwig#
16d35834c6SChristoph Hellwig# IOMMU drivers that can bypass the IOMMU code and optionally use the direct
17d35834c6SChristoph Hellwig# mapping fast path should select this option and set the dma_ops_bypass
18d35834c6SChristoph Hellwig# flag in struct device where applicable
19d35834c6SChristoph Hellwig#
20d35834c6SChristoph Hellwigconfig DMA_OPS_BYPASS
21d35834c6SChristoph Hellwig	bool
22d35834c6SChristoph Hellwig
238d8d53cfSAlexey Kardashevskiy# Lets platform IOMMU driver choose between bypass and IOMMU
248d8d53cfSAlexey Kardashevskiyconfig ARCH_HAS_DMA_MAP_DIRECT
258d8d53cfSAlexey Kardashevskiy	bool
268d8d53cfSAlexey Kardashevskiy
27af2880ecSRobin Murphyconfig NEED_SG_DMA_FLAGS
28af2880ecSRobin Murphy	bool
29af2880ecSRobin Murphy
30cf65a0f6SChristoph Hellwigconfig NEED_SG_DMA_LENGTH
31cf65a0f6SChristoph Hellwig	bool
32cf65a0f6SChristoph Hellwig
33cf65a0f6SChristoph Hellwigconfig NEED_DMA_MAP_STATE
34cf65a0f6SChristoph Hellwig	bool
35cf65a0f6SChristoph Hellwig
36cf65a0f6SChristoph Hellwigconfig ARCH_DMA_ADDR_T_64BIT
37cf65a0f6SChristoph Hellwig	def_bool 64BIT || PHYS_ADDR_T_64BIT
38cf65a0f6SChristoph Hellwig
3911ddce15SChristoph Hellwigconfig ARCH_HAS_DMA_SET_MASK
4011ddce15SChristoph Hellwig	bool
4111ddce15SChristoph Hellwig
42419e2f18SChristoph Hellwig#
43419e2f18SChristoph Hellwig# Select this option if the architecture needs special handling for
44419e2f18SChristoph Hellwig# DMA_ATTR_WRITE_COMBINE.  Normally the "uncached" mapping should be what
454d3af20eSSui Jingfeng# people think of when saying write combine, so very few platforms should
46419e2f18SChristoph Hellwig# need to enable this.
47419e2f18SChristoph Hellwig#
48419e2f18SChristoph Hellwigconfig ARCH_HAS_DMA_WRITE_COMBINE
49419e2f18SChristoph Hellwig	bool
50419e2f18SChristoph Hellwig
51abdaf11aSChristoph Hellwig#
52abdaf11aSChristoph Hellwig# Select if the architectures provides the arch_dma_mark_clean hook
53abdaf11aSChristoph Hellwig#
54abdaf11aSChristoph Hellwigconfig ARCH_HAS_DMA_MARK_CLEAN
55abdaf11aSChristoph Hellwig	bool
56abdaf11aSChristoph Hellwig
57ff4c25f2SChristoph Hellwigconfig DMA_DECLARE_COHERENT
58cf65a0f6SChristoph Hellwig	bool
59cf65a0f6SChristoph Hellwig
60347cb6afSChristoph Hellwigconfig ARCH_HAS_SETUP_DMA_OPS
61347cb6afSChristoph Hellwig	bool
62347cb6afSChristoph Hellwig
63dc2acdedSChristoph Hellwigconfig ARCH_HAS_TEARDOWN_DMA_OPS
64cf65a0f6SChristoph Hellwig	bool
65cf65a0f6SChristoph Hellwig
66cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_DEVICE
67cf65a0f6SChristoph Hellwig	bool
68cf65a0f6SChristoph Hellwig
69cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU
70cf65a0f6SChristoph Hellwig	bool
71cf65a0f6SChristoph Hellwig	select NEED_DMA_MAP_STATE
72cf65a0f6SChristoph Hellwig
73684f7e91SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
74684f7e91SChristoph Hellwig	bool
75684f7e91SChristoph Hellwig
7613bf5cedSChristoph Hellwigconfig ARCH_HAS_DMA_PREP_COHERENT
7713bf5cedSChristoph Hellwig	bool
7813bf5cedSChristoph Hellwig
799087c375STom Lendackyconfig ARCH_HAS_FORCE_DMA_UNENCRYPTED
809087c375STom Lendacky	bool
819087c375STom Lendacky
821d3f56b2SJiaxun Yang#
831d3f56b2SJiaxun Yang# Select this option if the architecture assumes DMA devices are coherent
841d3f56b2SJiaxun Yang# by default.
851d3f56b2SJiaxun Yang#
861d3f56b2SJiaxun Yangconfig ARCH_DMA_DEFAULT_COHERENT
871d3f56b2SJiaxun Yang	bool
881d3f56b2SJiaxun Yang
89cf65a0f6SChristoph Hellwigconfig SWIOTLB
90cf65a0f6SChristoph Hellwig	bool
91cf65a0f6SChristoph Hellwig	select NEED_DMA_MAP_STATE
92f0edfea8SChristoph Hellwig
93370645f4SCatalin Marinasconfig DMA_BOUNCE_UNALIGNED_KMALLOC
94370645f4SCatalin Marinas	bool
95370645f4SCatalin Marinas	depends on SWIOTLB
96370645f4SCatalin Marinas
970b84e4f8SClaire Changconfig DMA_RESTRICTED_POOL
980b84e4f8SClaire Chang	bool "DMA Restricted Pool"
99f3c4b134SClaire Chang	depends on OF && OF_RESERVED_MEM && SWIOTLB
1000b84e4f8SClaire Chang	help
1010b84e4f8SClaire Chang	  This enables support for restricted DMA pools which provide a level of
1020b84e4f8SClaire Chang	  DMA memory protection on systems with limited hardware protection
1030b84e4f8SClaire Chang	  capabilities, such as those lacking an IOMMU.
1040b84e4f8SClaire Chang
1050b84e4f8SClaire Chang	  For more information see
1060b84e4f8SClaire Chang	  <Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt>
1070b84e4f8SClaire Chang	  and <kernel/dma/swiotlb.c>.
1080b84e4f8SClaire Chang	  If unsure, say "n".
1090b84e4f8SClaire Chang
11034dc0ea6SChristoph Hellwig#
11134dc0ea6SChristoph Hellwig# Should be selected if we can mmap non-coherent mappings to userspace.
11234dc0ea6SChristoph Hellwig# The only thing that is really required is a way to set an uncached bit
11334dc0ea6SChristoph Hellwig# in the pagetables
11434dc0ea6SChristoph Hellwig#
11534dc0ea6SChristoph Hellwigconfig DMA_NONCOHERENT_MMAP
1161fbf57d0SChristoph Hellwig	default y if !MMU
11734dc0ea6SChristoph Hellwig	bool
11834dc0ea6SChristoph Hellwig
119dbed452aSDavid Rientjesconfig DMA_COHERENT_POOL
120d07ae4c4SChristoph Hellwig	select GENERIC_ALLOCATOR
121dbed452aSDavid Rientjes	bool
122dbed452aSDavid Rientjes
123faf4ef82SChristoph Hellwigconfig DMA_GLOBAL_POOL
124faf4ef82SChristoph Hellwig	select DMA_DECLARE_COHERENT
125faf4ef82SChristoph Hellwig	bool
126faf4ef82SChristoph Hellwig
127e860c299SDavid Rientjesconfig DMA_DIRECT_REMAP
128e860c299SDavid Rientjes	bool
129e860c299SDavid Rientjes	select DMA_COHERENT_POOL
130f5ff79fdSChristoph Hellwig	select DMA_NONCOHERENT_MMAP
131e860c299SDavid Rientjes
132ddb26d8eSChristoph Hellwigconfig DMA_CMA
133ddb26d8eSChristoph Hellwig	bool "DMA Contiguous Memory Allocator"
134ddb26d8eSChristoph Hellwig	depends on HAVE_DMA_CONTIGUOUS && CMA
135ddb26d8eSChristoph Hellwig	help
136ddb26d8eSChristoph Hellwig	  This enables the Contiguous Memory Allocator which allows drivers
137ddb26d8eSChristoph Hellwig	  to allocate big physically-contiguous blocks of memory for use with
138ddb26d8eSChristoph Hellwig	  hardware components that do not support I/O map nor scatter-gather.
139ddb26d8eSChristoph Hellwig
140ddb26d8eSChristoph Hellwig	  You can disable CMA by specifying "cma=0" on the kernel's command
141ddb26d8eSChristoph Hellwig	  line.
142ddb26d8eSChristoph Hellwig
1430b1abd1fSChristoph Hellwig	  For more information see <kernel/dma/contiguous.c>.
144ddb26d8eSChristoph Hellwig	  If unsure, say "n".
145ddb26d8eSChristoph Hellwig
146ddb26d8eSChristoph Hellwigif  DMA_CMA
147b7176c26SBarry Song
148b7176c26SBarry Songconfig DMA_PERNUMA_CMA
149b7176c26SBarry Song	bool "Enable separate DMA Contiguous Memory Area for each NUMA Node"
150*22e4a348SYajun Deng	default NUMA
151b7176c26SBarry Song	help
152*22e4a348SYajun Deng	  Enable this option to get pernuma CMA areas so that NUMA devices
153*22e4a348SYajun Deng	  can get local memory by DMA coherent APIs.
154b7176c26SBarry Song
155b7176c26SBarry Song	  You can set the size of pernuma CMA by specifying "cma_pernuma=size"
156b7176c26SBarry Song	  on the kernel's command line.
157b7176c26SBarry Song
158ddb26d8eSChristoph Hellwigcomment "Default contiguous memory area size:"
159ddb26d8eSChristoph Hellwig
160ddb26d8eSChristoph Hellwigconfig CMA_SIZE_MBYTES
161ddb26d8eSChristoph Hellwig	int "Size in Mega Bytes"
162ddb26d8eSChristoph Hellwig	depends on !CMA_SIZE_SEL_PERCENTAGE
163ddb26d8eSChristoph Hellwig	default 0 if X86
164ddb26d8eSChristoph Hellwig	default 16
165ddb26d8eSChristoph Hellwig	help
166ddb26d8eSChristoph Hellwig	  Defines the size (in MiB) of the default memory area for Contiguous
167ddb26d8eSChristoph Hellwig	  Memory Allocator.  If the size of 0 is selected, CMA is disabled by
168ddb26d8eSChristoph Hellwig	  default, but it can be enabled by passing cma=size[MG] to the kernel.
169ddb26d8eSChristoph Hellwig
170ddb26d8eSChristoph Hellwig
171ddb26d8eSChristoph Hellwigconfig CMA_SIZE_PERCENTAGE
172ddb26d8eSChristoph Hellwig	int "Percentage of total memory"
173ddb26d8eSChristoph Hellwig	depends on !CMA_SIZE_SEL_MBYTES
174ddb26d8eSChristoph Hellwig	default 0 if X86
175ddb26d8eSChristoph Hellwig	default 10
176ddb26d8eSChristoph Hellwig	help
177ddb26d8eSChristoph Hellwig	  Defines the size of the default memory area for Contiguous Memory
178ddb26d8eSChristoph Hellwig	  Allocator as a percentage of the total memory in the system.
179ddb26d8eSChristoph Hellwig	  If 0 percent is selected, CMA is disabled by default, but it can be
180ddb26d8eSChristoph Hellwig	  enabled by passing cma=size[MG] to the kernel.
181ddb26d8eSChristoph Hellwig
182ddb26d8eSChristoph Hellwigchoice
183ddb26d8eSChristoph Hellwig	prompt "Selected region size"
184ddb26d8eSChristoph Hellwig	default CMA_SIZE_SEL_MBYTES
185ddb26d8eSChristoph Hellwig
186ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MBYTES
187ddb26d8eSChristoph Hellwig	bool "Use mega bytes value only"
188ddb26d8eSChristoph Hellwig
189ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_PERCENTAGE
190ddb26d8eSChristoph Hellwig	bool "Use percentage value only"
191ddb26d8eSChristoph Hellwig
192ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MIN
193ddb26d8eSChristoph Hellwig	bool "Use lower value (minimum)"
194ddb26d8eSChristoph Hellwig
195ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MAX
196ddb26d8eSChristoph Hellwig	bool "Use higher value (maximum)"
197ddb26d8eSChristoph Hellwig
198ddb26d8eSChristoph Hellwigendchoice
199ddb26d8eSChristoph Hellwig
200ddb26d8eSChristoph Hellwigconfig CMA_ALIGNMENT
201ddb26d8eSChristoph Hellwig	int "Maximum PAGE_SIZE order of alignment for contiguous buffers"
2020de32796SPaul Cercueil	range 2 12
203ddb26d8eSChristoph Hellwig	default 8
204ddb26d8eSChristoph Hellwig	help
205ddb26d8eSChristoph Hellwig	  DMA mapping framework by default aligns all buffers to the smallest
206ddb26d8eSChristoph Hellwig	  PAGE_SIZE order which is greater than or equal to the requested buffer
207ddb26d8eSChristoph Hellwig	  size. This works well for buffers up to a few hundreds kilobytes, but
208ddb26d8eSChristoph Hellwig	  for larger buffers it just a memory waste. With this parameter you can
209ddb26d8eSChristoph Hellwig	  specify the maximum PAGE_SIZE order for contiguous buffers. Larger
210ddb26d8eSChristoph Hellwig	  buffers will be aligned only to this specified order. The order is
211ddb26d8eSChristoph Hellwig	  expressed as a power of two multiplied by the PAGE_SIZE.
212ddb26d8eSChristoph Hellwig
213ddb26d8eSChristoph Hellwig	  For example, if your system defaults to 4KiB pages, the order value
214ddb26d8eSChristoph Hellwig	  of 8 means that the buffers will be aligned up to 1MiB only.
215ddb26d8eSChristoph Hellwig
216ddb26d8eSChristoph Hellwig	  If unsure, leave the default value "8".
217ddb26d8eSChristoph Hellwig
218ddb26d8eSChristoph Hellwigendif
219ddb26d8eSChristoph Hellwig
22070ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG
22170ca7ba2SAndy Shevchenko	bool "Enable debugging of DMA-API usage"
22270ca7ba2SAndy Shevchenko	select NEED_DMA_MAP_STATE
22370ca7ba2SAndy Shevchenko	help
22470ca7ba2SAndy Shevchenko	  Enable this option to debug the use of the DMA API by device drivers.
22570ca7ba2SAndy Shevchenko	  With this option you will be able to detect common bugs in device
22670ca7ba2SAndy Shevchenko	  drivers like double-freeing of DMA mappings or freeing mappings that
22770ca7ba2SAndy Shevchenko	  were never allocated.
22870ca7ba2SAndy Shevchenko
22970ca7ba2SAndy Shevchenko	  This option causes a performance degradation.  Use only if you want to
23070ca7ba2SAndy Shevchenko	  debug device drivers and dma interactions.
23170ca7ba2SAndy Shevchenko
23270ca7ba2SAndy Shevchenko	  If unsure, say N.
23370ca7ba2SAndy Shevchenko
23470ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG_SG
23570ca7ba2SAndy Shevchenko	bool "Debug DMA scatter-gather usage"
23670ca7ba2SAndy Shevchenko	default y
23770ca7ba2SAndy Shevchenko	depends on DMA_API_DEBUG
23870ca7ba2SAndy Shevchenko	help
23970ca7ba2SAndy Shevchenko	  Perform extra checking that callers of dma_map_sg() have respected the
24070ca7ba2SAndy Shevchenko	  appropriate segment length/boundary limits for the given device when
24170ca7ba2SAndy Shevchenko	  preparing DMA scatterlists.
24270ca7ba2SAndy Shevchenko
24370ca7ba2SAndy Shevchenko	  This is particularly likely to have been overlooked in cases where the
24470ca7ba2SAndy Shevchenko	  dma_map_sg() API is used for general bulk mapping of pages rather than
24570ca7ba2SAndy Shevchenko	  preparing literal scatter-gather descriptors, where there is a risk of
24670ca7ba2SAndy Shevchenko	  unexpected behaviour from DMA API implementations if the scatterlist
24770ca7ba2SAndy Shevchenko	  is technically out-of-spec.
24870ca7ba2SAndy Shevchenko
24970ca7ba2SAndy Shevchenko	  If unsure, say N.
25065789daaSBarry Song
25165789daaSBarry Songconfig DMA_MAP_BENCHMARK
25265789daaSBarry Song	bool "Enable benchmarking of streaming DMA mapping"
25365789daaSBarry Song	depends on DEBUG_FS
25465789daaSBarry Song	help
25565789daaSBarry Song	  Provides /sys/kernel/debug/dma_map_benchmark that helps with testing
25665789daaSBarry Song	  performance of dma_(un)map_page.
25765789daaSBarry Song
25865789daaSBarry Song	  See tools/testing/selftests/dma/dma_map_benchmark.c
259