函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\dma\swiotlb.c Create Date:2022-07-27 11:36:03
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:swiotlb_tbl_map_single

函数原型:phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr, phys_addr_t orig_addr, size_t mapping_size, size_t alloc_size, enum dma_data_direction dir, unsigned long attrs)

返回类型:phys_addr_t

参数:

类型参数名称
struct device *hwdev
dma_addr_ttbl_dma_addr
phys_addr_torig_addr
size_tmapping_size
size_talloc_size
enum dma_data_directiondir
unsigned longattrs
462  如果no_iotlb_memorypanic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
465  如果mem_encrypt_active()则pr_warn_once("Memory encryption is active and system is using DMA bounce buffers\n")
468  如果mapping_size大于alloc_size
469  dev_warn_once(hwdev, "Invalid sizes (mapping: %zd bytes, alloc: %zd bytes)", mapping_size, alloc_size)
471  返回:DMA_MAPPING_ERROR
474  mask等于dma_get_seg_boundary(hwdev)
476  tbl_dma_addr与等于mask
478  offset_slots等于@a is a power of 2 value (tbl_dma_addr, 1 << log of the size of each IO TLB slab. The number of slabs is command line* controllable.)右移log of the size of each IO TLB slab. The number of slabs is command line* controllable.
483  max_slots等于如果mask加1则@a is a power of 2 value (mask + 1, 1 << log of the size of each IO TLB slab. The number of slabs is command line* controllable.)右移log of the size of each IO TLB slab. The number of slabs is command line* controllable.位否则1UL左移BITS_PER_LONGlog of the size of each IO TLB slab. The number of slabs is command line* controllable.
491  nslots等于@a is a power of 2 value (alloc_size, 1 << log of the size of each IO TLB slab. The number of slabs is command line* controllable.)右移log of the size of each IO TLB slab. The number of slabs is command line* controllable.
492  如果alloc_size大于等于PAGE_SIZEstride等于1左移PAGE_SHIFT determines the page size log of the size of each IO TLB slab. The number of slabs is command line* controllable.
494  否则stride等于1
497  BUG_ON(!nslots)
503  spin_lock_irqsave( & Protect the above data structures in the map and unmap calls, flags)
505  如果此条件成立可能性小(为编译器优化)(nslots > The number of IO TLB blocks (in groups of 64) between io_tlb_start and* io_tlb_end. This is command line adjustable via setup_io_tlb_npages. - The number of used IO TLB block)则转到:not_found
508  index等于@a is a power of 2 value (io_tlb_index, stride)
509  如果index大于等于The number of IO TLB blocks (in groups of 64) between io_tlb_start and* io_tlb_end. This is command line adjustable via setup_io_tlb_npages.index等于0
511  wrap等于index
513  循环
516  index加等于stride
519  如果index恒等于wrap则转到:not_found
529  count等于0
544  转到:found
546  index加等于stride
547  如果index大于等于The number of IO TLB blocks (in groups of 64) between io_tlb_start and* io_tlb_end. This is command line adjustable via setup_io_tlb_npages.index等于0
549 index不等于wrap循环
551  not_found :
552  tmp_io_tlb_used等于The number of used IO TLB block
554  spin_unlock_irqrestore( & Protect the above data structures in the map and unmap calls, flags)
555  如果非attrs按位与DMA_ATTR_NO_WARN: This tells the DMA-mapping subsystem to suppress* allocation failure reports (similarly to __GFP_NOWARN).的值且printk_ratelimit()则dev_warn(hwdev, "swiotlb buffer is full (sz: %zd bytes), total %lu (slots), used %lu (slots)\n", alloc_size, The number of IO TLB blocks (in groups of 64) between io_tlb_start and* io_tlb_end. This is command line adjustable via setup_io_tlb_npages., tmp_io_tlb_used)
558  返回:DMA_MAPPING_ERROR
559  found :
560  The number of used IO TLB block加等于nslots
561  spin_unlock_irqrestore( & Protect the above data structures in the map and unmap calls, flags)
568 i小于nslots循环io_tlb_orig_addr[index + i]等于orig_addri左移log of the size of each IO TLB slab. The number of slabs is command line* controllable.位的值
570  如果非attrs按位与DMA_ATTR_SKIP_CPU_SYNC: Allows platform code to skip synchronization of* the CPU cache for the given buffer assuming that it has been already* transferred to 'device' domain.的值且dir恒等于DMA_TO_DEVICEdir恒等于DMA_BIDIRECTIONAL的值则Bounce: copy the swiotlb buffer from or back to the original dma location
574  返回:tlb_addr
调用者
名称描述
swiotlb_mapCreate a swiotlb mapping for the buffer at @phys, and in case of DMAing* to the device copy the data into it as well.