From: Laurent Pinchart Date: Sun, 20 Apr 2014 23:55:41 +0000 (-0300) Subject: upstream: [media] v4l: vb2: Avoid double WARN_ON when stopping streaming X-Git-Tag: submit/tizen/20141121.110247~729 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f8d19273906ee5ff9fa3672744a387e86984178;p=platform%2Fkernel%2Flinux-3.10.git upstream: [media] v4l: vb2: Avoid double WARN_ON when stopping streaming The __vb2_queue_cancel function marks the queue as not streaming and then WARNs when buffers are still owned by the driver. It proceeds to complete all active buffers by calling vb2_buffer_done with the new buffer state set to VB2_BUF_STATE_ERROR in that case. This triggers another WARN_ON due to as new state not being VB2_BUF_STATE_QUEUED while the queue is not streaming. Check buffer ownership and complete all active buffers before marking the queue as not streaming to avoid the double WARN_on. Signed-off-by: Laurent Pinchart Reviewed-by: Hans Verkuil Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 00f3bf3..4116194 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2090,9 +2090,6 @@ static void __vb2_queue_cancel(struct vb2_queue *q) */ if (q->start_streaming_called) call_void_qop(q, stop_streaming, q); - q->streaming = 0; - q->start_streaming_called = 0; - q->queued_count = 0; if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { for (i = 0; i < q->num_buffers; ++i) @@ -2102,6 +2099,10 @@ static void __vb2_queue_cancel(struct vb2_queue *q) WARN_ON(atomic_read(&q->owned_by_drv_count)); } + q->streaming = 0; + q->start_streaming_called = 0; + q->queued_count = 0; + /* * Remove all buffers from videobuf's list... */