linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/4] vb2: V4L2_BUF_FLAG_DONE is set after DQBUF
@ 2016-06-20 12:47 Ricardo Ribalda Delgado
  2016-06-20 12:47 ` [PATCH v3 2/4] vb2: Merge vb2_internal_dqbuf and vb2_dqbuf Ricardo Ribalda Delgado
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2016-06-20 12:47 UTC (permalink / raw)
  To: Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, linux-media, linux-kernel, hans.verkuil,
	hverkuil
  Cc: Ricardo Ribalda Delgado

According to the doc, V4L2_BUF_FLAG_DONE is cleared after DQBUF:

V4L2_BUF_FLAG_DONE 0x00000004  ... After calling the VIDIOC_QBUF or
VIDIOC_DQBUF it is always cleared ...

Unfortunately, it seems that videobuf2 keeps it set after DQBUF. This
can be tested with vivid and dev_debug:

[257604.338082] video1: VIDIOC_DQBUF: 71:33:25.00260479 index=3,
type=vid-cap, flags=0x00002004, field=none, sequence=163,
memory=userptr, bytesused=460800, offset/userptr=0x344b000,
length=460800

This patch forces FLAG_DONE to 0 after calling DQBUF.

Reported-by: Dimitrios Katsaros <patcherwork@gmail.com>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/media/v4l2-core/videobuf2-v4l2.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 7f366f1b0377..6d14df3d615d 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -633,6 +633,12 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b,
 
 	ret = vb2_core_dqbuf(q, NULL, b, nonblocking);
 
+	/*
+	 *  After calling the VIDIOC_DQBUF V4L2_BUF_FLAG_DONE must be
+	 *  cleared.
+	 */
+	b->flags &= ~V4L2_BUF_FLAG_DONE;
+
 	return ret;
 }
 
-- 
2.8.1


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

* [PATCH v3 2/4] vb2: Merge vb2_internal_dqbuf and vb2_dqbuf
  2016-06-20 12:47 [PATCH v3 1/4] vb2: V4L2_BUF_FLAG_DONE is set after DQBUF Ricardo Ribalda Delgado
@ 2016-06-20 12:47 ` Ricardo Ribalda Delgado
  2016-06-20 14:59   ` Sakari Ailus
  2016-06-20 12:47 ` [PATCH v3 3/4] vb2: Merge vb2_internal_qbuf and vb2_qbuf Ricardo Ribalda Delgado
  2016-06-20 12:47 ` [PATCH v3 4/4] vb2: Fix comment Ricardo Ribalda Delgado
  2 siblings, 1 reply; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2016-06-20 12:47 UTC (permalink / raw)
  To: Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, linux-media, linux-kernel, hans.verkuil,
	hverkuil
  Cc: Ricardo Ribalda Delgado

After all the code refactoring, vb2_internal_dqbuf is only called by
vb2_dqbuf.

Since the function it is very simple, there is no need to have two
functions.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/media/v4l2-core/videobuf2-v4l2.c | 39 ++++++++++++++------------------
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 6d14df3d615d..7dff2b688a9f 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -621,27 +621,6 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 }
 EXPORT_SYMBOL_GPL(vb2_qbuf);
 
-static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b,
-		bool nonblocking)
-{
-	int ret;
-
-	if (b->type != q->type) {
-		dprintk(1, "invalid buffer type\n");
-		return -EINVAL;
-	}
-
-	ret = vb2_core_dqbuf(q, NULL, b, nonblocking);
-
-	/*
-	 *  After calling the VIDIOC_DQBUF V4L2_BUF_FLAG_DONE must be
-	 *  cleared.
-	 */
-	b->flags &= ~V4L2_BUF_FLAG_DONE;
-
-	return ret;
-}
-
 /**
  * vb2_dqbuf() - Dequeue a buffer to the userspace
  * @q:		videobuf2 queue
@@ -665,11 +644,27 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b,
  */
 int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
 {
+	int ret;
+
 	if (vb2_fileio_is_active(q)) {
 		dprintk(1, "file io in progress\n");
 		return -EBUSY;
 	}
-	return vb2_internal_dqbuf(q, b, nonblocking);
+
+	if (b->type != q->type) {
+		dprintk(1, "invalid buffer type\n");
+		return -EINVAL;
+	}
+
+	ret = vb2_core_dqbuf(q, NULL, b, nonblocking);
+
+	/*
+	 *  After calling the VIDIOC_DQBUF V4L2_BUF_FLAG_DONE must be
+	 *  cleared.
+	 */
+	b->flags &= ~V4L2_BUF_FLAG_DONE;
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(vb2_dqbuf);
 
-- 
2.8.1


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

* [PATCH v3 3/4] vb2: Merge vb2_internal_qbuf and vb2_qbuf
  2016-06-20 12:47 [PATCH v3 1/4] vb2: V4L2_BUF_FLAG_DONE is set after DQBUF Ricardo Ribalda Delgado
  2016-06-20 12:47 ` [PATCH v3 2/4] vb2: Merge vb2_internal_dqbuf and vb2_dqbuf Ricardo Ribalda Delgado
