Hi,

I have a PCI device. There is a specific need that application (userspace) has to access that device and also DMA from Device is done to the User space buffer.

In this regard, I have done this:

For mapping the "Device Memory" have used mmap() command.

For using DMA, I have done as below:
ioctl (......) {
//Caluclate the Number of Pages etc
..kmalloc for sg_list & pages
..get_user_pages() - Convert to Kernel accessible.
..dma_map_sg() - Get DMA address.
.. copy_to_user(); - Copy the DMA address and Lenght to User Space.
..dma_unmap_sg()

}

I want to know if the above procedure is proper.
The reason is once I do this with a buffer and free the buffer, it crashes (Pointing to Free() call). So I want to make sure that this procedure for getting Physical Address & size for DMA is proper.

-hari