diff options
author | Ankit Goyal <layog@google.com> | 2023-03-01 16:55:42 -0800 |
---|---|---|
committer | Ankit Goyal <layog@google.com> | 2023-03-01 17:01:01 -0800 |
commit | 36922f185ec93280afe71c9e323001a75ba10a0a (patch) | |
tree | 47942b13fcad531c8a8a45f29dd05e1f112d30ad | |
parent | e21346e84c6e0377f49416d64f5d94688c6b3619 (diff) | |
download | gchips-36922f185ec93280afe71c9e323001a75ba10a0a.tar.gz |
Revert "gralloc4: Do not map buffer on import"
This reverts commit 43ab868f19edb307808e3c40b7df2bca5c0ecb4e.
Bug: 269705937
Test: No display artifacts after camera shot
Change-Id: Id37bd48b14e90859b5e5f9f3e0bfe706873961aa
-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 b84cbb4..8f12975 100644 --- a/gralloc4/src/core/mali_gralloc_reference.cpp +++ b/gralloc4/src/core/mali_gralloc_reference.cpp @@ -26,7 +26,10 @@ #include <mutex> #include "allocator/mali_gralloc_ion.h" +#include "allocator/mali_gralloc_shared_memory.h" #include "mali_gralloc_buffer.h" +#include "mali_gralloc_bufferallocation.h" +#include "mali_gralloc_usages.h" class BufferManager { private: @@ -45,6 +48,17 @@ private: std::mutex lock; std::map<const private_handle_t *, std::unique_ptr<MappedData>> buffer_map GUARDED_BY(lock); + static bool should_map_dmabuf(buffer_handle_t handle) { + private_handle_t *hnd = (private_handle_t *)handle; + + // 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); + return hnd->get_usage() & cpu_access_usage; + } + static off_t get_buffer_size(unsigned int fd) { off_t current = lseek(fd, 0, SEEK_CUR); off_t size = lseek(fd, 0, SEEK_END); @@ -199,7 +213,8 @@ public: auto &data = *(it->second.get()); data.ref_count++; - return 0; + if (!should_map_dmabuf(handle)) return 0; + return map_locked(handle); } int map(buffer_handle_t handle) EXCLUDES(lock) { |