Thread (8 messages) flat view 8 messages, 2 authors, 2016-12-31

Driver to allow DMA from user space

From: Ran Shalit <hidden>
Date: 2016-12-19 16:08:47

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help