v4l2: don't warn before we release buffer

Message ID 1406174011-13600-1-git-send-email-scott.jiang.linux@gmail.com (mailing list archive)
State Rejected, archived
Headers

Commit Message

Scott Jiang July 24, 2014, 3:53 a.m. UTC
  In fact we only need to give a warning if the driver still use the
buffer after we release all queued buffers.

Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
---
 drivers/media/v4l2-core/videobuf2-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Hans Verkuil July 23, 2014, 6 a.m. UTC | #1
On 07/24/2014 05:53 AM, Scott Jiang wrote:
> In fact we only need to give a warning if the driver still use the
> buffer after we release all queued buffers.
> 
> Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>

Nacked-by: Hans Verkuil <hans.verkuil@cisco.com>

You're removing the warning telling you that your driver has a bug instead
of fixing the driver bug itself. In stop_streaming the driver must hand over
any buffers it owns to vb2 (vb2_buffer_done(..., STATE_ERROR)). If it doesn't
you'll get this warning and vb2 will forcefully reclaim them, quite possibly
leaving the driver with a corrupt buffer list.

The same should occur in start_streaming if an error occurs. In that case
start_streaming must return the buffers to STATE_DEQUEUED.

So fix your driver instead :-)

Regards,

	Hans

> ---
>  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 7c4489c..fa5dd73 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -2112,7 +2112,7 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
>  	if (q->start_streaming_called)
>  		call_void_qop(q, stop_streaming, q);
>  
> -	if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
> +	if (atomic_read(&q->owned_by_drv_count)) {
>  		for (i = 0; i < q->num_buffers; ++i)
>  			if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE)
>  				vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 7c4489c..fa5dd73 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2112,7 +2112,7 @@  static void __vb2_queue_cancel(struct vb2_queue *q)
 	if (q->start_streaming_called)
 		call_void_qop(q, stop_streaming, q);
 
-	if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
+	if (atomic_read(&q->owned_by_drv_count)) {
 		for (i = 0; i < q->num_buffers; ++i)
 			if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE)
 				vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR);