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 11*b5c58b2fSLeon Romanovskyconfig DMA_OPS_HELPERS 12*b5c58b2fSLeon Romanovsky bool 13*b5c58b2fSLeon Romanovsky 142f9237d4SChristoph Hellwigconfig DMA_OPS 15ef1a85b6SChristoph Hellwig depends on HAS_DMA 16*b5c58b2fSLeon Romanovsky select DMA_OPS_HELPERS 172f9237d4SChristoph Hellwig bool 182f9237d4SChristoph Hellwig 19d35834c6SChristoph Hellwig# 20d35834c6SChristoph Hellwig# IOMMU drivers that can bypass the IOMMU code and optionally use the direct 21d35834c6SChristoph Hellwig# mapping fast path should select this option and set the dma_ops_bypass 22d35834c6SChristoph Hellwig# flag in struct device where applicable 23d35834c6SChristoph Hellwig# 24d35834c6SChristoph Hellwigconfig DMA_OPS_BYPASS 25d35834c6SChristoph Hellwig bool 26d35834c6SChristoph Hellwig 278d8d53cfSAlexey Kardashevskiy# Lets platform IOMMU driver choose between bypass and IOMMU 288d8d53cfSAlexey Kardashevskiyconfig ARCH_HAS_DMA_MAP_DIRECT 298d8d53cfSAlexey Kardashevskiy bool 308d8d53cfSAlexey Kardashevskiy 31af2880ecSRobin Murphyconfig NEED_SG_DMA_FLAGS 32af2880ecSRobin Murphy bool 33af2880ecSRobin Murphy 34cf65a0f6SChristoph Hellwigconfig NEED_SG_DMA_LENGTH 35cf65a0f6SChristoph Hellwig bool 36cf65a0f6SChristoph Hellwig 37cf65a0f6SChristoph Hellwigconfig NEED_DMA_MAP_STATE 38cf65a0f6SChristoph Hellwig bool 39cf65a0f6SChristoph Hellwig 40cf65a0f6SChristoph Hellwigconfig ARCH_DMA_ADDR_T_64BIT 41cf65a0f6SChristoph Hellwig def_bool 64BIT || PHYS_ADDR_T_64BIT 42cf65a0f6SChristoph Hellwig 4311ddce15SChristoph Hellwigconfig ARCH_HAS_DMA_SET_MASK 4411ddce15SChristoph Hellwig bool 4511ddce15SChristoph Hellwig 46419e2f18SChristoph Hellwig# 47419e2f18SChristoph Hellwig# Select this option if the architecture needs special handling for 48419e2f18SChristoph Hellwig# DMA_ATTR_WRITE_COMBINE. Normally the "uncached" mapping should be what 494d3af20eSSui Jingfeng# people think of when saying write combine, so very few platforms should 50419e2f18SChristoph Hellwig# need to enable this. 51419e2f18SChristoph Hellwig# 52419e2f18SChristoph Hellwigconfig ARCH_HAS_DMA_WRITE_COMBINE 53419e2f18SChristoph Hellwig bool 54419e2f18SChristoph Hellwig 55abdaf11aSChristoph Hellwig# 56abdaf11aSChristoph Hellwig# Select if the architectures provides the arch_dma_mark_clean hook 57abdaf11aSChristoph Hellwig# 58abdaf11aSChristoph Hellwigconfig ARCH_HAS_DMA_MARK_CLEAN 59abdaf11aSChristoph Hellwig bool 60abdaf11aSChristoph Hellwig 61ff4c25f2SChristoph Hellwigconfig DMA_DECLARE_COHERENT 62cf65a0f6SChristoph Hellwig bool 63cf65a0f6SChristoph Hellwig 64347cb6afSChristoph Hellwigconfig ARCH_HAS_SETUP_DMA_OPS 65347cb6afSChristoph Hellwig bool 66347cb6afSChristoph Hellwig 67dc2acdedSChristoph Hellwigconfig ARCH_HAS_TEARDOWN_DMA_OPS 68cf65a0f6SChristoph Hellwig bool 69cf65a0f6SChristoph Hellwig 70cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_DEVICE 71cf65a0f6SChristoph Hellwig bool 72cf65a0f6SChristoph Hellwig 73cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU 74cf65a0f6SChristoph Hellwig bool 75cf65a0f6SChristoph Hellwig select NEED_DMA_MAP_STATE 76cf65a0f6SChristoph Hellwig 77684f7e91SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU_ALL 78684f7e91SChristoph Hellwig bool 79684f7e91SChristoph Hellwig 8013bf5cedSChristoph Hellwigconfig ARCH_HAS_DMA_PREP_COHERENT 8113bf5cedSChristoph Hellwig bool 8213bf5cedSChristoph Hellwig 839087c375STom Lendackyconfig ARCH_HAS_FORCE_DMA_UNENCRYPTED 849087c375STom Lendacky bool 859087c375STom Lendacky 861d3f56b2SJiaxun Yang# 871d3f56b2SJiaxun Yang# Select this option if the architecture assumes DMA devices are coherent 881d3f56b2SJiaxun Yang# by default. 891d3f56b2SJiaxun Yang# 901d3f56b2SJiaxun Yangconfig ARCH_DMA_DEFAULT_COHERENT 911d3f56b2SJiaxun Yang bool 921d3f56b2SJiaxun Yang 93cf65a0f6SChristoph Hellwigconfig SWIOTLB 94cf65a0f6SChristoph Hellwig bool 95cf65a0f6SChristoph Hellwig select NEED_DMA_MAP_STATE 96f0edfea8SChristoph Hellwig 9762708b2bSPetr Tesarikconfig SWIOTLB_DYNAMIC 9862708b2bSPetr Tesarik bool "Dynamic allocation of DMA bounce buffers" 9962708b2bSPetr Tesarik default n 10062708b2bSPetr Tesarik depends on SWIOTLB 10162708b2bSPetr Tesarik help 10262708b2bSPetr Tesarik This enables dynamic resizing of the software IO TLB. The kernel 10362708b2bSPetr Tesarik starts with one memory pool at boot and it will allocate additional 10462708b2bSPetr Tesarik pools as needed. To reduce run-time kernel memory requirements, you 10562708b2bSPetr Tesarik may have to specify a smaller size of the initial pool using 10662708b2bSPetr Tesarik "swiotlb=" on the kernel command line. 10762708b2bSPetr Tesarik 10862708b2bSPetr Tesarik If unsure, say N. 10962708b2bSPetr Tesarik 110370645f4SCatalin Marinasconfig DMA_BOUNCE_UNALIGNED_KMALLOC 111370645f4SCatalin Marinas bool 112370645f4SCatalin Marinas depends on SWIOTLB 113370645f4SCatalin Marinas 114fe7514b1SAlexander Lobakinconfig DMA_NEED_SYNC 115fe7514b1SAlexander Lobakin def_bool ARCH_HAS_SYNC_DMA_FOR_DEVICE || ARCH_HAS_SYNC_DMA_FOR_CPU || \ 116fe7514b1SAlexander Lobakin ARCH_HAS_SYNC_DMA_FOR_CPU_ALL || DMA_API_DEBUG || DMA_OPS || \ 117fe7514b1SAlexander Lobakin SWIOTLB 118fe7514b1SAlexander Lobakin 1190b84e4f8SClaire Changconfig DMA_RESTRICTED_POOL 1200b84e4f8SClaire Chang bool "DMA Restricted Pool" 121f3c4b134SClaire Chang depends on OF && OF_RESERVED_MEM && SWIOTLB 1220b84e4f8SClaire Chang help 1230b84e4f8SClaire Chang This enables support for restricted DMA pools which provide a level of 1240b84e4f8SClaire Chang DMA memory protection on systems with limited hardware protection 1250b84e4f8SClaire Chang capabilities, such as those lacking an IOMMU. 1260b84e4f8SClaire Chang 1270b84e4f8SClaire Chang For more information see 1280b84e4f8SClaire Chang <Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt> 1290b84e4f8SClaire Chang and <kernel/dma/swiotlb.c>. 1300b84e4f8SClaire Chang If unsure, say "n". 1310b84e4f8SClaire Chang 13234dc0ea6SChristoph Hellwig# 13334dc0ea6SChristoph Hellwig# Should be selected if we can mmap non-coherent mappings to userspace. 13434dc0ea6SChristoph Hellwig# The only thing that is really required is a way to set an uncached bit 13534dc0ea6SChristoph Hellwig# in the pagetables 13634dc0ea6SChristoph Hellwig# 13734dc0ea6SChristoph Hellwigconfig DMA_NONCOHERENT_MMAP 1381fbf57d0SChristoph Hellwig default y if !MMU 13934dc0ea6SChristoph Hellwig bool 14034dc0ea6SChristoph Hellwig 141dbed452aSDavid Rientjesconfig DMA_COHERENT_POOL 142d07ae4c4SChristoph Hellwig select GENERIC_ALLOCATOR 143dbed452aSDavid Rientjes bool 144dbed452aSDavid Rientjes 145faf4ef82SChristoph Hellwigconfig DMA_GLOBAL_POOL 146faf4ef82SChristoph Hellwig select DMA_DECLARE_COHERENT 147da323d46SChristoph Hellwig depends on !ARCH_HAS_DMA_SET_UNCACHED 148da323d46SChristoph Hellwig depends on !DMA_DIRECT_REMAP 149faf4ef82SChristoph Hellwig bool 150faf4ef82SChristoph Hellwig 151e860c299SDavid Rientjesconfig DMA_DIRECT_REMAP 152e860c299SDavid Rientjes bool 153e860c299SDavid Rientjes select DMA_COHERENT_POOL 154f5ff79fdSChristoph Hellwig select DMA_NONCOHERENT_MMAP 155e860c299SDavid Rientjes 1562c8ed1b9SChristoph Hellwig# 1572c8ed1b9SChristoph Hellwig# Fallback to arch code for DMA allocations. This should eventually go away. 1582c8ed1b9SChristoph Hellwig# 1592c8ed1b9SChristoph Hellwigconfig ARCH_HAS_DMA_ALLOC 1602c8ed1b9SChristoph Hellwig depends on !ARCH_HAS_DMA_SET_UNCACHED 1612c8ed1b9SChristoph Hellwig depends on !DMA_DIRECT_REMAP 1622c8ed1b9SChristoph Hellwig depends on !DMA_GLOBAL_POOL 1632c8ed1b9SChristoph Hellwig bool 1642c8ed1b9SChristoph Hellwig 165ddb26d8eSChristoph Hellwigconfig DMA_CMA 166ddb26d8eSChristoph Hellwig bool "DMA Contiguous Memory Allocator" 167ddb26d8eSChristoph Hellwig depends on HAVE_DMA_CONTIGUOUS && CMA 168ddb26d8eSChristoph Hellwig help 169ddb26d8eSChristoph Hellwig This enables the Contiguous Memory Allocator which allows drivers 170ddb26d8eSChristoph Hellwig to allocate big physically-contiguous blocks of memory for use with 171ddb26d8eSChristoph Hellwig hardware components that do not support I/O map nor scatter-gather. 172ddb26d8eSChristoph Hellwig 173ddb26d8eSChristoph Hellwig You can disable CMA by specifying "cma=0" on the kernel's command 174ddb26d8eSChristoph Hellwig line. 175ddb26d8eSChristoph Hellwig 1760b1abd1fSChristoph Hellwig For more information see <kernel/dma/contiguous.c>. 177ddb26d8eSChristoph Hellwig If unsure, say "n". 178ddb26d8eSChristoph Hellwig 179ddb26d8eSChristoph Hellwigif DMA_CMA 180b7176c26SBarry Song 181bf29bfaaSYajun Dengconfig DMA_NUMA_CMA 182bf29bfaaSYajun Deng bool "Enable separate DMA Contiguous Memory Area for NUMA Node" 1832dcdf8c1SChristoph Hellwig depends on NUMA 184b7176c26SBarry Song help 185bf29bfaaSYajun Deng Enable this option to get numa CMA areas so that NUMA devices 18622e4a348SYajun Deng can get local memory by DMA coherent APIs. 187b7176c26SBarry Song 188b7176c26SBarry Song You can set the size of pernuma CMA by specifying "cma_pernuma=size" 189bf29bfaaSYajun Deng or set the node id and its size of CMA by specifying "numa_cma= 190bf29bfaaSYajun Deng <node>:size[,<node>:size]" on the kernel's command line. 191b7176c26SBarry Song 192ddb26d8eSChristoph Hellwigcomment "Default contiguous memory area size:" 193ddb26d8eSChristoph Hellwig 194ddb26d8eSChristoph Hellwigconfig CMA_SIZE_MBYTES 195ddb26d8eSChristoph Hellwig int "Size in Mega Bytes" 196ddb26d8eSChristoph Hellwig depends on !CMA_SIZE_SEL_PERCENTAGE 197ddb26d8eSChristoph Hellwig default 0 if X86 198ddb26d8eSChristoph Hellwig default 16 199ddb26d8eSChristoph Hellwig help 200ddb26d8eSChristoph Hellwig Defines the size (in MiB) of the default memory area for Contiguous 201ddb26d8eSChristoph Hellwig Memory Allocator. If the size of 0 is selected, CMA is disabled by 202ddb26d8eSChristoph Hellwig default, but it can be enabled by passing cma=size[MG] to the kernel. 203ddb26d8eSChristoph Hellwig 204ddb26d8eSChristoph Hellwig 205ddb26d8eSChristoph Hellwigconfig CMA_SIZE_PERCENTAGE 206ddb26d8eSChristoph Hellwig int "Percentage of total memory" 207ddb26d8eSChristoph Hellwig depends on !CMA_SIZE_SEL_MBYTES 208ddb26d8eSChristoph Hellwig default 0 if X86 209ddb26d8eSChristoph Hellwig default 10 210ddb26d8eSChristoph Hellwig help 211ddb26d8eSChristoph Hellwig Defines the size of the default memory area for Contiguous Memory 212ddb26d8eSChristoph Hellwig Allocator as a percentage of the total memory in the system. 213ddb26d8eSChristoph Hellwig If 0 percent is selected, CMA is disabled by default, but it can be 214ddb26d8eSChristoph Hellwig enabled by passing cma=size[MG] to the kernel. 215ddb26d8eSChristoph Hellwig 216ddb26d8eSChristoph Hellwigchoice 217ddb26d8eSChristoph Hellwig prompt "Selected region size" 218ddb26d8eSChristoph Hellwig default CMA_SIZE_SEL_MBYTES 219ddb26d8eSChristoph Hellwig 220ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MBYTES 221ddb26d8eSChristoph Hellwig bool "Use mega bytes value only" 222ddb26d8eSChristoph Hellwig 223ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_PERCENTAGE 224ddb26d8eSChristoph Hellwig bool "Use percentage value only" 225ddb26d8eSChristoph Hellwig 226ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MIN 227ddb26d8eSChristoph Hellwig bool "Use lower value (minimum)" 228ddb26d8eSChristoph Hellwig 229ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MAX 230ddb26d8eSChristoph Hellwig bool "Use higher value (maximum)" 231ddb26d8eSChristoph Hellwig 232ddb26d8eSChristoph Hellwigendchoice 233ddb26d8eSChristoph Hellwig 234ddb26d8eSChristoph Hellwigconfig CMA_ALIGNMENT 235ddb26d8eSChristoph Hellwig int "Maximum PAGE_SIZE order of alignment for contiguous buffers" 2360de32796SPaul Cercueil range 2 12 237ddb26d8eSChristoph Hellwig default 8 238ddb26d8eSChristoph Hellwig help 239ddb26d8eSChristoph Hellwig DMA mapping framework by default aligns all buffers to the smallest 240ddb26d8eSChristoph Hellwig PAGE_SIZE order which is greater than or equal to the requested buffer 241ddb26d8eSChristoph Hellwig size. This works well for buffers up to a few hundreds kilobytes, but 242ddb26d8eSChristoph Hellwig for larger buffers it just a memory waste. With this parameter you can 243ddb26d8eSChristoph Hellwig specify the maximum PAGE_SIZE order for contiguous buffers. Larger 244ddb26d8eSChristoph Hellwig buffers will be aligned only to this specified order. The order is 245ddb26d8eSChristoph Hellwig expressed as a power of two multiplied by the PAGE_SIZE. 246ddb26d8eSChristoph Hellwig 247ddb26d8eSChristoph Hellwig For example, if your system defaults to 4KiB pages, the order value 248ddb26d8eSChristoph Hellwig of 8 means that the buffers will be aligned up to 1MiB only. 249ddb26d8eSChristoph Hellwig 250ddb26d8eSChristoph Hellwig If unsure, leave the default value "8". 251ddb26d8eSChristoph Hellwig 252ddb26d8eSChristoph Hellwigendif 253ddb26d8eSChristoph Hellwig 25470ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG 25570ca7ba2SAndy Shevchenko bool "Enable debugging of DMA-API usage" 25670ca7ba2SAndy Shevchenko select NEED_DMA_MAP_STATE 25770ca7ba2SAndy Shevchenko help 25870ca7ba2SAndy Shevchenko Enable this option to debug the use of the DMA API by device drivers. 25970ca7ba2SAndy Shevchenko With this option you will be able to detect common bugs in device 26070ca7ba2SAndy Shevchenko drivers like double-freeing of DMA mappings or freeing mappings that 26170ca7ba2SAndy Shevchenko were never allocated. 26270ca7ba2SAndy Shevchenko 26370ca7ba2SAndy Shevchenko This option causes a performance degradation. Use only if you want to 26470ca7ba2SAndy Shevchenko debug device drivers and dma interactions. 26570ca7ba2SAndy Shevchenko 26670ca7ba2SAndy Shevchenko If unsure, say N. 26770ca7ba2SAndy Shevchenko 26870ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG_SG 26970ca7ba2SAndy Shevchenko bool "Debug DMA scatter-gather usage" 27070ca7ba2SAndy Shevchenko default y 27170ca7ba2SAndy Shevchenko depends on DMA_API_DEBUG 27270ca7ba2SAndy Shevchenko help 27370ca7ba2SAndy Shevchenko Perform extra checking that callers of dma_map_sg() have respected the 27470ca7ba2SAndy Shevchenko appropriate segment length/boundary limits for the given device when 27570ca7ba2SAndy Shevchenko preparing DMA scatterlists. 27670ca7ba2SAndy Shevchenko 27770ca7ba2SAndy Shevchenko This is particularly likely to have been overlooked in cases where the 27870ca7ba2SAndy Shevchenko dma_map_sg() API is used for general bulk mapping of pages rather than 27970ca7ba2SAndy Shevchenko preparing literal scatter-gather descriptors, where there is a risk of 28070ca7ba2SAndy Shevchenko unexpected behaviour from DMA API implementations if the scatterlist 28170ca7ba2SAndy Shevchenko is technically out-of-spec. 28270ca7ba2SAndy Shevchenko 28370ca7ba2SAndy Shevchenko If unsure, say N. 28465789daaSBarry Song 28565789daaSBarry Songconfig DMA_MAP_BENCHMARK 28665789daaSBarry Song bool "Enable benchmarking of streaming DMA mapping" 28765789daaSBarry Song depends on DEBUG_FS 28865789daaSBarry Song help 28965789daaSBarry Song Provides /sys/kernel/debug/dma_map_benchmark that helps with testing 29065789daaSBarry Song performance of dma_(un)map_page. 29165789daaSBarry Song 29265789daaSBarry Song See tools/testing/selftests/dma/dma_map_benchmark.c 293