From: Stark Li Date: Tue, 22 Dec 2015 06:16:02 +0000 (+0800) Subject: PD#116501: fix dma share fd will be destroyed when android crashed X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d77d3617973eb1e653b982d4f1ad72f5868d5d03;p=GitHub%2FLineageOS%2FG12%2Fandroid_hardware_amlogic_kernel-modules_mali-driver.git PD#116501: fix dma share fd will be destroyed when android crashed Change-Id: I58b7c4e7e09e06821ff8e2cfb7a4b558455bb65a --- 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; };