1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only 2cf65a0f6SChristoph Hellwig 3cf65a0f6SChristoph Hellwigconfig HAS_DMA 4cf65a0f6SChristoph Hellwig bool 5cf65a0f6SChristoph Hellwig depends on !NO_DMA 6cf65a0f6SChristoph Hellwig default y 7cf65a0f6SChristoph Hellwig 8*2f9237d4SChristoph Hellwigconfig DMA_OPS 9*2f9237d4SChristoph Hellwig bool 10*2f9237d4SChristoph Hellwig 11cf65a0f6SChristoph Hellwigconfig NEED_SG_DMA_LENGTH 12cf65a0f6SChristoph Hellwig bool 13cf65a0f6SChristoph Hellwig 14cf65a0f6SChristoph Hellwigconfig NEED_DMA_MAP_STATE 15cf65a0f6SChristoph Hellwig bool 16cf65a0f6SChristoph Hellwig 17cf65a0f6SChristoph Hellwigconfig ARCH_DMA_ADDR_T_64BIT 18cf65a0f6SChristoph Hellwig def_bool 64BIT || PHYS_ADDR_T_64BIT 19cf65a0f6SChristoph Hellwig 20f3ecc0ffSChristoph Hellwigconfig ARCH_HAS_DMA_COHERENCE_H 21f3ecc0ffSChristoph Hellwig bool 22f3ecc0ffSChristoph Hellwig 2311ddce15SChristoph Hellwigconfig ARCH_HAS_DMA_SET_MASK 2411ddce15SChristoph Hellwig bool 2511ddce15SChristoph Hellwig 26419e2f18SChristoph Hellwig# 27419e2f18SChristoph Hellwig# Select this option if the architecture needs special handling for 28419e2f18SChristoph Hellwig# DMA_ATTR_WRITE_COMBINE. Normally the "uncached" mapping should be what 29419e2f18SChristoph Hellwig# people thing of when saying write combine, so very few platforms should 30419e2f18SChristoph Hellwig# need to enable this. 31419e2f18SChristoph Hellwig# 32419e2f18SChristoph Hellwigconfig ARCH_HAS_DMA_WRITE_COMBINE 33419e2f18SChristoph Hellwig bool 34419e2f18SChristoph Hellwig 35ff4c25f2SChristoph Hellwigconfig DMA_DECLARE_COHERENT 36cf65a0f6SChristoph Hellwig bool 37cf65a0f6SChristoph Hellwig 38347cb6afSChristoph Hellwigconfig ARCH_HAS_SETUP_DMA_OPS 39347cb6afSChristoph Hellwig bool 40347cb6afSChristoph Hellwig 41dc2acdedSChristoph Hellwigconfig ARCH_HAS_TEARDOWN_DMA_OPS 42cf65a0f6SChristoph Hellwig bool 43cf65a0f6SChristoph Hellwig 44cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_DEVICE 45cf65a0f6SChristoph Hellwig bool 46cf65a0f6SChristoph Hellwig 47cf65a0f6SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU 48cf65a0f6SChristoph Hellwig bool 49cf65a0f6SChristoph Hellwig select NEED_DMA_MAP_STATE 50cf65a0f6SChristoph Hellwig 51684f7e91SChristoph Hellwigconfig ARCH_HAS_SYNC_DMA_FOR_CPU_ALL 52684f7e91SChristoph Hellwig bool 53684f7e91SChristoph Hellwig 5413bf5cedSChristoph Hellwigconfig ARCH_HAS_DMA_PREP_COHERENT 5513bf5cedSChristoph Hellwig bool 5613bf5cedSChristoph Hellwig 579087c375STom Lendackyconfig ARCH_HAS_FORCE_DMA_UNENCRYPTED 589087c375STom Lendacky bool 599087c375STom Lendacky 60cf65a0f6SChristoph Hellwigconfig DMA_NONCOHERENT_CACHE_SYNC 61cf65a0f6SChristoph Hellwig bool 62cf65a0f6SChristoph Hellwig 63cf65a0f6SChristoph Hellwigconfig DMA_VIRT_OPS 64cf65a0f6SChristoph Hellwig bool 65cf65a0f6SChristoph Hellwig depends on HAS_DMA 66*2f9237d4SChristoph Hellwig select DMA_OPS 67cf65a0f6SChristoph Hellwig 68cf65a0f6SChristoph Hellwigconfig SWIOTLB 69cf65a0f6SChristoph Hellwig bool 70cf65a0f6SChristoph Hellwig select NEED_DMA_MAP_STATE 71f0edfea8SChristoph Hellwig 7234dc0ea6SChristoph Hellwig# 7334dc0ea6SChristoph Hellwig# Should be selected if we can mmap non-coherent mappings to userspace. 7434dc0ea6SChristoph Hellwig# The only thing that is really required is a way to set an uncached bit 7534dc0ea6SChristoph Hellwig# in the pagetables 7634dc0ea6SChristoph Hellwig# 7734dc0ea6SChristoph Hellwigconfig DMA_NONCOHERENT_MMAP 781fbf57d0SChristoph Hellwig default y if !MMU 7934dc0ea6SChristoph Hellwig bool 8034dc0ea6SChristoph Hellwig 81dbed452aSDavid Rientjesconfig DMA_COHERENT_POOL 82d07ae4c4SChristoph Hellwig select GENERIC_ALLOCATOR 83dbed452aSDavid Rientjes bool 84dbed452aSDavid Rientjes 85f0edfea8SChristoph Hellwigconfig DMA_REMAP 86dbed452aSDavid Rientjes bool 87f0edfea8SChristoph Hellwig depends on MMU 8834dc0ea6SChristoph Hellwig select DMA_NONCOHERENT_MMAP 8970ca7ba2SAndy Shevchenko 90e860c299SDavid Rientjesconfig DMA_DIRECT_REMAP 91e860c299SDavid Rientjes bool 92dbed452aSDavid Rientjes select DMA_REMAP 93e860c299SDavid Rientjes select DMA_COHERENT_POOL 94e860c299SDavid Rientjes 95ddb26d8eSChristoph Hellwigconfig DMA_CMA 96ddb26d8eSChristoph Hellwig bool "DMA Contiguous Memory Allocator" 97ddb26d8eSChristoph Hellwig depends on HAVE_DMA_CONTIGUOUS && CMA 98ddb26d8eSChristoph Hellwig help 99ddb26d8eSChristoph Hellwig This enables the Contiguous Memory Allocator which allows drivers 100ddb26d8eSChristoph Hellwig to allocate big physically-contiguous blocks of memory for use with 101ddb26d8eSChristoph Hellwig hardware components that do not support I/O map nor scatter-gather. 102ddb26d8eSChristoph Hellwig 103ddb26d8eSChristoph Hellwig You can disable CMA by specifying "cma=0" on the kernel's command 104ddb26d8eSChristoph Hellwig line. 105ddb26d8eSChristoph Hellwig 106ddb26d8eSChristoph Hellwig For more information see <include/linux/dma-contiguous.h>. 107ddb26d8eSChristoph Hellwig If unsure, say "n". 108ddb26d8eSChristoph Hellwig 109ddb26d8eSChristoph Hellwigif DMA_CMA 110ddb26d8eSChristoph Hellwigcomment "Default contiguous memory area size:" 111ddb26d8eSChristoph Hellwig 112ddb26d8eSChristoph Hellwigconfig CMA_SIZE_MBYTES 113ddb26d8eSChristoph Hellwig int "Size in Mega Bytes" 114ddb26d8eSChristoph Hellwig depends on !CMA_SIZE_SEL_PERCENTAGE 115ddb26d8eSChristoph Hellwig default 0 if X86 116ddb26d8eSChristoph Hellwig default 16 117ddb26d8eSChristoph Hellwig help 118ddb26d8eSChristoph Hellwig Defines the size (in MiB) of the default memory area for Contiguous 119ddb26d8eSChristoph Hellwig Memory Allocator. If the size of 0 is selected, CMA is disabled by 120ddb26d8eSChristoph Hellwig default, but it can be enabled by passing cma=size[MG] to the kernel. 121ddb26d8eSChristoph Hellwig 122ddb26d8eSChristoph Hellwig 123ddb26d8eSChristoph Hellwigconfig CMA_SIZE_PERCENTAGE 124ddb26d8eSChristoph Hellwig int "Percentage of total memory" 125ddb26d8eSChristoph Hellwig depends on !CMA_SIZE_SEL_MBYTES 126ddb26d8eSChristoph Hellwig default 0 if X86 127ddb26d8eSChristoph Hellwig default 10 128ddb26d8eSChristoph Hellwig help 129ddb26d8eSChristoph Hellwig Defines the size of the default memory area for Contiguous Memory 130ddb26d8eSChristoph Hellwig Allocator as a percentage of the total memory in the system. 131ddb26d8eSChristoph Hellwig If 0 percent is selected, CMA is disabled by default, but it can be 132ddb26d8eSChristoph Hellwig enabled by passing cma=size[MG] to the kernel. 133ddb26d8eSChristoph Hellwig 134ddb26d8eSChristoph Hellwigchoice 135ddb26d8eSChristoph Hellwig prompt "Selected region size" 136ddb26d8eSChristoph Hellwig default CMA_SIZE_SEL_MBYTES 137ddb26d8eSChristoph Hellwig 138ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MBYTES 139ddb26d8eSChristoph Hellwig bool "Use mega bytes value only" 140ddb26d8eSChristoph Hellwig 141ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_PERCENTAGE 142ddb26d8eSChristoph Hellwig bool "Use percentage value only" 143ddb26d8eSChristoph Hellwig 144ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MIN 145ddb26d8eSChristoph Hellwig bool "Use lower value (minimum)" 146ddb26d8eSChristoph Hellwig 147ddb26d8eSChristoph Hellwigconfig CMA_SIZE_SEL_MAX 148ddb26d8eSChristoph Hellwig bool "Use higher value (maximum)" 149ddb26d8eSChristoph Hellwig 150ddb26d8eSChristoph Hellwigendchoice 151ddb26d8eSChristoph Hellwig 152ddb26d8eSChristoph Hellwigconfig CMA_ALIGNMENT 153ddb26d8eSChristoph Hellwig int "Maximum PAGE_SIZE order of alignment for contiguous buffers" 154ddb26d8eSChristoph Hellwig range 4 12 155ddb26d8eSChristoph Hellwig default 8 156ddb26d8eSChristoph Hellwig help 157ddb26d8eSChristoph Hellwig DMA mapping framework by default aligns all buffers to the smallest 158ddb26d8eSChristoph Hellwig PAGE_SIZE order which is greater than or equal to the requested buffer 159ddb26d8eSChristoph Hellwig size. This works well for buffers up to a few hundreds kilobytes, but 160ddb26d8eSChristoph Hellwig for larger buffers it just a memory waste. With this parameter you can 161ddb26d8eSChristoph Hellwig specify the maximum PAGE_SIZE order for contiguous buffers. Larger 162ddb26d8eSChristoph Hellwig buffers will be aligned only to this specified order. The order is 163ddb26d8eSChristoph Hellwig expressed as a power of two multiplied by the PAGE_SIZE. 164ddb26d8eSChristoph Hellwig 165ddb26d8eSChristoph Hellwig For example, if your system defaults to 4KiB pages, the order value 166ddb26d8eSChristoph Hellwig of 8 means that the buffers will be aligned up to 1MiB only. 167ddb26d8eSChristoph Hellwig 168ddb26d8eSChristoph Hellwig If unsure, leave the default value "8". 169ddb26d8eSChristoph Hellwig 170ddb26d8eSChristoph Hellwigendif 171ddb26d8eSChristoph Hellwig 17270ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG 17370ca7ba2SAndy Shevchenko bool "Enable debugging of DMA-API usage" 17470ca7ba2SAndy Shevchenko select NEED_DMA_MAP_STATE 17570ca7ba2SAndy Shevchenko help 17670ca7ba2SAndy Shevchenko Enable this option to debug the use of the DMA API by device drivers. 17770ca7ba2SAndy Shevchenko With this option you will be able to detect common bugs in device 17870ca7ba2SAndy Shevchenko drivers like double-freeing of DMA mappings or freeing mappings that 17970ca7ba2SAndy Shevchenko were never allocated. 18070ca7ba2SAndy Shevchenko 18170ca7ba2SAndy Shevchenko This also attempts to catch cases where a page owned by DMA is 18270ca7ba2SAndy Shevchenko accessed by the cpu in a way that could cause data corruption. For 18370ca7ba2SAndy Shevchenko example, this enables cow_user_page() to check that the source page is 18470ca7ba2SAndy Shevchenko not undergoing DMA. 18570ca7ba2SAndy Shevchenko 18670ca7ba2SAndy Shevchenko This option causes a performance degradation. Use only if you want to 18770ca7ba2SAndy Shevchenko debug device drivers and dma interactions. 18870ca7ba2SAndy Shevchenko 18970ca7ba2SAndy Shevchenko If unsure, say N. 19070ca7ba2SAndy Shevchenko 19170ca7ba2SAndy Shevchenkoconfig DMA_API_DEBUG_SG 19270ca7ba2SAndy Shevchenko bool "Debug DMA scatter-gather usage" 19370ca7ba2SAndy Shevchenko default y 19470ca7ba2SAndy Shevchenko depends on DMA_API_DEBUG 19570ca7ba2SAndy Shevchenko help 19670ca7ba2SAndy Shevchenko Perform extra checking that callers of dma_map_sg() have respected the 19770ca7ba2SAndy Shevchenko appropriate segment length/boundary limits for the given device when 19870ca7ba2SAndy Shevchenko preparing DMA scatterlists. 19970ca7ba2SAndy Shevchenko 20070ca7ba2SAndy Shevchenko This is particularly likely to have been overlooked in cases where the 20170ca7ba2SAndy Shevchenko dma_map_sg() API is used for general bulk mapping of pages rather than 20270ca7ba2SAndy Shevchenko preparing literal scatter-gather descriptors, where there is a risk of 20370ca7ba2SAndy Shevchenko unexpected behaviour from DMA API implementations if the scatterlist 20470ca7ba2SAndy Shevchenko is technically out-of-spec. 20570ca7ba2SAndy Shevchenko 20670ca7ba2SAndy Shevchenko If unsure, say N. 207