gralloc960: do not use private_handle_t::{ion_hnd,pid} am: a3db107cbc
am: f8b1a70461
Change-Id: I2c936346b8406cb4d72199e8f9cebc7ddf1aba80
diff --git a/gralloc960/alloc_ion.cpp b/gralloc960/alloc_ion.cpp
index 954c538..2af9d94 100644
--- a/gralloc960/alloc_ion.cpp
+++ b/gralloc960/alloc_ion.cpp
@@ -248,6 +248,13 @@
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 = -1;
+
if (!(usage & GRALLOC_USAGE_PROTECTED))
{
cpu_ptr = (unsigned char*)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, shared_fd, 0 );
@@ -255,7 +262,6 @@
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;
}
@@ -280,7 +286,6 @@
if ( NULL != hnd )
{
hnd->share_fd = shared_fd;
- hnd->ion_hnd = ion_hnd;
hnd->min_pgsz = min_pgsz;
*pHandle = hnd;
return 0;
@@ -298,8 +303,6 @@
if ( 0 != ret ) AERR( "munmap failed for base:%p size: %zd", cpu_ptr, size );
}
- ret = ion_free( m->ion_client, ion_hnd );
- if ( 0 != ret ) AERR( "ion_free( %d ) failed", m->ion_client );
return -1;
}
@@ -322,6 +325,7 @@
void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m)
{
+ (void) m;
if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
{
return;
@@ -334,7 +338,6 @@
if ( 0 != munmap( (void*)hnd->base, hnd->size ) ) AERR( "Failed to munmap handle %p", hnd );
}
close( hnd->share_fd );
- if ( 0 != ion_free( m->ion_client, hnd->ion_hnd ) ) AERR( "Failed to ion_free( ion_client: %d ion_hnd: %d )", m->ion_client, hnd->ion_hnd );
memset( (void*)hnd, 0, sizeof( *hnd ) );
}
}
diff --git a/gralloc960/gralloc_module.cpp b/gralloc960/gralloc_module.cpp
index 232ecc1..28d361d 100644
--- a/gralloc960/gralloc_module.cpp
+++ b/gralloc960/gralloc_module.cpp
@@ -66,19 +66,10 @@
// if this handle was created in this process, then we keep it as is.
private_handle_t* hnd = (private_handle_t*)handle;
- if (hnd->pid == getpid())
- {
- // If the handle is created and registered in the same process this is valid,
- // but it could also be that application is registering twice which is illegal.
- AWAR("Registering handle %p coming from the same process: %d.", hnd, hnd->pid);
- }
-
int retval = -EINVAL;
pthread_mutex_lock(&s_map_lock);
- hnd->pid = getpid();
-
if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
{
AERR( "Can't register buffer %p as it is a framebuffer", handle );
@@ -114,7 +105,7 @@
{
AERR( "Can't unregister buffer %p as it is a framebuffer", handle );
}
- else if (hnd->pid == getpid()) // never unmap buffers that were not created in this process
+ else
{
pthread_mutex_lock(&s_map_lock);
@@ -142,10 +133,6 @@
pthread_mutex_unlock(&s_map_lock);
}
- else
- {
- AERR( "Trying to unregister buffer %p from process %d that was not created in current process: %d", hnd, hnd->pid, getpid());
- }
return 0;
}
diff --git a/gralloc960/gralloc_priv.h b/gralloc960/gralloc_priv.h
index 51089dd..7c4b835 100644
--- a/gralloc960/gralloc_priv.h
+++ b/gralloc960/gralloc_priv.h
@@ -162,7 +162,7 @@
int share_fd;
int share_attr_fd;
- ion_user_handle_t ion_hnd;
+ ion_user_handle_t ion_hnd_UNUSED;
// ints
int magic;
@@ -183,7 +183,7 @@
};
int lockState;
int writeOwner;
- int pid;
+ int pid_UNUSED;
// locally mapped shared attribute area
union {
@@ -221,7 +221,7 @@
private_handle_t(int _flags, int _usage, int _size, void *_base, int lock_state, int fb_file, off_t fb_offset):
share_fd(-1),
share_attr_fd(-1),
- ion_hnd(-1),
+ ion_hnd_UNUSED(-1),
magic(sMagic),
flags(_flags),
usage(_usage),
@@ -232,7 +232,7 @@
base(_base),
lockState(lock_state),
writeOwner(0),
- pid(getpid()),
+ pid_UNUSED(-1),
attr_base(MAP_FAILED),
yuv_info(MALI_YUV_NO_INFO),
shallow_fbdev_fd(fb_file),