In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Two types of DMA mapping
1.1. Consistent DMA mapping (Consistent DMA mappings)
It is mainly used to map areas that have been used for a long time.
CPU and DMA controller do not need to consider the impact of cache.
The consistent here is actually the concept of coherent, and there is no guarantee of consistent, that is, you need memory barrier to guarantee memory order.
1.2 streaming DMA Mapping (streaming DMA mapping)
It is mainly used for one-time DMA transmission and will be released after the transfer is completed.
two。 Specify the addressing range of the DMA device
Include/linux/dma-mapping.h
/ / Mapping range static inline int dma_set_coherent_mask for consistent memory mapping (struct device * dev, U64 mask) / / Mapping range static inline int dma_set_mask for streaming memory mapping (struct device * dev, U64 mask)
3.DMA mapping interface
3.1 consistent DMA interface
Assign a larger DMA buffer
/ / dev DMA controller device / / DMA buffer size to be assigned by size / / dma_handle returns the physical address of the DMA buf / / flag assignment flag / / the virtual address of the value DMA buffer void * dma_alloc_coherent (struct device * dev, size_t size, dma_addr_t * dma_handle Gfp_t flag) / / dev DMA controller device / / DMA buffer size released by size / / virtual address of cpu_addr DMA buf / / physical address of dma_handle DMA buf void dma_free_coherent (struct device * dev, size_t size, void * cpu_addr, dma_addr_t dma_handle)
Assign a smaller DMA buffer and apply from the dma poll.
/ * dma_pool_alloc-get a consistent memory from dma poll * @ pool: dma pool * @ mem_flags: GFP_* bitmask * @ handle: return the dma address of the memory block * / void * dma_pool_alloc (struct dma_pool * pool, gfp_t mem_flags) Dma_addr_t * handle) / * dma_pool_free-release the memory back to dma pool * @ pool: dma pool * @ vaddr: the virtual address of the memory block * @ dma: the physical address of the memory block * / void dma_pool_free (struct dma_pool * pool, void * vaddr, dma_addr_t dma)
3.2Stream DMA Interface
/ / dev devices that need to map memory / / buffer virtual address of ptr mapping / / size of size map / / dir transmission direction / / attr attribute / / return value dma physical address dma_addr_t dma_map_single_attrs (struct device * dev, void * ptr, size_t size, enum dma_data_direction dir) Unsigned long attrs) / / dev devices that need to map memory / physical address of / addr dma area / / size of size mapping / / dir transport direction / / attr attribute void dma_unmap_single_attrs (struct device * dev, dma_addr_t addr, size_t size, enum dma_data_direction dir, unsigned long attrs)
Page mapping
Dma_addr_t dma_map_page (struct device * dev, struct page * page, size_t offset, size_t size, enum dma_data_direction dir) void dma_unmap_page (struct device * dev, dma_addr_t addr, size_t size, enum dma_data_direction dir)
Return dma mapping error
/ / return dma mapping error int dma_mapping_error (struct device * dev, dma_addr_t dma_addr)
Map scatterlist
Int dma_map_sg_attrs (struct device * dev, struct scatterlist * sg, int nents, enum dma_data_direction dir, unsigned long attrs) void dma_unmap_sg_attrs (struct device * dev, struct scatterlist * sg, int nents, enum dma_data_direction dir, unsigned long attrs) / / dma address and length sg_dma_address (struct scatterlist * sg) sg_dma_len (struct scatterlist * sg) after map is returned.
Sync operation
Voiddma_sync_ single_for_cpu (struct device * dev,dma_addr_t addr,size_t size,enum dma_data_direction dir) voiddma_sync_ single_for_device (struct device * dev,dma_addr_t addr,size_t size,enum dma_data_direction dir) voiddma_sync_sg_for_cpu (struct device * dev, struct scatterlist * sg,int nelems, enum dma_data_direction dir) voiddma_sync_sg_for_device (struct device * dev, struct scatterlist * sg,int nelems Enum dma_data_direction dir)
The above are all the relevant knowledge points of this introduction, if you have anything to add, you can contact the editor.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.