getting physical address of buffer into user space
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)
Signature · 1 line
Marty Leisner <[email protected]>
Quoted 3 lines · Marty Leisner
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.
Quoted 10 lines
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.