v1->v2
Sync to Aug 30 common.git
v0->v1:
1, Change gen_pool_create(12, -1) to gen_pool_create(PAGE_SHIFT, -1), suggested by Haojian
2. move ion_shrink out of mutex, suggested by Nishanth
3. check error flag of ERR_PTR(-ENOMEM)
4. add msleep to allow schedule out.
Base on common.git, android-3.4 branch
Patch 2:
Add support page wised cache flush for carveout_heap
There is only one nents for carveout heap, as well as dirty bit.
As a result, cache flush only takes effect for total carve heap.
Patch 3:
Add oom killer.
Once heap is used off,
SIGKILL is send to all tasks refered the buffer with descending oom_socre_adj
Zhangfei Gao (3):
gpu: ion: update carveout_heap_ops
gpu: ion: carveout_heap page wised cache flush
gpu: ion: oom killer
drivers/gpu/ion/ion.c | 118 +++++++++++++++++++++++++++++++++-
drivers/gpu/ion/ion_carveout_heap.c | 25 ++++++--
2 files changed, 133 insertions(+), 10 deletions(-)
So I've been experimenting with support for Dave Airlie's new RandR 1.4 provider
object interface, so that Optimus-based laptops can use our driver to drive the
discrete GPU and display on the integrated GPU. The good news is that I've got
a proof of concept working.
During a review of the current code, we came up with a few concerns:
1. The output source is responsible for allocating the shared memory
Right now, the X server calls CreatePixmap on the output source screen and then
expects the output sink screen to be able to display from whatever memory the
source allocates. Right now, the source has no mechanism for asking the sink
what its requirements are for the surface. I'm using our own internal pitch
alignment requirements and that seems to be good enough for the Intel device to
scan out, but that could be pure luck.
Does it make sense to add a mechanism for drivers to negotiate this with each
other, or is it sufficient to just define a lowest common denominator format and
if your hardware can't deal with that format, you just don't get to share
buffers?
One of my coworkers brought to my attention the fact that Tegra requires a
specific pitch alignment, and cannot accommodate larger pitches. If other SoC
designs have similar restrictions, we might need to add a handshake mechanism.
2. There's no fallback mechanism if sharing can't be negotiated
If RandR fails to share a pixmap with the output sink screen, the whole modeset
fails. This means you'll end up not seeing anything on the screen and you'll
probably think your computer locked up. Should there be some sort of software
copy fallback to ensure that something at least shows up on the display?
3. How should the memory be allocated?
In the prototype I threw together, I'm allocating the shared memory using
shm_open and then exporting that as a dma-buf file descriptor using an ioctl I
added to the kernel, and then importing that memory back into our driver through
dma_buf_attach & dma_buf_map_attachment. Does it make sense for user-space
programs to be able to export shmfs files like that? Should that interface go
in DRM / GEM / PRIME instead? Something else? I'm pretty unfamiliar with this
kernel code so any suggestions would be appreciated.
-- Aaron
P.S. for those unfamiliar with PRIME:
Dave Airlie added new support to the X Resize and Rotate extension version 1.4
to support offloading display and rendering to different drivers. PRIME is the
DRM implementation in the kernel, layered on top of DMA-BUF, that implements the
actual sharing of buffers between drivers.
http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt?id=ra…http://airlied.livejournal.com/75555.html - update on hotplug server
http://airlied.livejournal.com/76078.html - randr 1.5 demo videos
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Base on common.git, android-3.4 branch
Patch 2:
Add support page wised cache flush for carveout_heap
There is only one nents for carveout heap, as well as dirty bit.
As a result, cache flush only takes effect for total carve heap.
Patch 3:
Add oom killer.
Once heap is used off,
SIGKILL is send to all tasks refered the buffer with descending oom_socre_adj
Zhangfei Gao (3):
gpu: ion: update carveout_heap_ops
gpu: ion: carveout_heap page wised cache flush
gpu: ion: oom killer
drivers/gpu/ion/ion.c | 112 ++++++++++++++++++++++++++++++++++-
drivers/gpu/ion/ion_carveout_heap.c | 23 ++++++--
2 files changed, 127 insertions(+), 8 deletions(-)
v0->v1:
1, Change gen_pool_create(12, -1) to gen_pool_create(PAGE_SHIFT, -1), suggested by Haojian
2. move ion_shrink out of mutex, suggested by Nishanth
3. check error flag of ERR_PTR(-ENOMEM)
4. add msleep to allow schedule out.
Base on common.git, android-3.4 branch
Patch 2:
Add support page wised cache flush for carveout_heap
There is only one nents for carveout heap, as well as dirty bit.
As a result, cache flush only takes effect for total carve heap.
Patch 3:
Add oom killer.
Once heap is used off,
SIGKILL is send to all tasks refered the buffer with descending oom_socre_adj
Zhangfei Gao (3):
gpu: ion: update carveout_heap_ops
gpu: ion: carveout_heap page wised cache flush
gpu: ion: oom killer
drivers/gpu/ion/ion.c | 118 +++++++++++++++++++++++++++++++++-
drivers/gpu/ion/ion_carveout_heap.c | 25 ++++++--
2 files changed, 133 insertions(+), 10 deletions(-)
Hi Linus,
I would like to ask for pulling another set of fixes for ARM dma-mapping
subsystem. Commit e9da6e9905e6 replaced custom consistent buffer
remapping code with generic vmalloc areas. It however introduced some
regressions caused by limited support for allocations in atomic context.
This series contains fixes for those regressions. For some subplatforms
the default, pre-allocated pool for atomic allocations turned out to be
too small, so a function for setting its size has been added. Another
set of patches adds support for atomic allocations to IOMMU-aware
DMA-mapping implementation. The last part of this pull request contains
two fixes for Contiguous Memory Allocator, which relax too strict
requirements.
The following changes since commit fea7a08acb13524b47711625eebea40a0ede69a0:
Linux 3.6-rc3 (2012-08-22 13:29:06 -0700)
are available in the git repository at:
fixes-for-3.6
for you to fetch changes up to 479ed93a4b98eef03fd8260f7ddc00019221c450:
ARM: dma-mapping: IOMMU allocates pages from atomic_pool with GFP_ATOMIC (2012-08-28 21:01:07 +0200)
Thanks!
Best regards
Marek Szyprowski
Samsung Poland R&D Center
----------------------------------------------------------------
Patch summary:
Hiroshi Doyu (4):
ARM: dma-mapping: atomic_pool with struct page **pages
ARM: dma-mapping: Refactor out to introduce __in_atomic_pool
ARM: dma-mapping: Introduce __atomic_get_pages() for __iommu_get_pages()
ARM: dma-mapping: IOMMU allocates pages from atomic_pool with GFP_ATOMIC
Marek Szyprowski (5):
mm: cma: fix alignment requirements for contiguous regions
ARM: relax conditions required for enabling Contiguous Memory Allocator
ARM: DMA-Mapping: add function for setting coherent pool size from platform code
ARM: DMA-Mapping: print warning when atomic coherent allocation fails
ARM: Kirkwood: increase atomic coherent pool size
arch/arm/Kconfig | 2 +-
arch/arm/include/asm/dma-mapping.h | 7 ++
arch/arm/mach-kirkwood/common.c | 7 ++
arch/arm/mm/dma-mapping.c | 114 ++++++++++++++++++++++++++++++++---
drivers/base/dma-contiguous.c | 2 +-
5 files changed, 120 insertions(+), 12 deletions(-)
Hi,
I am trying to export an ion_buffer allocate from kernel space to
multiple user-space clients. Eg: Allow multiple process to mmap
framebuffer allocated using ion by fb driver.
The following is the pseudo-code for that. Is this fine? there a
cleaner way to do it?
Or is it expected to share buffers across process only by user-space
sharing fds using sockets/binder and not directly in kernel.
fb driver init/probe: (init process context)
-------------------------------------------------
/* Create an ion client and allocate framebuffer */
init_client = ion_client_create(idev,...);
init_hdl = ion_alloc(init_client,...);
/* Create a global dma_buf instance for the buffer */
fd = ion_share_dma_buf(init_client, init_hdl);
// - Inc refcount of ion_buffer
// - Create a dma_buf and anon-file for the ion buffer
// - Get a free fd and install to anon file
g_dma_buf = dma_buf_get(fd);
// - Get the dma_buf pointer and inc refcount of anon_file
dma_buf_put(g_dma_buf);
// - Dec extra refcount of anon_file which happened in prev command
put_unused_fd(fd);
// - Free up the fd as fd is not exported to user-space here.
fb driver exit: (init process context)
------------------------------------------
/* Free the dma_buf reference */
dma_buf_put(g_dma_buf);
// - Dec refcount of anon_file. Free the dma_buf and dec refcount of
ion_buffer if anon_file refcount = 0
/* Free the framebuffer and destroy the ion client created for init process */
ion_free(init_client, init_hdl);
ion_client_destroy(init_client);
fb device open: (user process context)
-----------------------------------------------
/* Create an ion client for the user process */
p_client = ion_client_create(idev,...);
fb device ioctl to import ion handle for the fb: (user process context)
-----------------------------------------------------------------------------------
/* Import a ion_handle from the global dma_buf */
fd = dma_buf_fd(g_dmabuf, O_CLOEXEC);
// - Get ref to anon file
// - Get a free fd and install to anon file
p_hdl = ion_import_dma_buf(p_client, fd);
// - Inc refcount of ion_buffer
// - create a ion_handle for the buffer for this process/client
dma_buf_put(g_dmabuf);
// - Free the anon file reference taken in first step
put_unused_fd(fd);
// - Free up the fd as fd is not exported to user-space here.
fb device release: (user process context)
---------------------------------------------------
/* Destroy the client created */
ion_client_destroy(p_client);
- Nishanth Peethambaran