media: videobuf2-core: release all planes first in __prepare_dmabuf()
authorYunke Cao <yunkec@chromium.org>
Wed, 14 Aug 2024 02:06:41 +0000 (11:06 +0900)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 14 Aug 2024 08:05:32 +0000 (10:05 +0200)
commit95af7c00f35b9cb0873afb8f191f42e04714ed2a
treea8471cb4ebefb5d4850e2829f387b0322c4b5f3a
parent6a9c97ab6b7e85697e0b74e86062192a5ffffd99
media: videobuf2-core: release all planes first in __prepare_dmabuf()

In the existing implementation, validating planes, checking if the planes
changed, releasing previous planes and reaquiring new planes all happens in
the same for loop.

Split the for loop into 3 parts
1. In the first for loop, validate planes and check if planes changed.
2. Call __vb2_buf_dmabuf_put() to release all planes.
3. In the second for loop, reaquire new planes.

Signed-off-by: Yunke Cao <yunkec@chromium.org>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/common/videobuf2/videobuf2-core.c