linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* getting physical address of buffer into user space
@ 2020-02-18 20:56 Marty Leisner
  2020-02-20 21:27 ` Alexander Duyck
  0 siblings, 1 reply; 2+ messages in thread
From: Marty Leisner @ 2020-02-18 20:56 UTC (permalink / raw)
  To: linux-mm; +Cc: maleisner

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)

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)

-- 
Marty Leisner <linux@rochester.rr.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: getting physical address of buffer into user space
  2020-02-18 20:56 getting physical address of buffer into user space Marty Leisner
@ 2020-02-20 21:27 ` Alexander Duyck
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Duyck @ 2020-02-20 21:27 UTC (permalink / raw)
  To: Marty Leisner; +Cc: linux-mm, maleisner

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-20 21:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 20:56 getting physical address of buffer into user space Marty Leisner
2020-02-20 21:27 ` Alexander Duyck

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).