From d77d3617973eb1e653b982d4f1ad72f5868d5d03 Mon Sep 17 00:00:00 2001 From: Stark Li Date: Tue, 22 Dec 2015 14:16:02 +0800 Subject: [PATCH] PD#116501: fix dma share fd will be destroyed when android crashed Change-Id: I58b7c4e7e09e06821ff8e2cfb7a4b558455bb65a --- t83x/android/gralloc/src/alloc_device.cpp | 3 ++- t83x/android/gralloc/src/alloc_device_allocator_specific.h | 2 +- t83x/android/gralloc/src/alloc_ion.cpp | 4 +++- t83x/android/gralloc/src/alloc_ump.cpp | 2 +- t83x/android/gralloc/src/gralloc_priv.h | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/t83x/android/gralloc/src/alloc_device.cpp b/t83x/android/gralloc/src/alloc_device.cpp index 4543069..1706cdf 100644 --- a/t83x/android/gralloc/src/alloc_device.cpp +++ b/t83x/android/gralloc/src/alloc_device.cpp @@ -126,7 +126,8 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, size_t size, in * Perform allocator specific actions. If these fail we fall back to a regular buffer * which will be memcpy'ed to the main screen when fb_post is called. */ - if (alloc_backend_alloc_framebuffer(private_t, hnd) == -1) + uint32_t index = (framebufferVaddr - (uintptr_t)m->framebuffer->base) / framebufferSize; + if (alloc_backend_alloc_framebuffer(private_t, hnd, index) == -1) { delete hnd; int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D; diff --git a/t83x/android/gralloc/src/alloc_device_allocator_specific.h b/t83x/android/gralloc/src/alloc_device_allocator_specific.h index d6bb850..ac6a43d 100755 --- a/t83x/android/gralloc/src/alloc_device_allocator_specific.h +++ b/t83x/android/gralloc/src/alloc_device_allocator_specific.h @@ -16,7 +16,7 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle); -int alloc_backend_alloc_framebuffer(struct private_module_t* m, struct private_handle_t* hnd); +int alloc_backend_alloc_framebuffer(struct private_module_t* m, struct private_handle_t* hnd, uint32_t idx); void alloc_backend_alloc_free(struct private_handle_t const* hnd, struct private_module_t* m); diff --git a/t83x/android/gralloc/src/alloc_ion.cpp b/t83x/android/gralloc/src/alloc_ion.cpp index 619584b..e1969ec 100644 --- a/t83x/android/gralloc/src/alloc_ion.cpp +++ b/t83x/android/gralloc/src/alloc_ion.cpp @@ -133,7 +133,7 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand return -1; } -int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd) +int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd, uint32_t idx) { framebuffer_mapper_t* m_fb = NULL; @@ -153,6 +153,8 @@ int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd) struct fb_dmabuf_export fb_dma_buf; int res; + + fb_dma_buf.buffer_idx = idx; res = ioctl( m_fb->framebuffer->fd, FBIOGET_DMABUF, &fb_dma_buf ); if (res == 0) { diff --git a/t83x/android/gralloc/src/alloc_ump.cpp b/t83x/android/gralloc/src/alloc_ump.cpp index eb014df..8edf0f5 100755 --- a/t83x/android/gralloc/src/alloc_ump.cpp +++ b/t83x/android/gralloc/src/alloc_ump.cpp @@ -171,7 +171,7 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand } } -int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd) +int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd, uint32_t idx) { hnd->ump_id = m->framebuffer->ump_id; /* create a backing ump memory handle if the framebuffer is exposed as a secure ID */ diff --git a/t83x/android/gralloc/src/gralloc_priv.h b/t83x/android/gralloc/src/gralloc_priv.h index bb33823..874164b 100644 --- a/t83x/android/gralloc/src/gralloc_priv.h +++ b/t83x/android/gralloc/src/gralloc_priv.h @@ -71,6 +71,7 @@ typedef struct ion_handle *ion_user_handle_t; #if GRALLOC_ARM_DMA_BUF_MODULE struct fb_dmabuf_export { + __u32 buffer_idx; __u32 fd; __u32 flags; }; -- 2.20.1