Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\amd_gart_64.c Create Date:2022-07-28 08:52:26
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:DMA map all entries in a scatterlist.* Merge chunks that have page aligned sizes into a continuous mapping.

Proto:static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir, unsigned long attrs)

Type:int

Parameter:

TypeParameterName
struct device *dev
struct scatterlist *sg
intnents
enum dma_data_directiondir
unsigned longattrs
384  need = 0
385  pages = 0
389  If nents == 0 Then Return 0
392  out = 0
393  start = 0
394  start_sg = sg
395  sgmap = sg
396  seg_size = 0
397  max_seg_size = dma_get_max_seg_size(dev)
398  ps = NULL
401  addr = sg_phys - Return physical address of an sg entry*@sg: SG entry* Description:* This calls page_to_phys() on the page in this sg entry, and adds the* sg offset. The caller must know that it is legal to call page_to_phys()* on the sg page.
403  dma_address = addr
404  BUG_ON(length == 0)
406  nextneed = need_iommu(dev, addr, length)
409  If i > start Then
415  If Not iommu_merge || Not nextneed || Not need || offset || length + seg_size > max_seg_size || (offset + length) % PAGE_SIZE Then
418  If dma_map_cont(dev, start_sg, i - start, sgmap, pages, need) < 0 Then Go to error
421  out++
423  seg_size = 0
425  pages = 0
426  start = i
427  start_sg = s
431  seg_size += length
432  need = nextneed
433  pages += iommu_num_pages(offset, length, PAGE_SIZE)
434  ps = s
436  If dma_map_cont(dev, start_sg, i - start, sgmap, pages, need) < 0 Then Go to error
438  out++
439  Use global flush state to avoid races with multiple flushers.
440  If out < nents Then
441  sgmap = sg_next - return the next scatterlist entry in a list*@sg: The current sg entry* Description:* Usually the next entry will be @sg@ + 1, but if this sg element is part* of a chained scatterlist, it could jump to the start of a new* scatterlist array.
442  dma_length = 0
444  Return out
446  error :
447  Use global flush state to avoid races with multiple flushers.
448  Wrapper for pci_unmap_single working with scatterlists.
451  If force_iommu || iommu_merge Then
452  out = Fallback for dma_map_sg in case of overflow
453  If out > 0 Then Return out
456  If panic_on_overflow Then panic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
459  iommu_full(dev, pages << PAGE_SHIFT determines the page size , dir)
460  Loop over each sg element, following the pointer to a new list if necessary(sg, s, nents, i)
461  dma_address = DMA_MAPPING_ERROR
462  Return 0