*参照元 [#r1326de3]
#backlinks

*説明 [#ka114d9b]
FIXME: なにをするもの?

-とぴっく
--解説

**主要 API [#r3de2f60]

-Using large DMA-coherent buffers
--[[linux-4.4.1/dma_alloc_coherent()]]
--[[linux-4.4.1/dma_zalloc_coherent()]]
--[[linux-4.4.1/dma_free_coherent()]]

-Using small DMA-coherent buffers
--[[linux-4.4.1/dma_pool_create()]]
--[[linux-4.4.1/dma_pool_zalloc()]]
--[[linux-4.4.1/dma_pool_alloc()]]
--[[linux-4.4.1/dma_pool_free()]]
--[[linux-4.4.1/dma_pool_destroy()]]

-DMA addressing limitations
--[[linux-4.4.1/dma_set_mask_and_coherent()]]
--[[linux-4.4.1/dma_set_mask()]]
--[[linux-4.4.1/dma_set_coherent_mask()]]
--[[linux-4.4.1/dma_get_required_mask()]]

-Streaming DMA mappings
--[[linux-4.4.1/dma_map_single()]]
--[[linux-4.4.1/dma_unmap_single()]]
--[[linux-4.4.1/dma_map_page()]]
--[[linux-4.4.1/dma_unmap_page()]]
--[[linux-4.4.1/dma_mapping_error()]]
--[[linux-4.4.1/dma_map_sg()]]

 int i, count = dma_map_sg(dev, sglist, nents, direction);
 struct scatterlist *sg;
 
 for_each_sg(sglist, sg, count, i) {
 	hw_address[i] = sg_dma_address(sg);
 	hw_len[i] = sg_dma_len(sg);
 }


--[[linux-4.4.1/dma_unmap_sg()]]

--[[linux-4.4.1/dma_sync_single_for_cpu()]]
--[[linux-4.4.1/dma_sync_single_for_device()]]
--[[linux-4.4.1/dma_sync_sg_for_cpu()]]
--[[linux-4.4.1/dma_sync_sg_for_device()]]

--[[linux-4.4.1/dma_map_single_attrs()]]
--[[linux-4.4.1/dma_unmap_single_attrs()]]
--[[linux-4.4.1/dma_map_sg_attrs()]]
--[[linux-4.4.1/dma_unmap_sg_attrs()]]

 #include <linux/dma-attrs.h>
 /* DMA_ATTR_FOO should be defined in linux/dma-attrs.h and
  * documented in Documentation/DMA-attributes.txt */
 ...
 
         DEFINE_DMA_ATTRS(attrs);
         dma_set_attr(DMA_ATTR_FOO, &attrs);
         ....
         n = dma_map_sg_attrs(dev, sg, nents, DMA_TO_DEVICE, &attr);
         ....

 void whizco_dma_map_sg_attrs(struct device *dev, dma_addr_t dma_addr,
         size_t size, enum dma_data_direction dir,
         struct dma_attrs *attrs)
 {
         ....
         int foo =  dma_get_attr(DMA_ATTR_FOO, attrs);
         ....
         if (foo)
                 /* twizzle the frobnozzle */
         ....

-Advanced dma_ usage
--[[linux-4.4.1/dma_alloc_noncoherent()]]
--[[linux-4.4.1/dma_free_noncoherent()]]
--[[linux-4.4.1/dma_get_cache_alignment()]]
--[[linux-4.4.1/dma_cache_sync()]]
--[[linux-4.4.1/dma_declare_coherent_memory()]]
--[[linux-4.4.1/dma_mark_declared_memory_occupied()]]

-Others
--[[linux-4.4.1/dma_alloc_from_coherent()]]: try to allocate memory from the per-device coherent area
--[[linux-4.4.1/dma_release_from_coherent()]]: try to free the memory allocated from per-device coherent memory pool
--[[linux-4.4.1/dma_mmap_from_coherent()]]: try to mmap the memory allocated from per-device coherent memory pool to userspace

-Managed
--[[linux-4.4.1/dmam_alloc_coherent()]]: Managed dma_alloc_coherent
--[[linux-4.4.1/dmam_free_coherent()]]: Managed dma_free_coherent
--[[linux-4.4.1/dmam_alloc_noncoherent()]]: Managed dma_alloc_non_coherent
--[[linux-4.4.1/dmam_free_noncoherent()]]: Managed dma_free_noncoherent
--[[linux-4.4.1/dmam_declare_coherent_memory()]]: Managed dma_declare_coherent_memory
--[[linux-4.4.1/dmam_release_declared_memory()]]: Managed dma_release_declared_memory. 


**参考 [#n14c90c7]

https://www.kernel.org/doc/Documentation/DMA-API.txt

linux/Documentation/DocBook/device-drivers/


**関連モジュール [#p7eb18b5]


*コメント [#h36c76a6]

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