All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for v3.17] videobuf2-core: add comments before the WARN_ON
@ 2014-08-04  5:36 Hans Verkuil
  2014-08-04  5:57 ` Pawel Osciak
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2014-08-04  5:36 UTC (permalink / raw)
  To: Linux Media Mailing List, Pawel Osciak, Marek Szyprowski

Recently WARN_ON() calls have been added to warn if the driver is not
properly returning buffers to vb2 in start_streaming (if it fails) or
stop_streaming(). Add comments before those WARN_ON calls that refer
to the videobuf2-core.h header that explains what drivers are supposed
to do in these situations. That should help point developers in the
right direction if they see these warnings.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/videobuf2-core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index c359006..d3f2a22 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1762,6 +1762,12 @@ static int vb2_start_streaming(struct vb2_queue *q)
 	q->start_streaming_called = 0;
 
 	dprintk(1, "driver refused to start streaming\n");
+	/*
+	 * If you see this warning, then the driver isn't cleaning up properly
+	 * after a failed start_streaming(). See the start_streaming()
+	 * documentation in videobuf2-core.h for more information how buffers
+	 * should be returned to vb2 in start_streaming().
+	 */
 	if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
 		unsigned i;
 
@@ -2123,6 +2129,12 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
 	if (q->start_streaming_called)
 		call_void_qop(q, stop_streaming, q);
 
+	/*
+	 * If you see this warning, then the driver isn't cleaning up properly
+	 * in stop_streaming(). See the stop_streaming() documentation in
+	 * videobuf2-core.h for more information how buffers should be returned
+	 * to vb2 in stop_streaming().
+	 */
 	if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
 		for (i = 0; i < q->num_buffers; ++i)
 			if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE)
-- 
2.0.1


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

* Re: [PATCH for v3.17] videobuf2-core: add comments before the WARN_ON
  2014-08-04  5:36 [PATCH for v3.17] videobuf2-core: add comments before the WARN_ON Hans Verkuil
@ 2014-08-04  5:57 ` Pawel Osciak
  0 siblings, 0 replies; 2+ messages in thread
From: Pawel Osciak @ 2014-08-04  5:57 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List, Marek Szyprowski

On Mon, Aug 4, 2014 at 2:36 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> Recently WARN_ON() calls have been added to warn if the driver is not
> properly returning buffers to vb2 in start_streaming (if it fails) or
> stop_streaming(). Add comments before those WARN_ON calls that refer
> to the videobuf2-core.h header that explains what drivers are supposed
> to do in these situations. That should help point developers in the
> right direction if they see these warnings.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

Acked-by: Pawel Osciak <pawel@osciak.com>

> ---
>  drivers/media/v4l2-core/videobuf2-core.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index c359006..d3f2a22 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -1762,6 +1762,12 @@ static int vb2_start_streaming(struct vb2_queue *q)
>         q->start_streaming_called = 0;
>
>         dprintk(1, "driver refused to start streaming\n");
> +       /*
> +        * If you see this warning, then the driver isn't cleaning up properly
> +        * after a failed start_streaming(). See the start_streaming()
> +        * documentation in videobuf2-core.h for more information how buffers
> +        * should be returned to vb2 in start_streaming().
> +        */
>         if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
>                 unsigned i;
>
> @@ -2123,6 +2129,12 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
>         if (q->start_streaming_called)
>                 call_void_qop(q, stop_streaming, q);
>
> +       /*
> +        * If you see this warning, then the driver isn't cleaning up properly
> +        * in stop_streaming(). See the stop_streaming() documentation in
> +        * videobuf2-core.h for more information how buffers should be returned
> +        * to vb2 in stop_streaming().
> +        */
>         if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
>                 for (i = 0; i < q->num_buffers; ++i)
>                         if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE)
> --
> 2.0.1
>



-- 
Best regards,
Pawel Osciak

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

end of thread, other threads:[~2014-08-04  5:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-04  5:36 [PATCH for v3.17] videobuf2-core: add comments before the WARN_ON Hans Verkuil
2014-08-04  5:57 ` Pawel Osciak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.