Hi,

dma_map_xxx / dma_unmap_xxx pair are used to do cache coherency.
see Documentation/DMA-API.txt.

dma_map_xxx: "Maps a piece of processor virtual memory so it can be accessed by the device and returns the physical handle of the memory."
dma_unmap_xxx: "Unmaps the region previously mapped.  All the parameters passed in must be identical to those passed in (and returned) by the mapping API."

Assuming you are doing DMA_TO_DEVICE synchronization:

cpu accesses buffer
dma_map_xxx  (after this point, cpu cannot touch the buffer)
device accesses buffer 


device accesses buffer
dma_unmap_xxx (after this point, device cannot touch the buffer)
cpu accesses buffer

Regards,
MH


On Sat, Feb 8, 2014 at 4:16 PM, m silverstri <michael.j.silverstri@gmail.com> wrote:
Hi,

I create DMA buffer in my kernel driver.
I would like to know what is  cache coherency guidelines for DMA
buffer referred by this post?
http://stackoverflow.com/questions/5564326/linux-kernel-device-driver-to-dma-into-kernel-space

Both my kernel driver and HW writes to the DMA buffer. I wnat to know
how to make sure  cache coherency.

Thank you.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies