Driver to allow DMA from user space
Ran Shalit
ranshalit at gmail.com
Mon Dec 19 11:08:47 EST 2016
Hello,
I want to use DMA from userspace.
I already use dma in kernel, and now I want can create a character
device which will be responsible for this.
The only problem is that I want to use the same memory which was
allocated in kernel with dma_alloc_coherent.
Is it correct to use mmap in order to use the phsyical memory which
was allocated with dma_alloc_coherent ?
If it's that simple it can be surely helpful, and the simple driver
which wraps dma_alloc_coherent can do the job for dmaing from
userspace.
In kernel:
dma_buffer_info->buf_info[i].virtAddr = (uint8_t *)dma_alloc_coherent(
&ti667x_pci_dev[dev_id]->dev,
dma_buffer_info->buffer_size,
(dma_addr_t *)&dma_buffer_info->buf_info[i].pcieAddr,
GFP_KERNEL);
In userspace:
buf_desc[i].virtAddr = mmap(0,
size_of_buffer,
PROT_READ | PROT_WRITE,
MAP_SHARED,
pcie_drv_inst[dsp_id].dev_desc,
buf_desc[i].pcieAddr);
Thanks,
Ran
More information about the Kernelnewbies
mailing list