<div style="font-family: arial, helvetica, sans-serif"><font size="2">ping?<br><br><div class="gmail_quote">On Tue, Jun 19, 2012 at 11:12 PM, Dima Zavin <span dir="ltr"><<a href="mailto:dmitriyz@google.com" target="_blank">dmitriyz@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Tomasz,<br>
<br>
I've encountered an issue with this patch when userspace does several<br>
stream_on/stream_off cycles. When the user tries to qbuf a buffer<br>
after doing stream_off, we trigger the "dmabuf already pinned" warning<br>
since we didn't unmap the buffer as dqbuf was never called.<br>
<br>
The below patch adds calls to unmap in queue_cancel, but my feeling is that we<br>
probably should be calling detach too (i.e. put_dmabuf).<br>
<br>
Thoughts?<br>
<br>
--Dima<br>
<br>
Subject: [PATCH] v4l: vb2: unmap dmabufs on STREAM_OFF event<br>
<br>
Currently, if the user issues a STREAM_OFF request and then<br>
tries to re-enqueue buffers, it will trigger a warning in<br>
the vb2 allocators as the buffer would still be mapped<br>
from before STREAM_OFF was called. The current expectation<br>
is that buffers will be unmapped in dqbuf, but that will never<br>
be called on the mapped buffers after a STREAM_OFF event.<br>
<br>
Cc: Sumit Semwal <<a href="mailto:sumit.semwal@ti.com">sumit.semwal@ti.com</a>><br>
Cc: Tomasz Stanislawski <<a href="mailto:t.stanislaws@samsung.com">t.stanislaws@samsung.com</a>><br>
Signed-off-by: Dima Zavin <<a href="mailto:dima@android.com">dima@android.com</a>><br>
---<br>
 drivers/media/video/videobuf2-core.c |   22 ++++++++++++++++++++--<br>
 1 files changed, 20 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c<br>
index b431dc6..e2a8f12 100644<br>
--- a/drivers/media/video/videobuf2-core.c<br>
+++ b/drivers/media/video/videobuf2-core.c<br>
@@ -1592,8 +1592,26 @@ static void __vb2_queue_cancel(struct vb2_queue *q)<br>
        /*<br>
         * Reinitialize all buffers for next use.<br>
         */<br>
-       for (i = 0; i < q->num_buffers; ++i)<br>
-               q->bufs[i]->state = VB2_BUF_STATE_DEQUEUED;<br>
+       for (i = 0; i < q->num_buffers; ++i) {<br>
+               struct vb2_buffer *vb = q->bufs[i];<br>
+               int plane;<br>
+<br>
+               vb->state = VB2_BUF_STATE_DEQUEUED;<br>
+<br>
+               if (q->memory != V4L2_MEMORY_DMABUF)<br>
+                       continue;<br>
<div class="im">+<br>
+               for (plane = 0; plane < vb->num_planes; ++plane) {<br>
</div>+                       struct vb2_plane *p = &vb->planes[plane];<br>
<div class="im">+<br>
+                       if (!p->mem_priv)<br>
</div>+                               continue;<br>
<div class="im">+                       if (p->dbuf_mapped) {<br>
+                               call_memop(q, unmap_dmabuf, p->mem_priv);<br>
</div>+                               p->dbuf_mapped = 0;<br>
+                       }<br>
+               }<br>
+       }<br>
 }<br>
<br>
 /**<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.3<br>
<br>
</font></span></blockquote></div><br></font></div>