summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-01-02 15:48:30 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-01-02 16:01:22 +0000
commit73ef2c14bf7c34070e041923c0d18c75e3453105 (patch)
treed45be75579515b394fe2eb37b7a311e84263d6e2
parent598179bcb2c8742853b041c333255c83bd4539ef (diff)
downloadandroid_hardware_samsung-73ef2c14bf7c34070e041923c0d18c75e3453105.tar.gz
android_hardware_samsung-73ef2c14bf7c34070e041923c0d18c75e3453105.tar.bz2
android_hardware_samsung-73ef2c14bf7c34070e041923c0d18c75e3453105.zip
Revert "gralloc: Allow unmapping concurrent handles"
This reverts commit a3a9aaa5bbf0a94f1039e3eda368fa8a28ddecf8.
-rw-r--r--exynos4/hal/libgralloc_ump/gralloc_module.cpp63
1 files changed, 33 insertions, 30 deletions
diff --git a/exynos4/hal/libgralloc_ump/gralloc_module.cpp b/exynos4/hal/libgralloc_ump/gralloc_module.cpp
index 79c4750..3bbb831 100644
--- a/exynos4/hal/libgralloc_ump/gralloc_module.cpp
+++ b/exynos4/hal/libgralloc_ump/gralloc_module.cpp
@@ -318,39 +318,42 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand
ALOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK,
"[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState);
- pthread_mutex_lock(&s_map_lock);
- if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) {
- ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle);
- hnd->base = 0;
- ump_reference_release((ump_handle)hnd->ump_mem_handle);
- hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE;
- hnd->lockState = 0;
- hnd->writeOwner = 0;
- } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_IOCTL) {
- if(hnd->base != 0)
- gralloc_unmap(module, handle);
+ /* never unmap buffers that were created in this process */
+ if (hnd->pid != getpid()) {
+ pthread_mutex_lock(&s_map_lock);
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) {
+ ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle);
+ hnd->base = 0;
+ ump_reference_release((ump_handle)hnd->ump_mem_handle);
+ hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE;
+ hnd->lockState = 0;
+ hnd->writeOwner = 0;
+ } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_IOCTL) {
+ if(hnd->base != 0)
+ gralloc_unmap(module, handle);
- pthread_mutex_unlock(&s_map_lock);
- if (0 < gMemfd) {
- close(gMemfd);
- gMemfd = 0;
+ pthread_mutex_unlock(&s_map_lock);
+ if (0 < gMemfd) {
+ close(gMemfd);
+ gMemfd = 0;
+ }
+ return 0;
+ } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) {
+ ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle);
+ ump_reference_release((ump_handle)hnd->ump_mem_handle);
+ if (hnd->base)
+ gralloc_unmap(module, handle);
+
+ hnd->base = 0;
+ hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE;
+ hnd->lockState = 0;
+ hnd->writeOwner = 0;
+ } else {
+ ALOGE("unregistering non-UMP buffer not supported");
}
- return 0;
- } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) {
- ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle);
- ump_reference_release((ump_handle)hnd->ump_mem_handle);
- if (hnd->base)
- gralloc_unmap(module, handle);
-
- hnd->base = 0;
- hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE;
- hnd->lockState = 0;
- hnd->writeOwner = 0;
- } else {
- ALOGE("unregistering non-UMP buffer not supported");
- }
- pthread_mutex_unlock(&s_map_lock);
+ pthread_mutex_unlock(&s_map_lock);
+ }
return 0;
}