linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.duyck@gmail.com>
To: Marty Leisner <linux@rochester.rr.com>
Cc: linux-mm <linux-mm@kvack.org>, maleisner@gmail.com
Subject: Re: getting physical address of buffer into user space
Date: Thu, 20 Feb 2020 13:27:59 -0800	[thread overview]
Message-ID: <CAKgT0Ucfwq_8zmXD4yPs7GkYE2EhGHNcMzDb53X+iZGmpsnNtQ@mail.gmail.com> (raw)
In-Reply-To: <20200218155656.01223f67f9b2d902ce975fd0@rochester.rr.com>

On Tue, Feb 18, 2020 at 12:56 PM Marty Leisner <linux@rochester.rr.com> wrote:
>
> I've read tutorials and seen example programs on how to get page information into userspace
> (eventually, I'll want to dma from a UIO driver)

Instead of using a UIO driver you may want to consider a VFIO driver
as you may not be able to access memory directly from the device with
a UIO driver if an IOMMU is present in the system. UIO is normally
only used for small embedded controllers where you just need MMIO
access.

> For POC, I have a simple driver with an mmap rule, which does kmalloc on a new buffer.
>
> The driver can read/write the memory, and the user space program can read/write the memory (and both
> sides agree on the data read/written).
>
> It appears in /proc/self/maps, and when I try to look it up in /proc/self/pagemap, it says its
> neither swapped nor present.
>
> This seems like a clever way -- if it works (the alternative is sloppy ioctl's or other custom
> methods)

I suggest you just take a look at VFIO. You can find some user
documentation here:
https://www.kernel.org/doc/html/latest/driver-api/vfio.html

There are multiple userspace drivers out there that make use of UIO or
VFIO functionality. If you are in need of examples just go take a look
at the DPDK project (http://git.dpdk.org/dpdk/) as they have all of
their NIC drivers implemented in userspace and are using either a
igb_uio driver or vfio driver to connect to them.


      reply	other threads:[~2020-02-20 21:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 20:56 getting physical address of buffer into user space Marty Leisner
2020-02-20 21:27 ` Alexander Duyck [this message]

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=CAKgT0Ucfwq_8zmXD4yPs7GkYE2EhGHNcMzDb53X+iZGmpsnNtQ@mail.gmail.com \
    --to=alexander.duyck@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=linux@rochester.rr.com \
    --cc=maleisner@gmail.com \
    /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).