diff options
author | Devika Krishnadas <kdevika@google.com> | 2023-12-04 21:23:15 +0000 |
---|---|---|
committer | Devika Krishnadas <kdevika@google.com> | 2023-12-05 00:21:10 +0000 |
commit | 299507996fa4f1a8c9dfa1eaee8b0c23d2802eed (patch) | |
tree | 4d5361267488f8a1fd1d837a608e87899b5878db | |
parent | e25bf4c087d75cb08f539cfe035fc14c03b28bbf (diff) | |
download | gchips-299507996fa4f1a8c9dfa1eaee8b0c23d2802eed.tar.gz |
Use memfd on placeholder buffers
Bug: 314828124
Test: aion_test, video smoke test, camera smoke test
Change-Id: I7d9873a3bc19381d4aec345c04de2c7e9a6e2655
Signed-off-by: Devika Krishnadas <kdevika@google.com>
-rw-r--r-- | gralloc4/src/allocator/mali_gralloc_ion.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gralloc4/src/allocator/mali_gralloc_ion.cpp b/gralloc4/src/allocator/mali_gralloc_ion.cpp index 3a955d9..c66c54a 100644 --- a/gralloc4/src/allocator/mali_gralloc_ion.cpp +++ b/gralloc4/src/allocator/mali_gralloc_ion.cpp @@ -30,6 +30,7 @@ #include <utils/Trace.h> #include <linux/dma-buf.h> +#include <linux/memfd.h> #include <vector> #include <sys/ioctl.h> @@ -222,7 +223,12 @@ int alloc_from_dmabuf_heap(uint64_t usage, size_t size, const std::string& buffe std::stringstream tag; tag << "heap: " << heap_name << ", bytes: " << size; ATRACE_NAME(tag.str().c_str()); - int shared_fd = get_allocator().Alloc(heap_name, size, 0); + int shared_fd = -1; + + // memfd requires matching sepolicy allowing r/w access to tmpfs. + if (use_placeholder) shared_fd = memfd_create(heap_name.c_str(), 0); + else shared_fd = get_allocator().Alloc(heap_name, size, 0); + if (shared_fd < 0) { ALOGE("Allocation failed for heap %s error: %d\n", heap_name.c_str(), shared_fd); |