diff options
author | Ankit Goyal <layog@google.com> | 2021-06-28 10:24:23 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-06-28 10:24:23 +0000 |
commit | 7e2b9dadd47992b6ea64ea3fa9130a278e354816 (patch) | |
tree | b10c172e0e44bdd3d85b504d5543f2a88a89c1fd | |
parent | 7cef734f6f27b6e1de53c2e7567719c3692b71f1 (diff) | |
parent | 02b1b2c3733df1ab1b89add96b9e99135ce6371e (diff) | |
download | gchips-7e2b9dadd47992b6ea64ea3fa9130a278e354816.tar.gz |
Map CPU accessible buffers during import am: 02b1b2c373
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/gchips/+/15094175
Change-Id: I82e8f382b717a3f40ca377ae9070145c46f59009
-rw-r--r-- | gralloc4/src/core/mali_gralloc_reference.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gralloc4/src/core/mali_gralloc_reference.cpp b/gralloc4/src/core/mali_gralloc_reference.cpp index 35d2358..57b8f73 100644 --- a/gralloc4/src/core/mali_gralloc_reference.cpp +++ b/gralloc4/src/core/mali_gralloc_reference.cpp @@ -23,6 +23,8 @@ #include "allocator/mali_gralloc_shared_memory.h" #include "mali_gralloc_bufferallocation.h" #include "mali_gralloc_debug.h" +#include "mali_gralloc_reference.h" +#include "mali_gralloc_usages.h" static pthread_mutex_t s_map_lock = PTHREAD_MUTEX_INITIALIZER; @@ -36,6 +38,7 @@ int mali_gralloc_reference_retain(buffer_handle_t handle) private_handle_t *hnd = (private_handle_t *)handle; pthread_mutex_lock(&s_map_lock); + int retval = 0; if (hnd->allocating_pid == getpid() || hnd->remote_pid == getpid()) { @@ -54,7 +57,19 @@ int mali_gralloc_reference_retain(buffer_handle_t handle) pthread_mutex_unlock(&s_map_lock); - return 0; + // TODO(b/187145254): CPU_READ/WRITE buffer is not being properly locked from + // MFC. This is a WA for the time being. + constexpr auto cpu_access_usage = ( + GRALLOC_USAGE_SW_WRITE_OFTEN | + GRALLOC_USAGE_SW_READ_OFTEN | + GRALLOC_USAGE_SW_WRITE_RARELY | + GRALLOC_USAGE_SW_READ_RARELY + ); + + if (hnd->get_usage() & cpu_access_usage) + retval = mali_gralloc_reference_map(handle); + + return retval; } int mali_gralloc_reference_map(buffer_handle_t handle) { |