*参照元 [#v52e6933]
#backlinks

*説明 [#r1db2a79]
-パス: [[linux-4.4.1/lib/swiotlb.c]]

-FIXME: これは何?
--説明


**引数 [#a476b1c1]
-struct device *dev
--
--[[linux-4.4.1/device]]
-struct page *page
--
--[[linux-4.4.1/page]]
-unsigned long offset
--
-size_t size
--
-enum dma_data_direction dir
--
--[[linux-4.4.1/dma_data_direction]]
-struct dma_attrs *attrs
--
--[[linux-4.4.1/dma_attrs]]


**返り値 [#p697a70c]
-dma_addr_t
--
--[[linux-4.4.1/dma_addr_t]]


**参考 [#yc6f388f]


*実装 [#qbf45789]
 /*
  * Map a single buffer of the indicated size for DMA in streaming mode.  The
  * physical address to use is returned.
  *
  * Once the device is given the dma address, the device owns this memory until
  * either swiotlb_unmap_page or swiotlb_dma_sync_single is performed.
  */
 dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
                             unsigned long offset, size_t size,
                             enum dma_data_direction dir,
                             struct dma_attrs *attrs)
 {
         phys_addr_t map, phys = page_to_phys(page) + offset;
         dma_addr_t dev_addr = phys_to_dma(dev, phys);
 
-
--[[linux-4.4.1/phys_addr_t]]
--[[linux-4.4.1/page_to_phys()]]
--[[linux-4.4.1/dma_addr_t]]
--[[linux-4.4.1/phys_to_dma()]]

         BUG_ON(dir == DMA_NONE);
-
--[[linux-4.4.1/BUG_ON()]]

         /*
          * If the address happens to be in the device's DMA window,
          * we can safely return the device addr and not worry about bounce
          * buffering it.
          */
         if (dma_capable(dev, dev_addr, size) && !swiotlb_force)
                 return dev_addr;
 
-
--[[linux-4.4.1/dma_capable()]]
--[[linux-4.4.1/swiotlb_force(global)]]

         trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force);
 
-
--[[linux-4.4.1/trace_swiotlb_bounced()]]

         /* Oh well, have to allocate and map a bounce buffer. */
         map = map_single(dev, phys, size, dir);
         if (map == SWIOTLB_MAP_ERROR) {
                 swiotlb_full(dev, size, dir, 1);
                 return phys_to_dma(dev, io_tlb_overflow_buffer);
         }
 
-
--[[linux-4.4.1/map_single()]]
--[[linux-4.4.1/swiotlb_full()]]
--[[linux-4.4.1/io_tlb_overflow_buffer(global)]]

         dev_addr = phys_to_dma(dev, map);
 
         /* Ensure that the address returned is DMA'ble */
         if (!dma_capable(dev, dev_addr, size)) {
                 swiotlb_tbl_unmap_single(dev, map, size, dir);
                 return phys_to_dma(dev, io_tlb_overflow_buffer);
         }
 
-
--[[linux-4.4.1/swiotlb_tbl_unmap_single()]]

         return dev_addr;
 }
 EXPORT_SYMBOL_GPL(swiotlb_map_page);
-
--[[linux-4.4.1/EXPORT_SYMBOL_GPL()]]


*コメント [#w29f4f1a]


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS