I have a situation where I need to call dma_unmap_single
after dma_sync_single_for_cpu
. Below is my scenario.
kmalloc()
dma_map_single
with DMA_FROM_DEVICE
direction. dma_sync_single_for_cpu
. dma_unmap_single
with DMA_FROM_DEVICE
direction. Are all the above steps acceptable?
The buffer "ownership" (CPU or device) matters only for deciding who is allowed to access the buffer's contents.
dma_unmap_single()
does not care about the contents; it can be called in either state.
Please note that after the DMA unmapping, the memory again "belongs" to the CPU. If you are doing only a single DMA transfer, you do not need to call dma_sync_single_for_cpu()
; you can just read the buffer after the dma_unmap_single()
call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.