public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 for v3.15] vb2: call finish() memop for prepared/queued buffers
@ 2014-03-28 11:43 Hans Verkuil
  2014-04-11  8:45 ` Hans Verkuil
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2014-03-28 11:43 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Pawel Osciak

This supersedes "[PATCH for v3.15] vb2: call __buf_finish_memory for
prepared/queued buffers". I realized that that patch was for an internal
git branch and didn't apply to the master branch. The fix is the same,
though.

v4l2-compliance reports unbalanced prepare/finish memops in the case
where buffers are queued, streamon is never called and then reqbufs()
is called that has to cancel any queued buffers.

When canceling a queue the finish() memop should be called for all
buffers in the state 'PREPARED' or 'QUEUED' to ensure the prepare() and
finish() memops are balanced.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/videobuf2-core.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index f9059bb..cc1bd5a 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1063,6 +1063,15 @@ void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no)
 }
 EXPORT_SYMBOL_GPL(vb2_plane_cookie);
 
+static void vb2_buffer_finish(struct vb2_buffer *vb)
+{
+	unsigned plane;
+
+	/* sync buffers */
+	for (plane = 0; plane < vb->num_planes; ++plane)
+		call_memop(vb, finish, vb->planes[plane].mem_priv);
+}
+
 /**
  * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished
  * @vb:		vb2_buffer returned from the driver
@@ -1086,7 +1095,6 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
 {
 	struct vb2_queue *q = vb->vb2_queue;
 	unsigned long flags;
-	unsigned int plane;
 
 	if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE))
 		return;
@@ -1111,8 +1119,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
 			vb->v4l2_buf.index, state);
 
 	/* sync buffers */
-	for (plane = 0; plane < vb->num_planes; ++plane)
-		call_memop(vb, finish, vb->planes[plane].mem_priv);
+	vb2_buffer_finish(vb);
 
 	/* Add the buffer to the done buffers list */
 	spin_lock_irqsave(&q->done_lock, flags);
@@ -2041,6 +2048,9 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
 		struct vb2_buffer *vb = q->bufs[i];
 
 		if (vb->state != VB2_BUF_STATE_DEQUEUED) {
+			if (vb->state == VB2_BUF_STATE_QUEUED ||
+			    vb->state == VB2_BUF_STATE_PREPARED)
+				vb2_buffer_finish(vb);
 			vb->state = VB2_BUF_STATE_PREPARED;
 			call_vb_qop(vb, buf_finish, vb);
 		}
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-11  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-28 11:43 [PATCHv2 for v3.15] vb2: call finish() memop for prepared/queued buffers Hans Verkuil
2014-04-11  8:45 ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox