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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With