kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: ranshalit@gmail.com (Ran Shalit)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Driver to allow DMA from user space
Date: Mon, 19 Dec 2016 18:08:47 +0200	[thread overview]
Message-ID: <CAJ2oMhLdc0FqxL2KUQYKNey7podoztoZnuWuWMmtTJukfFvp=Q@mail.gmail.com> (raw)

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

             reply	other threads:[~2016-12-19 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 16:08 Ran Shalit [this message]
2016-12-20  9:38 ` Driver to allow DMA from user space Greg KH
2016-12-20 10:15   ` Ran Shalit
2016-12-20 10:26     ` Greg KH
2016-12-24 15:47       ` Ran Shalit
2016-12-25 12:37         ` Greg KH
2016-12-30 18:11           ` Ran Shalit
2016-12-31 10:55             ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ2oMhLdc0FqxL2KUQYKNey7podoztoZnuWuWMmtTJukfFvp=Q@mail.gmail.com' \
    --to=ranshalit@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).