xref: /linux-6.15/kernel/dma/Kconfig (revision ddb26d8e)
1cf65a0f6SChristoph Hellwig
2cf65a0f6SChristoph Hellwigconfig HAS_DMA
3cf65a0f6SChristoph Hellwig	bool
4cf65a0f6SChristoph Hellwig	depends on !NO_DMA
5cf65a0f6SChristoph Hellwig	default y
6cf65a0f6SChristoph Hellwig
7cf65a0f6SChristoph Hellwigconfig NEED_SG_DMA_LENGTH
8cf65a0f6SChristoph Hellwig	bool
9cf65a0f6SChristoph Hellwig
10cf65a0f6SChristoph Hellwigconfig NEED_DMA_MAP_STATE
11cf65a0f6SChristoph Hellwig	bool
12cf65a0f6SChristoph Hellwig
13cf65a0f6SChristoph Hellwigconfig ARCH_DMA_ADDR_T_64BIT
14cf65a0f6SChristoph Hellwig	def_bool 64BIT || PHYS_ADDR_T_64BIT
15cf65a0f6SChristoph Hellwig
16f3ecc0ffSChristoph Hellwigconfig ARCH_HAS_DMA_COHERENCE_H
17f3ecc0ffSChristoph Hellwig	bool
18f3ecc0ffSChristoph Hellwig
19ff4c25f2SChristoph Hellwigconfig DMA_DECLARE_COHERENT
20cf65a0f6SChristoph Hellwig	bool
21cf65a0f6SChristoph Hellwig
22347cb6afSChristoph Hellwigconfig ARCH_HAS_SETUP_DMA_OPS
23347cb6afSChristoph Hellwig	bool
24347cb6afSChristoph Hellwig
25dc2acdedSChristoph Hellwigconfig ARCH_HAS_TEARDOWN_DMA_OPS
26dc2acdedSChristoph Hellwig	bool
27dc2acdedSChristoph Hellwig
28cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_DEVICE
29cf65a0f6SChristoph Hellwig	bool
30cf65a0f6SChristoph Hellwig
31cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU
32cf65a0f6SChristoph Hellwig	bool
33cf65a0f6SChristoph Hellwig	select NEED_DMA_MAP_STATE
34cf65a0f6SChristoph Hellwig
35684f7e91SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
36684f7e91SChristoph Hellwig	bool
37684f7e91SChristoph Hellwig
3858b04406SChristoph Hellwigconfig ARCH_HAS_DMA_COHERENT_TO_PFN
3958b04406SChristoph Hellwig	bool
4058b04406SChristoph Hellwig
4158b04406SChristoph Hellwigconfig ARCH_HAS_DMA_MMAP_PGPROT
4258b04406SChristoph Hellwig	bool
4358b04406SChristoph Hellwig
44cf65a0f6SChristoph Hellwigconfig DMA_NONCOHERENT_CACHE_SYNC
45cf65a0f6SChristoph Hellwig	bool
46cf65a0f6SChristoph Hellwig
47cf65a0f6SChristoph Hellwigconfig DMA_VIRT_OPS
48cf65a0f6SChristoph Hellwig	bool
49cf65a0f6SChristoph Hellwig	depends on HAS_DMA
50cf65a0f6SChristoph Hellwig
51cf65a0f6SChristoph Hellwigconfig SWIOTLB
52cf65a0f6SChristoph Hellwig	bool
53cf65a0f6SChristoph Hellwig	select NEED_DMA_MAP_STATE
54f0edfea8SChristoph Hellwig
55f0edfea8SChristoph Hellwigconfig DMA_REMAP
56f0edfea8SChristoph Hellwig	depends on MMU
57f0edfea8SChristoph Hellwig	bool
580c3b3171SChristoph Hellwig
590c3b3171SChristoph Hellwigconfig DMA_DIRECT_REMAP
600c3b3171SChristoph Hellwig	bool
610c3b3171SChristoph Hellwig	select DMA_REMAP
6270ca7ba2SAndy Shevchenko
63*ddb26d8eSChristoph Hellwigconfig DMA_CMA
64*ddb26d8eSChristoph Hellwig	bool "DMA Contiguous Memory Allocator"
65*ddb26d8eSChristoph Hellwig	depends on HAVE_DMA_CONTIGUOUS && CMA
66*ddb26d8eSChristoph Hellwig	help
67*ddb26d8eSChristoph Hellwig	  This enables the Contiguous Memory Allocator which allows drivers
68*ddb26d8eSChristoph Hellwig	  to allocate big physically-contiguous blocks of memory for use with
69*ddb26d8eSChristoph Hellwig	  hardware components that do not support I/O map nor scatter-gather.
70*ddb26d8eSChristoph Hellwig
71*ddb26d8eSChristoph Hellwig	  You can disable CMA by specifying "cma=0" on the kernel's command
72*ddb26d8eSChristoph Hellwig	  line.
73*ddb26d8eSChristoph Hellwig
74*ddb26d8eSChristoph Hellwig	  For more information see <include/linux/dma-contiguous.h>.
75*ddb26d8eSChristoph Hellwig	  If unsure, say "n".
76*ddb26d8eSChristoph Hellwig
77*ddb26d8eSChristoph Hellwigif  DMA_CMA
78*ddb26d8eSChristoph Hellwigcomment "Default contiguous memory area size:"
79*ddb26d8eSChristoph Hellwig
80*ddb26d8eSChristoph Hellwigconfig CMA_SIZE_MBYTES
81*ddb26d8eSChristoph Hellwig	int "Size in Mega Bytes"
82*ddb26d8eSChristoph Hellwig	depends on !CMA_SIZE_SEL_PERCENTAGE
83*ddb26d8eSChristoph Hellwig	default 0 if X86
84*ddb26d8eSChristoph Hellwig	default 16
85*ddb26d8eSChristoph Hellwig	help
86*ddb26d8eSChristoph Hellwig	  Defines the size (in MiB) of the default memory area for Contiguous
87*ddb26d8eSChristoph Hellwig	  Memory Allocator.  If the size of 0 is selected, CMA is disabled by
88*ddb26d8eSChristoph Hellwig	  default, but it can be enabled by passing cma=size[MG] to the kernel.
89*ddb26d8eSChristoph Hellwig
90*ddb26d8eSChristoph Hellwig
91*ddb26d8eSChristoph Hellwigconfig CMA_SIZE_PERCENTAGE
92*ddb26d8eSChristoph Hellwig	int "Percentage of total memory"
93*ddb26d8eSChristoph Hellwig	depends on !CMA_SIZE_SEL_MBYTES
94*ddb26d8eSChristoph Hellwig	default 0 if X86
95*ddb26d8eSChristoph Hellwig	default 10
96*ddb26d8eSChristoph Hellwig	help
97*ddb26d8eSChristoph Hellwig	  Defines the size of the default memory area for Contiguous Memory
98*ddb26d8eSChristoph Hellwig	  Allocator as a percentage of the total memory in the system.
99*ddb26d8eSChristoph Hellwig	  If 0 percent is selected, CMA is disabled by default, but it can be
100*ddb26d8eSChristoph Hellwig	  enabled by passing cma=size[MG] to the kernel.
101*ddb26d8eSChristoph Hellwig
102*ddb26d8eSChristoph Hellwigchoice
103*ddb26d8eSChristoph Hellwig	prompt "Selected region size"
104*ddb26d8eSChristoph Hellwig	default CMA_SIZE_SEL_MBYTES
105*ddb26d8eSChristoph Hellwig
106*ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MBYTES
107*ddb26d8eSChristoph Hellwig	bool "Use mega bytes value only"
108*ddb26d8eSChristoph Hellwig
109*ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_PERCENTAGE
110*ddb26d8eSChristoph Hellwig	bool "Use percentage value only"
111*ddb26d8eSChristoph Hellwig
112*ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MIN
113*ddb26d8eSChristoph Hellwig	bool "Use lower value (minimum)"
114*ddb26d8eSChristoph Hellwig
115*ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MAX
116*ddb26d8eSChristoph Hellwig	bool "Use higher value (maximum)"
117*ddb26d8eSChristoph Hellwig
118*ddb26d8eSChristoph Hellwigendchoice
119*ddb26d8eSChristoph Hellwig
120*ddb26d8eSChristoph Hellwigconfig CMA_ALIGNMENT
121*ddb26d8eSChristoph Hellwig	int "Maximum PAGE_SIZE order of alignment for contiguous buffers"
122*ddb26d8eSChristoph Hellwig	range 4 12
123*ddb26d8eSChristoph Hellwig	default 8
124*ddb26d8eSChristoph Hellwig	help
125*ddb26d8eSChristoph Hellwig	  DMA mapping framework by default aligns all buffers to the smallest
126*ddb26d8eSChristoph Hellwig	  PAGE_SIZE order which is greater than or equal to the requested buffer
127*ddb26d8eSChristoph Hellwig	  size. This works well for buffers up to a few hundreds kilobytes, but
128*ddb26d8eSChristoph Hellwig	  for larger buffers it just a memory waste. With this parameter you can
129*ddb26d8eSChristoph Hellwig	  specify the maximum PAGE_SIZE order for contiguous buffers. Larger
130*ddb26d8eSChristoph Hellwig	  buffers will be aligned only to this specified order. The order is
131*ddb26d8eSChristoph Hellwig	  expressed as a power of two multiplied by the PAGE_SIZE.
132*ddb26d8eSChristoph Hellwig
133*ddb26d8eSChristoph Hellwig	  For example, if your system defaults to 4KiB pages, the order value
134*ddb26d8eSChristoph Hellwig	  of 8 means that the buffers will be aligned up to 1MiB only.
135*ddb26d8eSChristoph Hellwig
136*ddb26d8eSChristoph Hellwig	  If unsure, leave the default value "8".
137*ddb26d8eSChristoph Hellwig
138*ddb26d8eSChristoph Hellwigendif
139*ddb26d8eSChristoph Hellwig
14070ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG
14170ca7ba2SAndy Shevchenko	bool "Enable debugging of DMA-API usage"
14270ca7ba2SAndy Shevchenko	select NEED_DMA_MAP_STATE
14370ca7ba2SAndy Shevchenko	help
14470ca7ba2SAndy Shevchenko	  Enable this option to debug the use of the DMA API by device drivers.
14570ca7ba2SAndy Shevchenko	  With this option you will be able to detect common bugs in device
14670ca7ba2SAndy Shevchenko	  drivers like double-freeing of DMA mappings or freeing mappings that
14770ca7ba2SAndy Shevchenko	  were never allocated.
14870ca7ba2SAndy Shevchenko
14970ca7ba2SAndy Shevchenko	  This also attempts to catch cases where a page owned by DMA is
15070ca7ba2SAndy Shevchenko	  accessed by the cpu in a way that could cause data corruption.  For
15170ca7ba2SAndy Shevchenko	  example, this enables cow_user_page() to check that the source page is
15270ca7ba2SAndy Shevchenko	  not undergoing DMA.
15370ca7ba2SAndy Shevchenko
15470ca7ba2SAndy Shevchenko	  This option causes a performance degradation.  Use only if you want to
15570ca7ba2SAndy Shevchenko	  debug device drivers and dma interactions.
15670ca7ba2SAndy Shevchenko
15770ca7ba2SAndy Shevchenko	  If unsure, say N.
15870ca7ba2SAndy Shevchenko
15970ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG_SG
16070ca7ba2SAndy Shevchenko	bool "Debug DMA scatter-gather usage"
16170ca7ba2SAndy Shevchenko	default y
16270ca7ba2SAndy Shevchenko	depends on DMA_API_DEBUG
16370ca7ba2SAndy Shevchenko	help
16470ca7ba2SAndy Shevchenko	  Perform extra checking that callers of dma_map_sg() have respected the
16570ca7ba2SAndy Shevchenko	  appropriate segment length/boundary limits for the given device when
16670ca7ba2SAndy Shevchenko	  preparing DMA scatterlists.
16770ca7ba2SAndy Shevchenko
16870ca7ba2SAndy Shevchenko	  This is particularly likely to have been overlooked in cases where the
16970ca7ba2SAndy Shevchenko	  dma_map_sg() API is used for general bulk mapping of pages rather than
17070ca7ba2SAndy Shevchenko	  preparing literal scatter-gather descriptors, where there is a risk of
17170ca7ba2SAndy Shevchenko	  unexpected behaviour from DMA API implementations if the scatterlist
17270ca7ba2SAndy Shevchenko	  is technically out-of-spec.
17370ca7ba2SAndy Shevchenko
17470ca7ba2SAndy Shevchenko	  If unsure, say N.
175