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/4, 2/4 and 3/4 refactors __prepare_dmabuf() 4/4 adds a flag to avoid duplicated attaching v5: - Add Acked-by from Tomasz. Thanks!! - Address comments from Hans: - Add comment and modify commit message for 3/4. - Fix typo in 4/4. v4: - Update patch 4/4, only set dbuf_duplicated when alloc_devs are equal. v3: - Add patch 1/4 to move clearing fields into __vb2_plane_dmabuf_put(). - Resolve review comments on v2. Detailed changelog in patch. v2: - 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 (4): media: videobuf2-core: clear memory related fields in __vb2_plane_dmabuf_put() 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 | 159 +++++++++++------- include/media/videobuf2-core.h | 3 + 2 files changed, 98 insertions(+), 64 deletions(-) -- 2.46.0.184.g6999bdac58-goog