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 12*ef1a85b6SChristoph 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 23cf65a0f6SChristoph Hellwigconfig NEED_SG_DMA_LENGTH 24cf65a0f6SChristoph Hellwig bool 25cf65a0f6SChristoph Hellwig 26cf65a0f6SChristoph Hellwigconfig NEED_DMA_MAP_STATE 27cf65a0f6SChristoph Hellwig bool 28cf65a0f6SChristoph Hellwig 29cf65a0f6SChristoph Hellwigconfig ARCH_DMA_ADDR_T_64BIT 30cf65a0f6SChristoph Hellwig def_bool 64BIT || PHYS_ADDR_T_64BIT 31cf65a0f6SChristoph Hellwig 32f3ecc0ffSChristoph Hellwigconfig ARCH_HAS_DMA_COHERENCE_H 33f3ecc0ffSChristoph Hellwig bool 34f3ecc0ffSChristoph Hellwig 3511ddce15SChristoph Hellwigconfig ARCH_HAS_DMA_SET_MASK 3611ddce15SChristoph Hellwig bool 3711ddce15SChristoph Hellwig 38419e2f18SChristoph Hellwig# 39419e2f18SChristoph Hellwig# Select this option if the architecture needs special handling for 40419e2f18SChristoph Hellwig# DMA_ATTR_WRITE_COMBINE. Normally the "uncached" mapping should be what 41419e2f18SChristoph Hellwig# people thing of when saying write combine, so very few platforms should 42419e2f18SChristoph Hellwig# need to enable this. 43419e2f18SChristoph Hellwig# 44419e2f18SChristoph Hellwigconfig ARCH_HAS_DMA_WRITE_COMBINE 45419e2f18SChristoph Hellwig bool 46419e2f18SChristoph Hellwig 47ff4c25f2SChristoph Hellwigconfig DMA_DECLARE_COHERENT 48cf65a0f6SChristoph Hellwig bool 49cf65a0f6SChristoph Hellwig 50347cb6afSChristoph Hellwigconfig ARCH_HAS_SETUP_DMA_OPS 51347cb6afSChristoph Hellwig bool 52347cb6afSChristoph Hellwig 53dc2acdedSChristoph Hellwigconfig ARCH_HAS_TEARDOWN_DMA_OPS 54cf65a0f6SChristoph Hellwig bool 55cf65a0f6SChristoph Hellwig 56cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_DEVICE 57cf65a0f6SChristoph Hellwig bool 58cf65a0f6SChristoph Hellwig 59cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU 60cf65a0f6SChristoph Hellwig bool 61cf65a0f6SChristoph Hellwig select NEED_DMA_MAP_STATE 62cf65a0f6SChristoph Hellwig 63684f7e91SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU_ALL 64684f7e91SChristoph Hellwig bool 65684f7e91SChristoph Hellwig 6613bf5cedSChristoph Hellwigconfig ARCH_HAS_DMA_PREP_COHERENT 6713bf5cedSChristoph Hellwig bool 6813bf5cedSChristoph Hellwig 699087c375STom Lendackyconfig ARCH_HAS_FORCE_DMA_UNENCRYPTED 709087c375STom Lendacky bool 719087c375STom Lendacky 72cf65a0f6SChristoph Hellwigconfig DMA_NONCOHERENT_CACHE_SYNC 73cf65a0f6SChristoph Hellwig bool 74cf65a0f6SChristoph Hellwig 75cf65a0f6SChristoph Hellwigconfig DMA_VIRT_OPS 76cf65a0f6SChristoph Hellwig bool 77cf65a0f6SChristoph Hellwig depends on HAS_DMA 782f9237d4SChristoph Hellwig select DMA_OPS 79cf65a0f6SChristoph Hellwig 80cf65a0f6SChristoph Hellwigconfig SWIOTLB 81cf65a0f6SChristoph Hellwig bool 82cf65a0f6SChristoph Hellwig select NEED_DMA_MAP_STATE 83f0edfea8SChristoph Hellwig 8434dc0ea6SChristoph Hellwig# 8534dc0ea6SChristoph Hellwig# Should be selected if we can mmap non-coherent mappings to userspace. 8634dc0ea6SChristoph Hellwig# The only thing that is really required is a way to set an uncached bit 8734dc0ea6SChristoph Hellwig# in the pagetables 8834dc0ea6SChristoph Hellwig# 8934dc0ea6SChristoph Hellwigconfig DMA_NONCOHERENT_MMAP 901fbf57d0SChristoph Hellwig default y if !MMU 9134dc0ea6SChristoph Hellwig bool 9234dc0ea6SChristoph Hellwig 93dbed452aSDavid Rientjesconfig DMA_COHERENT_POOL 94d07ae4c4SChristoph Hellwig select GENERIC_ALLOCATOR 95dbed452aSDavid Rientjes bool 96dbed452aSDavid Rientjes 97f0edfea8SChristoph Hellwigconfig DMA_REMAP 98dbed452aSDavid Rientjes bool 99f0edfea8SChristoph Hellwig depends on MMU 10034dc0ea6SChristoph Hellwig select DMA_NONCOHERENT_MMAP 10170ca7ba2SAndy Shevchenko 102e860c299SDavid Rientjesconfig DMA_DIRECT_REMAP 103e860c299SDavid Rientjes bool 104dbed452aSDavid Rientjes select DMA_REMAP 105e860c299SDavid Rientjes select DMA_COHERENT_POOL 106e860c299SDavid Rientjes 107ddb26d8eSChristoph Hellwigconfig DMA_CMA 108ddb26d8eSChristoph Hellwig bool "DMA Contiguous Memory Allocator" 109ddb26d8eSChristoph Hellwig depends on HAVE_DMA_CONTIGUOUS && CMA 110ddb26d8eSChristoph Hellwig help 111ddb26d8eSChristoph Hellwig This enables the Contiguous Memory Allocator which allows drivers 112ddb26d8eSChristoph Hellwig to allocate big physically-contiguous blocks of memory for use with 113ddb26d8eSChristoph Hellwig hardware components that do not support I/O map nor scatter-gather. 114ddb26d8eSChristoph Hellwig 115ddb26d8eSChristoph Hellwig You can disable CMA by specifying "cma=0" on the kernel's command 116ddb26d8eSChristoph Hellwig line. 117ddb26d8eSChristoph Hellwig 118ddb26d8eSChristoph Hellwig For more information see <include/linux/dma-contiguous.h>. 119ddb26d8eSChristoph Hellwig If unsure, say "n". 120ddb26d8eSChristoph Hellwig 121ddb26d8eSChristoph Hellwigif DMA_CMA 122b7176c26SBarry Song 123b7176c26SBarry Songconfig DMA_PERNUMA_CMA 124b7176c26SBarry Song bool "Enable separate DMA Contiguous Memory Area for each NUMA Node" 125b7176c26SBarry Song default NUMA && ARM64 126b7176c26SBarry Song help 127b7176c26SBarry Song Enable this option to get pernuma CMA areas so that devices like 128b7176c26SBarry Song ARM64 SMMU can get local memory by DMA coherent APIs. 129b7176c26SBarry Song 130b7176c26SBarry Song You can set the size of pernuma CMA by specifying "cma_pernuma=size" 131b7176c26SBarry Song on the kernel's command line. 132b7176c26SBarry Song 133ddb26d8eSChristoph Hellwigcomment "Default contiguous memory area size:" 134ddb26d8eSChristoph Hellwig 135ddb26d8eSChristoph Hellwigconfig CMA_SIZE_MBYTES 136ddb26d8eSChristoph Hellwig int "Size in Mega Bytes" 137ddb26d8eSChristoph Hellwig depends on !CMA_SIZE_SEL_PERCENTAGE 138ddb26d8eSChristoph Hellwig default 0 if X86 139ddb26d8eSChristoph Hellwig default 16 140ddb26d8eSChristoph Hellwig help 141ddb26d8eSChristoph Hellwig Defines the size (in MiB) of the default memory area for Contiguous 142ddb26d8eSChristoph Hellwig Memory Allocator. If the size of 0 is selected, CMA is disabled by 143ddb26d8eSChristoph Hellwig default, but it can be enabled by passing cma=size[MG] to the kernel. 144ddb26d8eSChristoph Hellwig 145ddb26d8eSChristoph Hellwig 146ddb26d8eSChristoph Hellwigconfig CMA_SIZE_PERCENTAGE 147ddb26d8eSChristoph Hellwig int "Percentage of total memory" 148ddb26d8eSChristoph Hellwig depends on !CMA_SIZE_SEL_MBYTES 149ddb26d8eSChristoph Hellwig default 0 if X86 150ddb26d8eSChristoph Hellwig default 10 151ddb26d8eSChristoph Hellwig help 152ddb26d8eSChristoph Hellwig Defines the size of the default memory area for Contiguous Memory 153ddb26d8eSChristoph Hellwig Allocator as a percentage of the total memory in the system. 154ddb26d8eSChristoph Hellwig If 0 percent is selected, CMA is disabled by default, but it can be 155ddb26d8eSChristoph Hellwig enabled by passing cma=size[MG] to the kernel. 156ddb26d8eSChristoph Hellwig 157ddb26d8eSChristoph Hellwigchoice 158ddb26d8eSChristoph Hellwig prompt "Selected region size" 159ddb26d8eSChristoph Hellwig default CMA_SIZE_SEL_MBYTES 160ddb26d8eSChristoph Hellwig 161ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MBYTES 162ddb26d8eSChristoph Hellwig bool "Use mega bytes value only" 163ddb26d8eSChristoph Hellwig 164ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_PERCENTAGE 165ddb26d8eSChristoph Hellwig bool "Use percentage value only" 166ddb26d8eSChristoph Hellwig 167ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MIN 168ddb26d8eSChristoph Hellwig bool "Use lower value (minimum)" 169ddb26d8eSChristoph Hellwig 170ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MAX 171ddb26d8eSChristoph Hellwig bool "Use higher value (maximum)" 172ddb26d8eSChristoph Hellwig 173ddb26d8eSChristoph Hellwigendchoice 174ddb26d8eSChristoph Hellwig 175ddb26d8eSChristoph Hellwigconfig CMA_ALIGNMENT 176ddb26d8eSChristoph Hellwig int "Maximum PAGE_SIZE order of alignment for contiguous buffers" 177ddb26d8eSChristoph Hellwig range 4 12 178ddb26d8eSChristoph Hellwig default 8 179ddb26d8eSChristoph Hellwig help 180ddb26d8eSChristoph Hellwig DMA mapping framework by default aligns all buffers to the smallest 181ddb26d8eSChristoph Hellwig PAGE_SIZE order which is greater than or equal to the requested buffer 182ddb26d8eSChristoph Hellwig size. This works well for buffers up to a few hundreds kilobytes, but 183ddb26d8eSChristoph Hellwig for larger buffers it just a memory waste. With this parameter you can 184ddb26d8eSChristoph Hellwig specify the maximum PAGE_SIZE order for contiguous buffers. Larger 185ddb26d8eSChristoph Hellwig buffers will be aligned only to this specified order. The order is 186ddb26d8eSChristoph Hellwig expressed as a power of two multiplied by the PAGE_SIZE. 187ddb26d8eSChristoph Hellwig 188ddb26d8eSChristoph Hellwig For example, if your system defaults to 4KiB pages, the order value 189ddb26d8eSChristoph Hellwig of 8 means that the buffers will be aligned up to 1MiB only. 190ddb26d8eSChristoph Hellwig 191ddb26d8eSChristoph Hellwig If unsure, leave the default value "8". 192ddb26d8eSChristoph Hellwig 193ddb26d8eSChristoph Hellwigendif 194ddb26d8eSChristoph Hellwig 19570ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG 19670ca7ba2SAndy Shevchenko bool "Enable debugging of DMA-API usage" 19770ca7ba2SAndy Shevchenko select NEED_DMA_MAP_STATE 19870ca7ba2SAndy Shevchenko help 19970ca7ba2SAndy Shevchenko Enable this option to debug the use of the DMA API by device drivers. 20070ca7ba2SAndy Shevchenko With this option you will be able to detect common bugs in device 20170ca7ba2SAndy Shevchenko drivers like double-freeing of DMA mappings or freeing mappings that 20270ca7ba2SAndy Shevchenko were never allocated. 20370ca7ba2SAndy Shevchenko 20470ca7ba2SAndy Shevchenko This option causes a performance degradation. Use only if you want to 20570ca7ba2SAndy Shevchenko debug device drivers and dma interactions. 20670ca7ba2SAndy Shevchenko 20770ca7ba2SAndy Shevchenko If unsure, say N. 20870ca7ba2SAndy Shevchenko 20970ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG_SG 21070ca7ba2SAndy Shevchenko bool "Debug DMA scatter-gather usage" 21170ca7ba2SAndy Shevchenko default y 21270ca7ba2SAndy Shevchenko depends on DMA_API_DEBUG 21370ca7ba2SAndy Shevchenko help 21470ca7ba2SAndy Shevchenko Perform extra checking that callers of dma_map_sg() have respected the 21570ca7ba2SAndy Shevchenko appropriate segment length/boundary limits for the given device when 21670ca7ba2SAndy Shevchenko preparing DMA scatterlists. 21770ca7ba2SAndy Shevchenko 21870ca7ba2SAndy Shevchenko This is particularly likely to have been overlooked in cases where the 21970ca7ba2SAndy Shevchenko dma_map_sg() API is used for general bulk mapping of pages rather than 22070ca7ba2SAndy Shevchenko preparing literal scatter-gather descriptors, where there is a risk of 22170ca7ba2SAndy Shevchenko unexpected behaviour from DMA API implementations if the scatterlist 22270ca7ba2SAndy Shevchenko is technically out-of-spec. 22370ca7ba2SAndy Shevchenko 22470ca7ba2SAndy Shevchenko If unsure, say N. 225