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 11b5c58b2fSLeon Romanovskyconfig DMA_OPS_HELPERS 12b5c58b2fSLeon Romanovsky bool 13b5c58b2fSLeon Romanovsky 14d35834c6SChristoph Hellwig# 15d35834c6SChristoph Hellwig# IOMMU drivers that can bypass the IOMMU code and optionally use the direct 16d35834c6SChristoph Hellwig# mapping fast path should select this option and set the dma_ops_bypass 17d35834c6SChristoph Hellwig# flag in struct device where applicable 18d35834c6SChristoph Hellwig# 19d35834c6SChristoph Hellwigconfig DMA_OPS_BYPASS 20d35834c6SChristoph Hellwig bool 21d35834c6SChristoph Hellwig 228d8d53cfSAlexey Kardashevskiy# Lets platform IOMMU driver choose between bypass and IOMMU 238d8d53cfSAlexey Kardashevskiyconfig ARCH_HAS_DMA_MAP_DIRECT 248d8d53cfSAlexey Kardashevskiy bool 258d8d53cfSAlexey Kardashevskiy 26af2880ecSRobin Murphyconfig NEED_SG_DMA_FLAGS 27af2880ecSRobin Murphy bool 28af2880ecSRobin Murphy 29cf65a0f6SChristoph Hellwigconfig NEED_SG_DMA_LENGTH 30cf65a0f6SChristoph Hellwig bool 31cf65a0f6SChristoph Hellwig 32cf65a0f6SChristoph Hellwigconfig NEED_DMA_MAP_STATE 33cf65a0f6SChristoph Hellwig bool 34cf65a0f6SChristoph Hellwig 35cf65a0f6SChristoph Hellwigconfig ARCH_DMA_ADDR_T_64BIT 36cf65a0f6SChristoph Hellwig def_bool 64BIT || PHYS_ADDR_T_64BIT 37cf65a0f6SChristoph Hellwig 3811ddce15SChristoph Hellwigconfig ARCH_HAS_DMA_SET_MASK 3911ddce15SChristoph Hellwig bool 4011ddce15SChristoph Hellwig 41419e2f18SChristoph Hellwig# 42419e2f18SChristoph Hellwig# Select this option if the architecture needs special handling for 43419e2f18SChristoph Hellwig# DMA_ATTR_WRITE_COMBINE. Normally the "uncached" mapping should be what 444d3af20eSSui Jingfeng# people think of when saying write combine, so very few platforms should 45419e2f18SChristoph Hellwig# need to enable this. 46419e2f18SChristoph Hellwig# 47419e2f18SChristoph Hellwigconfig ARCH_HAS_DMA_WRITE_COMBINE 48419e2f18SChristoph Hellwig bool 49419e2f18SChristoph Hellwig 50ff4c25f2SChristoph Hellwigconfig DMA_DECLARE_COHERENT 51cf65a0f6SChristoph Hellwig bool 52cf65a0f6SChristoph Hellwig 53347cb6afSChristoph Hellwigconfig ARCH_HAS_SETUP_DMA_OPS 54347cb6afSChristoph Hellwig bool 55347cb6afSChristoph Hellwig 56dc2acdedSChristoph Hellwigconfig ARCH_HAS_TEARDOWN_DMA_OPS 57cf65a0f6SChristoph Hellwig bool 58cf65a0f6SChristoph Hellwig 59cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_DEVICE 60cf65a0f6SChristoph Hellwig bool 61cf65a0f6SChristoph Hellwig 62cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU 63cf65a0f6SChristoph Hellwig bool 64cf65a0f6SChristoph Hellwig select NEED_DMA_MAP_STATE 65cf65a0f6SChristoph Hellwig 66684f7e91SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU_ALL 67684f7e91SChristoph Hellwig bool 68684f7e91SChristoph Hellwig 6913bf5cedSChristoph Hellwigconfig ARCH_HAS_DMA_PREP_COHERENT 7013bf5cedSChristoph Hellwig bool 7113bf5cedSChristoph Hellwig 729087c375STom Lendackyconfig ARCH_HAS_FORCE_DMA_UNENCRYPTED 739087c375STom Lendacky bool 749087c375STom Lendacky 75d7eafe65SBarry Songconfig ARCH_HAS_BATCHED_DMA_SYNC 76d7eafe65SBarry Song bool 77d7eafe65SBarry Song 781d3f56b2SJiaxun Yang# 791d3f56b2SJiaxun Yang# Select this option if the architecture assumes DMA devices are coherent 801d3f56b2SJiaxun Yang# by default. 811d3f56b2SJiaxun Yang# 821d3f56b2SJiaxun Yangconfig ARCH_DMA_DEFAULT_COHERENT 831d3f56b2SJiaxun Yang bool 841d3f56b2SJiaxun Yang 85cf65a0f6SChristoph Hellwigconfig SWIOTLB 86cf65a0f6SChristoph Hellwig bool 87cf65a0f6SChristoph Hellwig select NEED_DMA_MAP_STATE 88f0edfea8SChristoph Hellwig 89*3cf67bbcSJagadeesh Pagadalaconfig SWIOTLB_DEFAULT_SIZE_MB 90*3cf67bbcSJagadeesh Pagadala int "Default SWIOTLB bounce buffer size in MB" 91*3cf67bbcSJagadeesh Pagadala depends on SWIOTLB 92*3cf67bbcSJagadeesh Pagadala range 1 64 93*3cf67bbcSJagadeesh Pagadala default 64 94*3cf67bbcSJagadeesh Pagadala help 95*3cf67bbcSJagadeesh Pagadala Sets the default size of the software IO TLB (SWIOTLB) bounce buffer 96*3cf67bbcSJagadeesh Pagadala pool allocated at boot time. The default is 64 MB. 97*3cf67bbcSJagadeesh Pagadala 98*3cf67bbcSJagadeesh Pagadala On memory-constrained embedded or mobile platforms (e.g., those with 99*3cf67bbcSJagadeesh Pagadala a hardware IOMMU such as ARM SMMU covering most DMA-capable devices), 100*3cf67bbcSJagadeesh Pagadala a smaller value such as 4 or 8 MB may be sufficient. The SWIOTLB is 101*3cf67bbcSJagadeesh Pagadala then only needed for devices that bypass the IOMMU or have restricted 102*3cf67bbcSJagadeesh Pagadala DMA address ranges. 103*3cf67bbcSJagadeesh Pagadala 104*3cf67bbcSJagadeesh Pagadala The minimum allowed value is 1 MB. This compile-time default can be 105*3cf67bbcSJagadeesh Pagadala overridden at runtime using the "swiotlb=<nslabs>" kernel command line 106*3cf67bbcSJagadeesh Pagadala parameter. Refer to Documentation/admin-guide/kernel-parameters.txt 107*3cf67bbcSJagadeesh Pagadala for details. 108*3cf67bbcSJagadeesh Pagadala 109*3cf67bbcSJagadeesh Pagadala If unsure, leave at the default value of 64. 110*3cf67bbcSJagadeesh Pagadala 11162708b2bSPetr Tesarikconfig SWIOTLB_DYNAMIC 11262708b2bSPetr Tesarik bool "Dynamic allocation of DMA bounce buffers" 11362708b2bSPetr Tesarik default n 11462708b2bSPetr Tesarik depends on SWIOTLB 11562708b2bSPetr Tesarik help 11662708b2bSPetr Tesarik This enables dynamic resizing of the software IO TLB. The kernel 11762708b2bSPetr Tesarik starts with one memory pool at boot and it will allocate additional 11862708b2bSPetr Tesarik pools as needed. To reduce run-time kernel memory requirements, you 11962708b2bSPetr Tesarik may have to specify a smaller size of the initial pool using 12062708b2bSPetr Tesarik "swiotlb=" on the kernel command line. 12162708b2bSPetr Tesarik 12262708b2bSPetr Tesarik If unsure, say N. 12362708b2bSPetr Tesarik 124370645f4SCatalin Marinasconfig DMA_BOUNCE_UNALIGNED_KMALLOC 125370645f4SCatalin Marinas bool 126370645f4SCatalin Marinas depends on SWIOTLB 127370645f4SCatalin Marinas 128fe7514b1SAlexander Lobakinconfig DMA_NEED_SYNC 129fe7514b1SAlexander Lobakin def_bool ARCH_HAS_SYNC_DMA_FOR_DEVICE || ARCH_HAS_SYNC_DMA_FOR_CPU || \ 130de6c85bfSChristoph Hellwig ARCH_HAS_SYNC_DMA_FOR_CPU_ALL || DMA_API_DEBUG || \ 131de6c85bfSChristoph Hellwig ARCH_HAS_DMA_OPS || SWIOTLB 132fe7514b1SAlexander Lobakin 1330b84e4f8SClaire Changconfig DMA_RESTRICTED_POOL 1340b84e4f8SClaire Chang bool "DMA Restricted Pool" 135f3c4b134SClaire Chang depends on OF && OF_RESERVED_MEM && SWIOTLB 1360b84e4f8SClaire Chang help 1370b84e4f8SClaire Chang This enables support for restricted DMA pools which provide a level of 1380b84e4f8SClaire Chang DMA memory protection on systems with limited hardware protection 1390b84e4f8SClaire Chang capabilities, such as those lacking an IOMMU. 1400b84e4f8SClaire Chang 1410b84e4f8SClaire Chang For more information see 1420b84e4f8SClaire Chang <Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt> 1430b84e4f8SClaire Chang and <kernel/dma/swiotlb.c>. 1440b84e4f8SClaire Chang If unsure, say "n". 1450b84e4f8SClaire Chang 14634dc0ea6SChristoph Hellwig# 14734dc0ea6SChristoph Hellwig# Should be selected if we can mmap non-coherent mappings to userspace. 14834dc0ea6SChristoph Hellwig# The only thing that is really required is a way to set an uncached bit 14934dc0ea6SChristoph Hellwig# in the pagetables 15034dc0ea6SChristoph Hellwig# 15134dc0ea6SChristoph Hellwigconfig DMA_NONCOHERENT_MMAP 1521fbf57d0SChristoph Hellwig default y if !MMU 15334dc0ea6SChristoph Hellwig bool 15434dc0ea6SChristoph Hellwig 155dbed452aSDavid Rientjesconfig DMA_COHERENT_POOL 156d07ae4c4SChristoph Hellwig select GENERIC_ALLOCATOR 157dbed452aSDavid Rientjes bool 158dbed452aSDavid Rientjes 159faf4ef82SChristoph Hellwigconfig DMA_GLOBAL_POOL 160faf4ef82SChristoph Hellwig select DMA_DECLARE_COHERENT 161da323d46SChristoph Hellwig depends on !ARCH_HAS_DMA_SET_UNCACHED 162da323d46SChristoph Hellwig depends on !DMA_DIRECT_REMAP 163faf4ef82SChristoph Hellwig bool 164faf4ef82SChristoph Hellwig 165e860c299SDavid Rientjesconfig DMA_DIRECT_REMAP 166e860c299SDavid Rientjes bool 167e860c299SDavid Rientjes select DMA_COHERENT_POOL 168f5ff79fdSChristoph Hellwig select DMA_NONCOHERENT_MMAP 169e860c299SDavid Rientjes 1702c8ed1b9SChristoph Hellwig# 1712c8ed1b9SChristoph Hellwig# Fallback to arch code for DMA allocations. This should eventually go away. 1722c8ed1b9SChristoph Hellwig# 1732c8ed1b9SChristoph Hellwigconfig ARCH_HAS_DMA_ALLOC 1742c8ed1b9SChristoph Hellwig depends on !ARCH_HAS_DMA_SET_UNCACHED 1752c8ed1b9SChristoph Hellwig depends on !DMA_DIRECT_REMAP 1762c8ed1b9SChristoph Hellwig depends on !DMA_GLOBAL_POOL 1772c8ed1b9SChristoph Hellwig bool 1782c8ed1b9SChristoph Hellwig 179ddb26d8eSChristoph Hellwigconfig DMA_CMA 180ddb26d8eSChristoph Hellwig bool "DMA Contiguous Memory Allocator" 181ddb26d8eSChristoph Hellwig depends on HAVE_DMA_CONTIGUOUS && CMA 182ddb26d8eSChristoph Hellwig help 183ddb26d8eSChristoph Hellwig This enables the Contiguous Memory Allocator which allows drivers 184ddb26d8eSChristoph Hellwig to allocate big physically-contiguous blocks of memory for use with 185ddb26d8eSChristoph Hellwig hardware components that do not support I/O map nor scatter-gather. 186ddb26d8eSChristoph Hellwig 187ddb26d8eSChristoph Hellwig You can disable CMA by specifying "cma=0" on the kernel's command 188ddb26d8eSChristoph Hellwig line. 189ddb26d8eSChristoph Hellwig 1900b1abd1fSChristoph Hellwig For more information see <kernel/dma/contiguous.c>. 191ddb26d8eSChristoph Hellwig If unsure, say "n". 192ddb26d8eSChristoph Hellwig 193ddb26d8eSChristoph Hellwigif DMA_CMA 194b7176c26SBarry Song 195bf29bfaaSYajun Dengconfig DMA_NUMA_CMA 196bf29bfaaSYajun Deng bool "Enable separate DMA Contiguous Memory Area for NUMA Node" 1972dcdf8c1SChristoph Hellwig depends on NUMA 198b7176c26SBarry Song help 199bf29bfaaSYajun Deng Enable this option to get numa CMA areas so that NUMA devices 20022e4a348SYajun Deng can get local memory by DMA coherent APIs. 201b7176c26SBarry Song 202b7176c26SBarry Song You can set the size of pernuma CMA by specifying "cma_pernuma=size" 203bf29bfaaSYajun Deng or set the node id and its size of CMA by specifying "numa_cma= 204d5cae226SFeng Tang <node>:size[,<node>:size]" on the kernel's command line. And in 205d5cae226SFeng Tang rare case that the above 2 are both setup, then the "numa_cma=" 206d5cae226SFeng Tang takes priority for the specified numa nodes. 207b7176c26SBarry Song 2087e6ace25SFeng Tangconfig CMA_SIZE_PERNUMA 2097e6ace25SFeng Tang bool "Default CMA area per NUMA node" 2107e6ace25SFeng Tang depends on DMA_NUMA_CMA 2117e6ace25SFeng Tang default y 2127e6ace25SFeng Tang help 2137e6ace25SFeng Tang On systems with more than one NUMA node, the selected CMA 2147e6ace25SFeng Tang area size will be also allocated on each additional node, 2157e6ace25SFeng Tang so that most devices may have benefit from better DMA 2167e6ace25SFeng Tang locality without an explicit command-line opt-in. 2177e6ace25SFeng Tang 218ddb26d8eSChristoph Hellwigcomment "Default contiguous memory area size:" 219ddb26d8eSChristoph Hellwig 220ddb26d8eSChristoph Hellwigconfig CMA_SIZE_MBYTES 221ddb26d8eSChristoph Hellwig int "Size in Mega Bytes" 222ddb26d8eSChristoph Hellwig depends on !CMA_SIZE_SEL_PERCENTAGE 223ddb26d8eSChristoph Hellwig default 0 if X86 224ddb26d8eSChristoph Hellwig default 16 225ddb26d8eSChristoph Hellwig help 226ddb26d8eSChristoph Hellwig Defines the size (in MiB) of the default memory area for Contiguous 227ddb26d8eSChristoph Hellwig Memory Allocator. If the size of 0 is selected, CMA is disabled by 228ddb26d8eSChristoph Hellwig default, but it can be enabled by passing cma=size[MG] to the kernel. 229ddb26d8eSChristoph Hellwig 230ddb26d8eSChristoph Hellwig 231ddb26d8eSChristoph Hellwigconfig CMA_SIZE_PERCENTAGE 232ddb26d8eSChristoph Hellwig int "Percentage of total memory" 233ddb26d8eSChristoph Hellwig depends on !CMA_SIZE_SEL_MBYTES 234ddb26d8eSChristoph Hellwig default 0 if X86 235ddb26d8eSChristoph Hellwig default 10 236ddb26d8eSChristoph Hellwig help 237ddb26d8eSChristoph Hellwig Defines the size of the default memory area for Contiguous Memory 238ddb26d8eSChristoph Hellwig Allocator as a percentage of the total memory in the system. 239ddb26d8eSChristoph Hellwig If 0 percent is selected, CMA is disabled by default, but it can be 240ddb26d8eSChristoph Hellwig enabled by passing cma=size[MG] to the kernel. 241ddb26d8eSChristoph Hellwig 242ddb26d8eSChristoph Hellwigchoice 243ddb26d8eSChristoph Hellwig prompt "Selected region size" 244ddb26d8eSChristoph Hellwig default CMA_SIZE_SEL_MBYTES 245ddb26d8eSChristoph Hellwig 246ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MBYTES 247ddb26d8eSChristoph Hellwig bool "Use mega bytes value only" 248ddb26d8eSChristoph Hellwig 249ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_PERCENTAGE 250ddb26d8eSChristoph Hellwig bool "Use percentage value only" 251ddb26d8eSChristoph Hellwig 252ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MIN 253ddb26d8eSChristoph Hellwig bool "Use lower value (minimum)" 254ddb26d8eSChristoph Hellwig 255ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MAX 256ddb26d8eSChristoph Hellwig bool "Use higher value (maximum)" 257ddb26d8eSChristoph Hellwig 258ddb26d8eSChristoph Hellwigendchoice 259ddb26d8eSChristoph Hellwig 260ddb26d8eSChristoph Hellwigconfig CMA_ALIGNMENT 261ddb26d8eSChristoph Hellwig int "Maximum PAGE_SIZE order of alignment for contiguous buffers" 2620de32796SPaul Cercueil range 2 12 263ddb26d8eSChristoph Hellwig default 8 264ddb26d8eSChristoph Hellwig help 265ddb26d8eSChristoph Hellwig DMA mapping framework by default aligns all buffers to the smallest 266ddb26d8eSChristoph Hellwig PAGE_SIZE order which is greater than or equal to the requested buffer 267ddb26d8eSChristoph Hellwig size. This works well for buffers up to a few hundreds kilobytes, but 268ddb26d8eSChristoph Hellwig for larger buffers it just a memory waste. With this parameter you can 269ddb26d8eSChristoph Hellwig specify the maximum PAGE_SIZE order for contiguous buffers. Larger 270ddb26d8eSChristoph Hellwig buffers will be aligned only to this specified order. The order is 271ddb26d8eSChristoph Hellwig expressed as a power of two multiplied by the PAGE_SIZE. 272ddb26d8eSChristoph Hellwig 273ddb26d8eSChristoph Hellwig For example, if your system defaults to 4KiB pages, the order value 274ddb26d8eSChristoph Hellwig of 8 means that the buffers will be aligned up to 1MiB only. 275ddb26d8eSChristoph Hellwig 276ddb26d8eSChristoph Hellwig If unsure, leave the default value "8". 277ddb26d8eSChristoph Hellwig 278ddb26d8eSChristoph Hellwigendif 279ddb26d8eSChristoph Hellwig 28070ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG 28170ca7ba2SAndy Shevchenko bool "Enable debugging of DMA-API usage" 28270ca7ba2SAndy Shevchenko select NEED_DMA_MAP_STATE 28370ca7ba2SAndy Shevchenko help 28470ca7ba2SAndy Shevchenko Enable this option to debug the use of the DMA API by device drivers. 28570ca7ba2SAndy Shevchenko With this option you will be able to detect common bugs in device 28670ca7ba2SAndy Shevchenko drivers like double-freeing of DMA mappings or freeing mappings that 28770ca7ba2SAndy Shevchenko were never allocated. 28870ca7ba2SAndy Shevchenko 28970ca7ba2SAndy Shevchenko This option causes a performance degradation. Use only if you want to 29070ca7ba2SAndy Shevchenko debug device drivers and dma interactions. 29170ca7ba2SAndy Shevchenko 29270ca7ba2SAndy Shevchenko If unsure, say N. 29370ca7ba2SAndy Shevchenko 29465789daaSBarry Songconfig DMA_MAP_BENCHMARK 29565789daaSBarry Song bool "Enable benchmarking of streaming DMA mapping" 29665789daaSBarry Song depends on DEBUG_FS 29765789daaSBarry Song help 29865789daaSBarry Song Provides /sys/kernel/debug/dma_map_benchmark that helps with testing 29965789daaSBarry Song performance of dma_(un)map_page. 30065789daaSBarry Song 30165789daaSBarry Song See tools/testing/selftests/dma/dma_map_benchmark.c 302