From: Hans Verkuil <hverkuil@xs4all.nl>
To: Linux Media Mailing List <linux-media@vger.kernel.org>
Cc: Pawel Osciak <pawel@osciak.com>
Subject: [PATCHv2 for v3.15] vb2: call finish() memop for prepared/queued buffers
Date: Fri, 28 Mar 2014 12:43:25 +0100 [thread overview]
Message-ID: <5335605D.5070106@xs4all.nl> (raw)
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
next reply other threads:[~2014-03-28 11:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 11:43 Hans Verkuil [this message]
2014-04-11 8:45 ` [PATCHv2 for v3.15] vb2: call finish() memop for prepared/queued buffers Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5335605D.5070106@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=pawel@osciak.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox