summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevika Krishnadas <kdevika@google.com>2023-12-04 21:23:15 +0000
committerDevika Krishnadas <kdevika@google.com>2023-12-05 00:21:10 +0000
commit299507996fa4f1a8c9dfa1eaee8b0c23d2802eed (patch)
tree4d5361267488f8a1fd1d837a608e87899b5878db
parente25bf4c087d75cb08f539cfe035fc14c03b28bbf (diff)
downloadgchips-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.cpp8
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);