Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\dma\direct.c Create Date:2022-07-28 10:33:09
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:dma_direct_alloc_pages

Proto:void *dma_direct_alloc_pages(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)

Type:void

Parameter:

TypeParameterName
struct device *dev
size_tsize
dma_addr_t *dma_handle
gfp_tgfp
unsigned longattrs
139  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_DMA_DIRECT_REMAP) && Check if an allocation needs to be marked uncached to be coherent. && Not gfpflags_allow_blocking(gfp) Then
142  ret = dma_alloc_from_pool( align the pointer to the (next) page boundary (size), & page, gfp)
143  If Not ret Then Return NULL
145  Go to done
148  page = __dma_direct_alloc_pages(dev, size, gfp, attrs)
149  If Not page Then Return NULL
152  If attrs & DMA_ATTR_NO_KERNEL_MAPPING: Lets the platform to avoid creating a kernel* virtual mapping for the allocated buffer. && Not force_dma_unencrypted(dev) Then
155  If Not PageHighMem(page) Then arch_dma_prep_coherent(page, size)
158  ret = page
159  Go to done
162  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_DMA_DIRECT_REMAP) && Check if an allocation needs to be marked uncached to be coherent. || IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_DMA_REMAP) && PageHighMem(page) Then
166  arch_dma_prep_coherent(page, align the pointer to the (next) page boundary (size))
169  ret = dma_common_contiguous_remap(page, align the pointer to the (next) page boundary (size), Return the page attributes used for mapping dma_alloc_* memory, either in* kernel space if remapping is needed, or to userspace through dma_mmap_*., __builtin_return_address(0))
172  If Not ret Then
174  Return ret
177  memset(ret, 0, size)
178  Go to done
181  If PageHighMem(page) Then
188  dev_info(dev, "Rejecting highmem page from CMA.\n")
189  dma_free_contiguous(dev, page, size)
190  Return NULL
193  ret = page_address(page)
194  If force_dma_unencrypted(dev) Then set_memory_decrypted((unsignedlong)ret, 1 << get_order - Determine the allocation order of a memory size*@size: The size for which to get the order* Determine the allocation order of a particular sized block of memory)
197  memset(ret, 0, size)
199  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_ARCH_HAS_UNCACHED_SEGMENT) && Check if an allocation needs to be marked uncached to be coherent. Then
201  arch_dma_prep_coherent(page, size)
202  ret = uncached_kernel_address(ret)
204  done :
205  If force_dma_unencrypted(dev) Then dma_handle = __phys_to_dma(dev, Change "struct page" to physical address.(page))
207  Else dma_handle = If memory encryption is supported, phys_to_dma will set the memory encryption* bit in the DMA address, and dma_to_phys will clear it. The raw __phys_to_dma* and __dma_to_phys versions should only be used on non-encrypted memory for
209  Return ret
Caller
NameDescribe
dma_direct_alloc
gart_alloc_coherentallocate and map a coherent mapping