Does every dma_map_single call require a corresponding dma_unmap_single?

I am moving a large code base to the Linux kernel device driver. ASIC uses a huge number of DMA channels.

I memory kmalloc s GFP_KERNEL|GFP_DMA. Before starting DMA, I use dma_map_single to get the hardware (physical) memory address to feed to the equipment. (Does it also flash / delete memory from dcache?) I sometimes need CPU access for data after DMA completes, but not often. Before I access the data through code, I do dma_unmap_single to avoid cache coherency issues.

In cases where I do not need access to the CPU, do I still need to call dma_unmap_single? Do I dma_unmap_singleevery pointer I have dma_map_single? Does the dma_map_singleresource (for example, a table entry) use which will free dma_unmap_single?

DMA-API.txt is not clear regarding good DMA memory hygiene.

Thank!

+2
source share
2 answers

With dma_map_singleyou map the memory to transmit DMA. You get a physical pointer to the memory, so the device can use DMA for this address.

Using, dma_unmap_singleyou remove the memory card mentioned above. You must do this when your transfers are over.

DMA, , . , DMA, . , dma_sync_single_for_device; , dma_sync_single_for_cpu

+3

dma_map api , dma_unmap.

0

All Articles