Age | Commit message (Collapse) | Author |
|
This is a complete redesign and rewrite of libbmm. This implementation
is based upon dma_bufs - where a dma_buf is a kernel-side buffer which
can be passed to and from other subsystems. libbmm becomes a provider
of dma_bufs - it permits userspace to allocate such things.
When a dma_buf is allocated, userspace is handed a file descriptor
which is unique to this buffer. This file descriptor can then be
passed into other subsystems, which can then request access to this
buffer.
The file descriptor supports very few operations - it can be mmap()d to
provide userspace access to the buffer, and it can be closed when it is
no longer required. Internally in the kernel, dma_bufs are reference
counted, so the dma_buf will only be freed when the last user gives up
its reference.
|
|
Add an API to export BMM buffers by passing in a physical address.
This allows a BMM buffer without a virtual mapping to be passed to
other device drivers.
|
|
Attaching to a buffer with an offset, and then subsequently asking for
it's physical address returned the non-offset buffer. Fix this by
tracking the physical offset.
|
|
Implement better tracking of phys/virt address usage. This permits us
to track multiple virtual mappings for the same physical allocation.
|
|
Use %z for sizeof() arguments
Extra debugging for conflicting RBtree entries
|
|
Fix the "warning: function declaration isn't a prototype" warnings
in the bmm_lib code, printf formats in the test code, and make test
functions static.
|
|
Vmeta really wants the physical and virtual address of the buffer.
Adjust the BMM API to give that to it.
|
|
Use the new free-by-physical address kernel API. This allows us
to free bmm buffers which have not been mapped into user memory.
This also allows us to free a bmm buffer which failed to mmap().
|
|
libbmm calls into the kernel a lot to perform various functions such as
translating between virtual and physical addresses, finding out the
buffer size, and so forth. Much of this can be done in userspace,
because we have that information at the point where the buffer is
allocated.
Rather than having to keep fetching it from the kernel, store it in our
own local bmm_buffer structure, and store this in a pair of rb trees -
one indexed by physical address and the other by virtual address. This
allows us to efficiently look up the bmm_buffer structure by either
address, and retrieve the other buffer attribute(s).
Reference: http://web.eecs.utk.edu/~plank/plank/rbtree/rbtree.html
|
|
Add an API to allow bmm buffers to be exported as dma_buf objects, so
they can be imported into DRM without needing to resort to passing
physical addresses around.
|
|
Add a method to allow the userspace library to obtain the API version
of the kernel driver. This allows us to automatically adjust to
changes in the API and fail cleanly when we detect an incompatibility.
|
|
|
|
We don't want to pass the BMM file descriptor to child programs, so
ensure that it is opened using the O_CLOEXEC flag to prevent that
happening.
|
|
Userspace should not be dealing with kernel space addresses at all.
Thankfully this function is unused, so we can merely delete it.
|
|
vmeta wants to allocate memory with specific alignments. Rather than
having vmeta request more memory of bmm, and then doing alignment on
the result, provide a proper API to do this task. This requires an
updated kernel.
|
|
Modern systems use udev to manage /dev, and so /dev/bmm should be
already created.
Nevertheless, having a library try to create a device node is insane;
the library doesn't know what context it is being called from. Neither
should it try to create device nodes as non-root users.
Get rid of this code.
|
|
For debugging, we need to include stdio. While we're here, lets clean
up the debug macro a bit too.
|
|
Rather than having physical addresses be a void * pointer, make them
integer like; they're really just numbers because we can't ever
dereference them and they certainly aren't pointer-like.
|
|
Do not use 0 to indicate that the fd is uninitialized; use -1 instead.
|
|
|
|
|
|
|