Skip to contentSkip to conversation

vb2: core: Finish buffers at the end of the stream

PATCH In review Sakari Ailus 2 participants 3 messages Feb 2, 2018 – Feb 5, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vb2: core: Finish buffers at the end of the stream

If buffers were prepared or queued and the buffers were released without starting the queue, the finish mem op (corresponding to the prepare mem op) was never called to the buffers.

Before commit a136f59c0a1f there was no need to do this as in such a case the prepare mem op had not been called yet. Address the problem by explicitly calling finish mem op when the queue is stopped if the buffer is in either prepared or queued state.

Fixes a136f59c0a1f ("[media] vb2: Move buffer cache synchronisation to prepare from queue")
Cc [email protected] # for v4.13 and up

---
Hi Devin,

Could you check whether this will resolve the problem you've found?

Thanks.

 drivers/media/common/videobuf2/videobuf2-core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/common/videobuf2/videobuf2-core.c +9 -0
index f7109f827f6e..52a7c1d0a79a 100644
@@ -1696,6 +1696,15 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
 	for (i = 0; i < q->num_buffers; ++i) {
 		struct vb2_buffer *vb = q->bufs[i];
 
+		if (vb->state == VB2_BUF_STATE_PREPARED ||
+		    vb->state == VB2_BUF_STATE_QUEUED) {
+			unsigned int plane;
+
+			for (plane = 0; plane < vb->num_planes; ++plane)
+				call_void_memop(vb, finish,
+						vb->planes[plane].mem_priv);
+		}
+
 		if (vb->state != VB2_BUF_STATE_DEQUEUED) {
 			vb->state = VB2_BUF_STATE_PREPARED;
 			call_void_vb_qop(vb, buf_finish, vb);
Signature · 1 line
2.11.0
#1 lore raw

Hello Sakari,

Thanks for proposing this patch. I'll give it a try this weekend.

Regards,

Devin

Quoted 45 lines · Sakari Ailus

If buffers were prepared or queued and the buffers were released without starting the queue, the finish mem op (corresponding to the prepare mem op) was never called to the buffers.

Before commit a136f59c0a1f there was no need to do this as in such a case the prepare mem op had not been called yet. Address the problem by explicitly calling finish mem op when the queue is stopped if the buffer is in either prepared or queued state.

Fixes a136f59c0a1f ("[media] vb2: Move buffer cache synchronisation to prepare from queue")
Cc [email protected] # for v4.13 and up

---
Hi Devin,

Could you check whether this will resolve the problem you've found?

Thanks.

 drivers/media/common/videobuf2/videobuf2-core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/common/videobuf2/videobuf2-core.c +9 -1
index f7109f827f6e..52a7c1d0a79a 100644
@@ -1696,6 +1696,15 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
        for (i = 0; i < q->num_buffers; ++i) {
                struct vb2_buffer *vb = q->bufs[i];
 
+               if (vb->state == VB2_BUF_STATE_PREPARED ||
+                   vb->state == VB2_BUF_STATE_QUEUED) {
+                       unsigned int plane;
+
+                       for (plane = 0; plane < vb->num_planes; ++plane)
+                               call_void_memop(vb, finish,
+                                               vb->planes[plane].mem_priv);
+               }
+
                if (vb->state != VB2_BUF_STATE_DEQUEUED) {
                        vb->state = VB2_BUF_STATE_PREPARED;
                        call_void_vb_qop(vb, buf_finish, vb);
--

2.11.0

Signature · 2 lines
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
#2 lore raw

Hi Sakari,

I tried this patch, and I no longer see the messages in dmesg output when closing the V4L2 device node.

Thanks,

Devin

Quoted 61 lines · Devin Heitmueller

Hello Sakari,

Thanks for proposing this patch. I'll give it a try this weekend.

Regards,

Devin

Quoted 43 lines · Sakari Ailus

If buffers were prepared or queued and the buffers were released without starting the queue, the finish mem op (corresponding to the prepare mem op) was never called to the buffers.

Before commit a136f59c0a1f there was no need to do this as in such a case the prepare mem op had not been called yet. Address the problem by explicitly calling finish mem op when the queue is stopped if the buffer is in either prepared or queued state.

Fixes a136f59c0a1f ("[media] vb2: Move buffer cache synchronisation to prepare from queue")
Cc [email protected] # for v4.13 and up

---
Hi Devin,

Could you check whether this will resolve the problem you've found?

Thanks.

 drivers/media/common/videobuf2/videobuf2-core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/common/videobuf2/videobuf2-core.c +9 -1
index f7109f827f6e..52a7c1d0a79a 100644
@@ -1696,6 +1696,15 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
        for (i = 0; i < q->num_buffers; ++i) {
                struct vb2_buffer *vb = q->bufs[i];
 
+               if (vb->state == VB2_BUF_STATE_PREPARED ||
+                   vb->state == VB2_BUF_STATE_QUEUED) {
+                       unsigned int plane;
+
+                       for (plane = 0; plane < vb->num_planes; ++plane)
+                               call_void_memop(vb, finish,
+                                               vb->planes[plane].mem_priv);
+               }
+
                if (vb->state != VB2_BUF_STATE_DEQUEUED) {
                        vb->state = VB2_BUF_STATE_PREPARED;
                        call_void_vb_qop(vb, buf_finish, vb);
--
Quoted 2 lines

2.11.0

--
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com

Signature · 2 lines
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com