summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnkit Goyal <layog@google.com>2022-03-16 11:30:48 -0700
committerAnkit Goyal <layog@google.com>2022-03-18 16:29:03 -0700
commitd1726ab7499abc5446b119908fbfee201b3fddf2 (patch)
tree3f1645624ef91cedba36673cb3ddee1c1758b659
parent5f11cc7df43ce03f56fa164455f4e451a738dcf0 (diff)
downloadgchips-d1726ab7499abc5446b119908fbfee201b3fddf2.tar.gz
Remove allocating_pid from reference count mechanism
Allocator runs in its own separate process and does not rely on reference count of the buffer. `allocating_pid` serves no purpose now. Bug: 207450311 Bug: 212803946 Test: Boots to home Change-Id: I5280d37daccc8f68c25a8ef8590483c4eac0467e
-rw-r--r--gralloc4/src/core/mali_gralloc_bufferaccess.cpp2
-rw-r--r--gralloc4/src/core/mali_gralloc_reference.cpp15
-rw-r--r--gralloc4/src/mali_gralloc_buffer.h2
-rw-r--r--libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp2
4 files changed, 5 insertions, 16 deletions
diff --git a/gralloc4/src/core/mali_gralloc_bufferaccess.cpp b/gralloc4/src/core/mali_gralloc_bufferaccess.cpp
index 6740556..0c7dd7c 100644
--- a/gralloc4/src/core/mali_gralloc_bufferaccess.cpp
+++ b/gralloc4/src/core/mali_gralloc_bufferaccess.cpp
@@ -154,7 +154,7 @@ int validate_lock_input_parameters(const buffer_handle_t buffer, const int l,
* will have a valid buffer virtual address if it is the allocating
* process or it retained / registered a cloned buffer handle
*/
- if ((hnd->allocating_pid == lock_pid) || (hnd->remote_pid == lock_pid))
+ if (hnd->remote_pid == lock_pid)
{
is_registered_process = true;
}
diff --git a/gralloc4/src/core/mali_gralloc_reference.cpp b/gralloc4/src/core/mali_gralloc_reference.cpp
index e9636ea..074e189 100644
--- a/gralloc4/src/core/mali_gralloc_reference.cpp
+++ b/gralloc4/src/core/mali_gralloc_reference.cpp
@@ -39,7 +39,7 @@ int mali_gralloc_reference_retain(buffer_handle_t handle)
pthread_mutex_lock(&s_map_lock);
int retval = 0;
- if (hnd->allocating_pid == getpid() || hnd->remote_pid == getpid())
+ if (hnd->remote_pid == getpid())
{
hnd->ref_count++;
}
@@ -107,16 +107,7 @@ int mali_gralloc_reference_release(buffer_handle_t handle)
return -EINVAL;
}
- if (hnd->allocating_pid == getpid())
- {
- hnd->ref_count--;
-
- if (hnd->ref_count == 0)
- {
- mali_gralloc_buffer_free(handle);
- }
- }
- else if (hnd->remote_pid == getpid()) // never unmap buffers that were not imported into this process
+ if (hnd->remote_pid == getpid()) // never unmap buffers that were not imported into this process
{
hnd->ref_count--;
@@ -153,7 +144,7 @@ int mali_gralloc_reference_validate(buffer_handle_t handle)
const auto *hnd = (private_handle_t *)handle;
pthread_mutex_lock(&s_map_lock);
- if (hnd->allocating_pid == getpid() || hnd->remote_pid == getpid()) {
+ if (hnd->remote_pid == getpid()) {
pthread_mutex_unlock(&s_map_lock);
return 0;
} else {
diff --git a/gralloc4/src/mali_gralloc_buffer.h b/gralloc4/src/mali_gralloc_buffer.h
index a163d1a..d186f02 100644
--- a/gralloc4/src/mali_gralloc_buffer.h
+++ b/gralloc4/src/mali_gralloc_buffer.h
@@ -215,7 +215,6 @@ struct private_handle_t
uint64_t backing_store_id DEFAULT_INITIALIZER(0x0);
int cpu_read DEFAULT_INITIALIZER(0); /**< Buffer is locked for CPU read when non-zero. */
int cpu_write DEFAULT_INITIALIZER(0); /**< Buffer is locked for CPU write when non-zero. */
- int allocating_pid DEFAULT_INITIALIZER(0);
int remote_pid DEFAULT_INITIALIZER(-1);
int ref_count DEFAULT_INITIALIZER(0);
// locally mapped shared attribute area
@@ -265,7 +264,6 @@ struct private_handle_t
stride = _stride;
alloc_format = _alloc_format;
layer_count = _layer_count;
- allocating_pid = getpid();
ref_count = 1;
version = sizeof(native_handle);
set_numfds(fd_count);
diff --git a/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp b/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
index 49ce035..030d509 100644
--- a/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
+++ b/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
@@ -47,7 +47,7 @@ using android::hardware::graphics::mapper::V4_0::Error;
int mali_gralloc_reference_validate(buffer_handle_t handle) {
auto hnd = static_cast<const private_handle_t *>(handle);
- if (hnd->allocating_pid != getpid() && hnd->remote_pid != getpid()) {
+ if (hnd->remote_pid != getpid()) {
return -EINVAL;
}