Skip to contentSkip to conversation

videobuf2-core: add comments before the WARN_ON

PATCH In review Hans Verkuil 2 participants 2 messages Aug 4, 2014 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 videobuf2-core: add comments before the WARN_ON

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.

---
 drivers/media/v4l2-core/videobuf2-core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/media/v4l2-core/videobuf2-core.c +12 -0
index c359006..d3f2a22 100644
@@ -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)
Signature · 1 line
2.0.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Hans Verkuil

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.

Quoted 37 lines
---
 drivers/media/v4l2-core/videobuf2-core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/media/v4l2-core/videobuf2-core.c +12 -1
index c359006..d3f2a22 100644
@@ -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

Signature · 2 lines
Best regards,
Pawel Osciak