public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] vb2: Only requeue buffers immediately once streaming is started
@ 2015-07-03 10:20 Sakari Ailus
  2015-07-03 10:49 ` Hans Verkuil
  0 siblings, 1 reply; 2+ messages in thread
From: Sakari Ailus @ 2015-07-03 10:20 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil, mchehab

Buffers can be returned back to videobuf2 in driver's streamon handler. In
this case vb2_buffer_done() with buffer state VB2_BUF_STATE_QUEUED will
cause the driver's buf_queue vb2 operation to be called, queueing the same
buffer again only to be returned to videobuf2 using vb2_buffer_done() and so
on.

Instead of using q->start_streamin_called to judge whether to return the
buffer to the driver immediately, use q->streaming which is set only after
the driver's start_streaming() vb2 operation is called.

Fixes: ce0eff016f72 ("[media] vb2: allow requeuing buffers while streaming")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: stable@vger.kernel.org # for v4.1
---
 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 1a096a6..6957078 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1208,7 +1208,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
 	spin_unlock_irqrestore(&q->done_lock, flags);
 
 	if (state == VB2_BUF_STATE_QUEUED) {
-		if (q->start_streaming_called)
+		if (q->streaming)
 			__enqueue_in_driver(vb);
 		return;
 	}
-- 
2.1.4


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

* Re: [PATCH 1/1] vb2: Only requeue buffers immediately once streaming is started
  2015-07-03 10:20 [PATCH 1/1] vb2: Only requeue buffers immediately once streaming is started Sakari Ailus
@ 2015-07-03 10:49 ` Hans Verkuil
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2015-07-03 10:49 UTC (permalink / raw)
  To: Sakari Ailus, linux-media; +Cc: mchehab

On 07/03/2015 12:20 PM, Sakari Ailus wrote:
> Buffers can be returned back to videobuf2 in driver's streamon handler. In
> this case vb2_buffer_done() with buffer state VB2_BUF_STATE_QUEUED will
> cause the driver's buf_queue vb2 operation to be called, queueing the same
> buffer again only to be returned to videobuf2 using vb2_buffer_done() and so
> on.
> 
> Instead of using q->start_streamin_called to judge whether to return the
> buffer to the driver immediately, use q->streaming which is set only after
> the driver's start_streaming() vb2 operation is called.

I don't think this patch will work. If q->min_buffers_needed is > 0, then
q->streaming and q->start_streaming_called will both be true in vb2_buffer_done(),
still causing the same issue.

The problem is that there is no clear distinction between STATE_QUEUED as used
in start_streaming and STATE_QUEUED as used to requeue a buffer while streaming.

The best option here I think is to introduce a STATE_REQUEUE for the second use
case.

Regards,

	Hans

> 
> Fixes: ce0eff016f72 ("[media] vb2: allow requeuing buffers while streaming")
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: stable@vger.kernel.org # for v4.1
> ---
>  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 1a096a6..6957078 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -1208,7 +1208,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
>  	spin_unlock_irqrestore(&q->done_lock, flags);
>  
>  	if (state == VB2_BUF_STATE_QUEUED) {
> -		if (q->start_streaming_called)
> +		if (q->streaming)
>  			__enqueue_in_driver(vb);
>  		return;
>  	}
> 


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

end of thread, other threads:[~2015-07-03 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-03 10:20 [PATCH 1/1] vb2: Only requeue buffers immediately once streaming is started Sakari Ailus
2015-07-03 10:49 ` Hans Verkuil

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