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