summaryrefslogtreecommitdiff
path: root/gralloc
diff options
context:
space:
mode:
authorChia-I Wu <olv@google.com>2017-05-08 12:55:28 -0700
committerChia-I Wu <olv@google.com>2017-05-08 13:35:44 -0700
commit06695a61ba0c5148972108a03c094ae85531cf1c (patch)
treef41313b5259ea7d3fa341dce704f476750749906 /gralloc
parent57b9e8ac152ba8b95dbbb4ce2cbfc0fec292532f (diff)
downloadhikey-06695a61ba0c5148972108a03c094ae85531cf1c.tar.gz
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
Diffstat (limited to 'gralloc')
-rw-r--r--gralloc/alloc_device.cpp25
-rw-r--r--gralloc/gralloc_priv.h8
2 files changed, 11 insertions, 22 deletions
diff --git a/gralloc/alloc_device.cpp b/gralloc/alloc_device.cpp
index 3c4531bf..67734050 100644
--- a/gralloc/alloc_device.cpp
+++ b/gralloc/alloc_device.cpp
@@ -128,17 +128,19 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
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 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
if (NULL != hnd)
{
hnd->share_fd = shared_fd;
- hnd->ion_hnd = ion_hnd;
*pHandle = hnd;
return 0;
}
@@ -165,13 +166,6 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
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 @@ static int alloc_device_free(alloc_device_t *dev, buffer_handle_t handle)
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 b931ac20..547027e8 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -186,7 +186,7 @@ struct private_handle_t
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 @@ struct private_handle_t
offset(0)
#if GRALLOC_ARM_DMA_BUF_MODULE
,
- ion_hnd(ION_INVALID_HANDLE)
+ ion_hnd_UNUSED(ION_INVALID_HANDLE)
#endif
{
@@ -255,7 +255,7 @@ struct private_handle_t
#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 @@ struct private_handle_t
offset(fb_offset)
#if GRALLOC_ARM_DMA_BUF_MODULE
,
- ion_hnd(ION_INVALID_HANDLE)
+ ion_hnd_UNUSED(ION_INVALID_HANDLE)
#endif
{