@ 2016-06-20 12:47 ` Ricardo Ribalda Delgado
  2016-06-20 12:47 ` [PATCH v3 4/4] vb2: Fix comment Ricardo Ribalda Delgado
  2 siblings, 0 replies; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2016-06-20 12:47 UTC (permalink / raw)
  To: Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, linux-media, linux-kernel, hans.verkuil,
	hverkuil
  Cc: Ricardo Ribalda Delgado

After all the code refactoring, vb2_internal_dqbuf is only called by
vb2_dqbuf.

Since the function it is very simple, there is no need to have
two functions.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/media/v4l2-core/videobuf2-v4l2.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 7dff2b688a9f..9cfbb6e4bc28 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -427,7 +427,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
 	if (V4L2_TYPE_IS_OUTPUT(b->type)) {
 		/*
 		 * For output buffers mask out the timecode flag:
-		 * this will be handled later in vb2_internal_qbuf().
+		 * this will be handled later in vb2_qbuf().
 		 * The 'field' is valid metadata for this output buffer
 		 * and so that needs to be copied here.
 		 */
@@ -586,13 +586,6 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
 }
 EXPORT_SYMBOL_GPL(vb2_create_bufs);
 
-static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
-{
-	int ret = vb2_queue_or_prepare_buf(q, b, "qbuf");
-
-	return ret ? ret : vb2_core_qbuf(q, b->index, b);
-}
-
 /**
  * vb2_qbuf() - Queue a buffer from userspace
  * @q:		videobuf2 queue
@@ -612,12 +605,15 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
  */
 int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
+	int ret;
+
 	if (vb2_fileio_is_active(q)) {
 		dprintk(1, "file io in progress\n");
 		return -EBUSY;
 	}
 
-	return vb2_internal_qbuf(q, b);
+	ret = vb2_queue_or_prepare_buf(q, b, "qbuf");
+	return ret ? ret : vb2_core_qbuf(q, b->index, b);
 }
 EXPORT_SYMBOL_GPL(vb2_qbuf);
 
-- 
2.8.1


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

* [PATCH v3 4/4] vb2: Fix comment
  2016-06-20 12:47 [PATCH v3 1/4] vb2: V4L2_BUF_FLAG_DONE is set after DQBUF Ricardo Ribalda Delgado
  2016-06-20 12:47 ` [PATCH v3 2/4] vb2: Merge vb2_internal_dqbuf and vb2_dqbuf Ricardo Ribalda Delgado
  2016-06-20 12:47 ` [PATCH v3 3/4] vb2: Merge vb2_internal_qbuf and vb2_qbuf Ricardo Ribalda Delgado
@ 2016-06-20 12:47 ` Ricardo Ribalda Delgado
  2 siblings, 0 replies; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2016-06-20 12:47 UTC (permalink / raw)
  To: Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, linux-media, linux-kernel, hans.verkuil,
	hverkuil
  Cc: Ricardo Ribalda Delgado

The comment was referencing the wrong function.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/media/v4l2-core/videobuf2-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 633fc1ab1d7a..ba6ab8b7311f 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1845,7 +1845,7 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
 	 * Make sure to call buf_finish for any queued buffers. Normally
 	 * that's done in dqbuf, but that's not going to happen when we
 	 * cancel the whole queue. Note: this code belongs here, not in
-	 * __vb2_dqbuf() since in vb2_internal_dqbuf() there is a critical
+	 * __vb2_dqbuf() since in vb2_core_dqbuf() there is a critical
 	 * call to __fill_user_buffer() after buf_finish(). That order can't
 	 * be changed, so we can't move the buf_finish() to __vb2_dqbuf().
 	 */
-- 
2.8.1


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

* Re: [PATCH v3 2/4] vb2: Merge vb2_internal_dqbuf and vb2_dqbuf
  2016-06-20 12:47 ` [PATCH v3 2/4] vb2: Merge vb2_internal_dqbuf and vb2_dqbuf Ricardo Ribalda Delgado
@ 2016-06-20 14:59   ` Sakari Ailus
  0 siblings, 0 replies; 5+ messages in thread
From: Sakari Ailus @ 2016-06-20 14:59 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, linux-media, linux-kernel, hans.verkuil,
	hverkuil

On Mon, Jun 20, 2016 at 02:47:23PM +0200, Ricardo Ribalda Delgado wrote:
> After all the code refactoring, vb2_internal_dqbuf is only called by
> vb2_dqbuf.
> 
> Since the function it is very simple, there is no need to have two
> functions.
> 
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>

Hi, Ricardo!

Patches 2--4: 

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

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

end of thread, other threads:[~2016-06-20 15:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20 12:47 [PATCH v3 1/4] vb2: V4L2_BUF_FLAG_DONE is set after DQBUF Ricardo Ribalda Delgado
2016-06-20 12:47 ` [PATCH v3 2/4] vb2: Merge vb2_internal_dqbuf and vb2_dqbuf Ricardo Ribalda Delgado
2016-06-20 14:59   ` Sakari Ailus
2016-06-20 12:47 ` [PATCH v3 3/4] vb2: Merge vb2_internal_qbuf and vb2_qbuf Ricardo Ribalda Delgado
2016-06-20 12:47 ` [PATCH v3 4/4] vb2: Fix comment Ricardo Ribalda Delgado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).