diff options
author | Chia-I Wu <olv@google.com> | 2017-07-15 00:06:34 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-07-15 00:06:34 +0000 |
commit | f8b1a70461af9fe63dfec1abf4b6f98e3831b321 (patch) | |
tree | dc9b80d9d8c2cc132f809e667bff57aae825520a | |
parent | f0446da0adf136b2c579b8db03045259eaabe86d (diff) | |
parent | a3db107cbcc0af586bef2ffb04172250c97f6201 (diff) | |
download | hikey-f8b1a70461af9fe63dfec1abf4b6f98e3831b321.tar.gz |
gralloc960: do not use private_handle_t::{ion_hnd,pid}
am: a3db107cbc
Change-Id: Ic33da9ebe1b3839cd1ed62812fdbdf896882f92f
-rw-r--r-- | gralloc960/alloc_ion.cpp | 13 | ||||
-rw-r--r-- | gralloc960/gralloc_module.cpp | 15 | ||||
-rw-r--r-- | gralloc960/gralloc_priv.h | 8 |
3 files changed, 13 insertions, 23 deletions
diff --git a/gralloc960/alloc_ion.cpp b/gralloc960/alloc_ion.cpp index 954c5382..2af9d945 100644 --- a/gralloc960/alloc_ion.cpp +++ b/gralloc960/alloc_ion.cpp @@ -248,6 +248,13 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand 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 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand 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 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand 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 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand 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 @@ int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd) 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 @@ void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m) 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 232ecc12..28d361d4 100644 --- a/gralloc960/gralloc_module.cpp +++ b/gralloc960/gralloc_module.cpp @@ -66,19 +66,10 @@ static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle // 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 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand { 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 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand 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 51089ddc..7c4b8359 100644 --- a/gralloc960/gralloc_priv.h +++ b/gralloc960/gralloc_priv.h @@ -162,7 +162,7 @@ struct private_handle_t 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 @@ struct private_handle_t }; int lockState; int writeOwner; - int pid; + int pid_UNUSED; // locally mapped shared attribute area union { @@ -221,7 +221,7 @@ struct private_handle_t 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 @@ struct private_handle_t 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), |