gralloc: do not use private_handle_t::ion_hnd
This makes private_handle_t native_handle_clone friendly when
GRALLOC_ARM_UMP_MODULE is not defined.
Bug: 37550237
Test: boots
Change-Id: I6c489eb4f8f6791ab91ddffe55d9ce3dc96509a0
diff --git a/gralloc/alloc_device.cpp b/gralloc/alloc_device.cpp
index 3c4531b..6773405 100644
--- a/gralloc/alloc_device.cpp
+++ b/gralloc/alloc_device.cpp
@@ -128,17 +128,19 @@
return -1;
}
+ // we do not need ion_hnd once we have shared_fd
+ if (0 != ion_free(m->ion_client, ion_hnd))
+ {
+ AWAR("ion_free( %d ) failed", m->ion_client);
+ }
+ ion_hnd = ION_INVALID_HANDLE;
+
cpu_ptr = (unsigned char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, shared_fd, 0);
if (MAP_FAILED == cpu_ptr)
{
AERR("ion_map( %d ) failed", m->ion_client);
- if (0 != ion_free(m->ion_client, ion_hnd))
- {
- AERR("ion_free( %d ) failed", m->ion_client);
- }
-
close(shared_fd);
return -1;
}
@@ -148,7 +150,6 @@
if (NULL != hnd)
{
hnd->share_fd = shared_fd;
- hnd->ion_hnd = ion_hnd;
*pHandle = hnd;
return 0;
}
@@ -165,13 +166,6 @@
AERR("munmap failed for base:%p size: %lu", cpu_ptr, (unsigned long)size);
}
- ret = ion_free(m->ion_client, ion_hnd);
-
- if (0 != ret)
- {
- AERR("ion_free( %d ) failed", m->ion_client);
- }
-
return -1;
}
#endif
@@ -560,11 +554,6 @@
close(hnd->share_fd);
- if (0 != ion_free(m->ion_client, hnd->ion_hnd))
- {
- AERR("Failed to ion_free( ion_client: %d ion_hnd: %p )", m->ion_client, (void *)(uintptr_t)hnd->ion_hnd);
- }
-
memset((void *)hnd, 0, sizeof(*hnd));
#else
AERR("Can't free dma_buf memory for handle:0x%x. Not supported.", (unsigned int)hnd);
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index b931ac2..547027e 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -186,7 +186,7 @@
int offset;
#if GRALLOC_ARM_DMA_BUF_MODULE
- ion_user_handle_t ion_hnd;
+ ion_user_handle_t ion_hnd_UNUSED;
#endif
#if GRALLOC_ARM_DMA_BUF_MODULE
@@ -223,7 +223,7 @@
offset(0)
#if GRALLOC_ARM_DMA_BUF_MODULE
,
- ion_hnd(ION_INVALID_HANDLE)
+ ion_hnd_UNUSED(ION_INVALID_HANDLE)
#endif
{
@@ -255,7 +255,7 @@
#endif
shallow_fbdev_fd(0),
offset(0),
- ion_hnd(ION_INVALID_HANDLE)
+ ion_hnd_UNUSED(ION_INVALID_HANDLE)
{
version = sizeof(native_handle);
@@ -290,7 +290,7 @@
offset(fb_offset)
#if GRALLOC_ARM_DMA_BUF_MODULE
,
- ion_hnd(ION_INVALID_HANDLE)
+ ion_hnd_UNUSED(ION_INVALID_HANDLE)
#endif
{