^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) config NO_DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) config HAS_DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) depends on !NO_DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) default y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) config DMA_OPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) depends on HAS_DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # IOMMU drivers that can bypass the IOMMU code and optionally use the direct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # mapping fast path should select this option and set the dma_ops_bypass
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) # flag in struct device where applicable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) config DMA_OPS_BYPASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) config NEED_SG_DMA_LENGTH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) config NEED_DMA_MAP_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) config ARCH_DMA_ADDR_T_64BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) def_bool 64BIT || PHYS_ADDR_T_64BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) config ARCH_HAS_DMA_COHERENCE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) config ARCH_HAS_DMA_SET_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) # Select this option if the architecture needs special handling for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) # DMA_ATTR_WRITE_COMBINE. Normally the "uncached" mapping should be what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) # people thing of when saying write combine, so very few platforms should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) # need to enable this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) config ARCH_HAS_DMA_WRITE_COMBINE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) # Select if the architectures provides the arch_dma_mark_clean hook
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) config ARCH_HAS_DMA_MARK_CLEAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) config DMA_DECLARE_COHERENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) config ARCH_HAS_SETUP_DMA_OPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) config ARCH_HAS_TEARDOWN_DMA_OPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) config ARCH_HAS_SYNC_DMA_FOR_DEVICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) config ARCH_HAS_SYNC_DMA_FOR_CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) select NEED_DMA_MAP_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) config ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) config ARCH_HAS_DMA_PREP_COHERENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) config ARCH_HAS_FORCE_DMA_UNENCRYPTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) config DMA_VIRT_OPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) depends on HAS_DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) select DMA_OPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) config SWIOTLB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) select NEED_DMA_MAP_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) # Should be selected if we can mmap non-coherent mappings to userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) # The only thing that is really required is a way to set an uncached bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) # in the pagetables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) config DMA_NONCOHERENT_MMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) default y if !MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) config DMA_COHERENT_POOL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) select GENERIC_ALLOCATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) config DMA_REMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) depends on MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) select DMA_NONCOHERENT_MMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) config DMA_DIRECT_REMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) select DMA_REMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) select DMA_COHERENT_POOL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) config DMA_CMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) bool "DMA Contiguous Memory Allocator"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) depends on HAVE_DMA_CONTIGUOUS && CMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) This enables the Contiguous Memory Allocator which allows drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) to allocate big physically-contiguous blocks of memory for use with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) hardware components that do not support I/O map nor scatter-gather.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) You can disable CMA by specifying "cma=0" on the kernel's command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) For more information see <kernel/dma/contiguous.c>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) If unsure, say "n".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if DMA_CMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) config DMA_PERNUMA_CMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) bool "Enable separate DMA Contiguous Memory Area for each NUMA Node"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) default NUMA && ARM64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) Enable this option to get pernuma CMA areas so that devices like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) ARM64 SMMU can get local memory by DMA coherent APIs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) You can set the size of pernuma CMA by specifying "cma_pernuma=size"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) on the kernel's command line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) comment "Default contiguous memory area size:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) config CMA_SIZE_MBYTES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int "Size in Mega Bytes"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) depends on !CMA_SIZE_SEL_PERCENTAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) default 0 if X86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) default 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) Defines the size (in MiB) of the default memory area for Contiguous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) Memory Allocator. If the size of 0 is selected, CMA is disabled by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) default, but it can be enabled by passing cma=size[MG] to the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) config CMA_SIZE_PERCENTAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int "Percentage of total memory"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) depends on !CMA_SIZE_SEL_MBYTES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) default 0 if X86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) default 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) Defines the size of the default memory area for Contiguous Memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) Allocator as a percentage of the total memory in the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) If 0 percent is selected, CMA is disabled by default, but it can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) enabled by passing cma=size[MG] to the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) choice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) prompt "Selected region size"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) default CMA_SIZE_SEL_MBYTES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) config CMA_SIZE_SEL_MBYTES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) bool "Use mega bytes value only"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) config CMA_SIZE_SEL_PERCENTAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) bool "Use percentage value only"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) config CMA_SIZE_SEL_MIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) bool "Use lower value (minimum)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) config CMA_SIZE_SEL_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) bool "Use higher value (maximum)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) endchoice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) config CMA_ALIGNMENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) int "Maximum PAGE_SIZE order of alignment for contiguous buffers"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) range 2 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) default 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) DMA mapping framework by default aligns all buffers to the smallest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) PAGE_SIZE order which is greater than or equal to the requested buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) size. This works well for buffers up to a few hundreds kilobytes, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) for larger buffers it just a memory waste. With this parameter you can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) specify the maximum PAGE_SIZE order for contiguous buffers. Larger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) buffers will be aligned only to this specified order. The order is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) expressed as a power of two multiplied by the PAGE_SIZE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) For example, if your system defaults to 4KiB pages, the order value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) of 8 means that the buffers will be aligned up to 1MiB only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) If unsure, leave the default value "8".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) config DMA_API_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) bool "Enable debugging of DMA-API usage"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) select NEED_DMA_MAP_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) Enable this option to debug the use of the DMA API by device drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) With this option you will be able to detect common bugs in device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) drivers like double-freeing of DMA mappings or freeing mappings that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) were never allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) This option causes a performance degradation. Use only if you want to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) debug device drivers and dma interactions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) If unsure, say N.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) config DMA_API_DEBUG_SG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) bool "Debug DMA scatter-gather usage"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) default y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) depends on DMA_API_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) Perform extra checking that callers of dma_map_sg() have respected the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) appropriate segment length/boundary limits for the given device when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) preparing DMA scatterlists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) This is particularly likely to have been overlooked in cases where the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) dma_map_sg() API is used for general bulk mapping of pages rather than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) preparing literal scatter-gather descriptors, where there is a risk of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) unexpected behaviour from DMA API implementations if the scatterlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) is technically out-of-spec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) If unsure, say N.