From: Benjamin Gaignard <benjamin.gaignard@linaro.org>
To: linaro-kernel@lists.linaro.org, arnd@arndb.de,
labbott@redhat.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
daniel.vetter@ffwll.ch, laurent.pinchart@ideasonboard.com,
robdclark@gmail.com, akpm@linux-foundation.org,
hverkuil@xs4all.nl
Cc: broonie@kernel.org, Benjamin Gaignard <benjamin.gaignard@linaro.org>
Subject: [RFC simple allocator v2 0/2] Simple allocator
Date: Mon, 13 Feb 2017 15:45:04 +0100 [thread overview]
Message-ID: <1486997106-23277-1-git-send-email-benjamin.gaignard@linaro.org> (raw)
version 2:
- rebase code on 4.10-rc7
- fix bug in CMA allocator
- do more tests with wayland dmabuf protocol:
https://git.linaro.org/people/benjamin.gaignard/simple_allocator.git
The goal of this RFC is to understand if a common ioctl for specific memory
regions allocations is needed/welcome.
Obviously it will not replace allocation done in linux kernel frameworks like
v4l2, drm/kms or others, but offer an alternative when you don't want/need to
use them for buffer allocation.
To keep a compatibility with what already exist allocated buffers are exported
in userland as dmabuf file descriptor (like ION is doing).
"Unix Device Memory Allocator" project [1] wants to create a userland library
which may allow to select, depending of the devices constraint, the best
back-end for allocation. With this RFC I would to propose to have common ioctl
for a maximum of allocators to avoid to duplicated back-ends for this library.
One of the issues that lead me to propose this RFC it is that since the beginning
it is a problem to allocate contiguous memory (CMA) without using v4l2 or
drm/kms so the first allocator available in this RFC use CMA memory.
An other question is: do we have others memory regions that could be interested
by this new framework ? I have in mind that some title memory regions could use
it or replace ION heaps (system, carveout, etc...).
Maybe it only solve CMA allocation issue, in this case there is no need to create
a new framework but only a dedicated ioctl.
Maybe the first thing to do is to change the name and the location of this
module, suggestions are welcome.
I have testing this code with the following program:
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "simple-allocator.h"
#define LENGTH 1024*16
void main (void)
{
struct simple_allocate_data data;
int fd = open("/dev/cma0", O_RDWR, 0);
int ret;
void *mem;
if (fd < 0) {
printf("Can't open /dev/cma0\n");
return;
}
memset(&data, 0, sizeof(data));
data.length = LENGTH;
data.flags = O_RDWR | O_CLOEXEC;
ret = ioctl(fd, SA_IOC_ALLOC, &data);
if (ret) {
printf("Buffer allocation failed\n");
goto end;
}
mem = mmap(0, LENGTH, PROT_READ | PROT_WRITE, MAP_SHARED, data.fd, 0);
if (mem == MAP_FAILED) {
printf("mmap failed\n");
}
memset(mem, 0xFF, LENGTH);
munmap(mem, LENGTH);
printf("test simple allocator CMA OK\n");
end:
close(fd);
}
[1] https://github.com/cubanismo/allocator
Benjamin Gaignard (2):
Create Simple Allocator module
add CMA simple allocator module
Documentation/simple-allocator.txt | 81 ++++++++++
drivers/Kconfig | 2 +
drivers/Makefile | 1 +
drivers/simpleallocator/Kconfig | 17 +++
drivers/simpleallocator/Makefile | 2 +
drivers/simpleallocator/simple-allocator-cma.c | 187 ++++++++++++++++++++++++
drivers/simpleallocator/simple-allocator-priv.h | 33 +++++
drivers/simpleallocator/simple-allocator.c | 180 +++++++++++++++++++++++
include/uapi/linux/simple-allocator.h | 35 +++++
9 files changed, 538 insertions(+)
create mode 100644 Documentation/simple-allocator.txt
create mode 100644 drivers/simpleallocator/Kconfig
create mode 100644 drivers/simpleallocator/Makefile
create mode 100644 drivers/simpleallocator/simple-allocator-cma.c
create mode 100644 drivers/simpleallocator/simple-allocator-priv.h
create mode 100644 drivers/simpleallocator/simple-allocator.c
create mode 100644 include/uapi/linux/simple-allocator.h
--
1.9.1
next reply other threads:[~2017-02-13 14:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 14:45 Benjamin Gaignard [this message]
2017-02-13 14:45 ` [RFC simple allocator v2 1/2] Create Simple Allocator module Benjamin Gaignard
2017-02-14 19:30 ` Laurent Pinchart
2017-02-15 8:41 ` Benjamin Gaignard
2017-02-14 19:33 ` Daniel Vetter
2017-02-14 19:39 ` Laurent Pinchart
2017-02-14 19:44 ` Daniel Vetter
2017-02-14 19:59 ` Laurent Pinchart
2017-02-15 8:51 ` Benjamin Gaignard
2017-02-15 12:15 ` Mark Brown
2017-02-26 20:30 ` Daniel Vetter
2017-02-13 14:45 ` [RFC simple allocator v2 2/2] add CMA simple allocator module Benjamin Gaignard
2017-02-13 18:18 ` [RFC simple allocator v2 0/2] Simple allocator Mark Brown
2017-02-13 19:01 ` Laura Abbott
2017-02-14 16:45 ` Mark Brown
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=1486997106-23277-1-git-send-email-benjamin.gaignard@linaro.org \
--to=benjamin.gaignard@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hverkuil@xs4all.nl \
--cc=labbott@redhat.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=robdclark@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).