Hi, This patch set avoids attaching and mapping a dma_buf multiple times when several planes in one vb2 buffer share the same dma_buf. 1/3 and 2/3 refactors __prepare_dmabuf() 3/3 adds a flag to avoid duplicated attaching Changelog since v1: - Add patch 1/3 to refactor __prepare_dmabuf() - Add patch 2/3 to resolve Tomasz's comment on __vb2_buf_dmabuf_put()'s iteration order - Fix mem_priv in patch 3/3 - Rename duplicated_dbuf to dbuf_duplicated Yunke Cao (3): media: videobuf2-core: release all planes first in __prepare_dmabuf() media: videobuf2-core: reverse the iteration order in __vb2_buf_dmabuf_put media: videobuf2-core: attach once if multiple planes share the same dbuf .../media/common/videobuf2/videobuf2-core.c | 97 +++++++++++-------- include/media/videobuf2-core.h | 3 + 2 files changed, 62 insertions(+), 38 deletions(-) -- 2.44.0.478.gd926399ef9-goog