From f992c521c382ee23e94148ad523bd5e7782f29a6 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 8 Apr 2021 14:53:52 -0400 Subject: [PATCH] v4l2codecs: allocator: Keep dmabuf mapped DMABuf allocator already implements DMABuf Sync, meaning that doing mmap/munmap (unless the mode have changed) is not required. In fact, on systems with IOMMU it makes the kernel redo the mmu table which is visible in the CPU usage. This change reduces CPU usage when decoding bbb_sunflower_2160p_60fps_normal.mp4 on RK3399 SoC from over 30% to around 15%. Part-of: --- sys/v4l2codecs/gstv4l2codecallocator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/v4l2codecs/gstv4l2codecallocator.c b/sys/v4l2codecs/gstv4l2codecallocator.c index d18e8bb70f..e2886989cc 100644 --- a/sys/v4l2codecs/gstv4l2codecallocator.c +++ b/sys/v4l2codecs/gstv4l2codecallocator.c @@ -90,7 +90,8 @@ gst_v4l2_codec_buffer_new (GstAllocator * allocator, GstV4l2Decoder * decoder, buf->index = index; buf->num_mems = num_mems; for (i = 0; i < buf->num_mems; i++) { - GstMemory *mem = gst_dmabuf_allocator_alloc (allocator, fds[i], sizes[i]); + GstMemory *mem = gst_fd_allocator_alloc (allocator, fds[i], sizes[i], + GST_FD_MEMORY_FLAG_KEEP_MAPPED); gst_memory_resize (mem, offsets[i], sizes[i] - offsets[i]); GST_MINI_OBJECT (mem)->dispose = gst_v4l2_codec_allocator_release;