On 09/11/2015 01:50 PM, Sakari Ailus wrote: > The buffer cache should be synchronised in buffer preparation, not when > the buffer is queued to the device. Fix this. > > Mmap buffers do not need cache synchronisation since they are always > coherent. > While I agree with this change, I also think it is incomplete. The memop prepare() is now done before it is queued to the driver, but the corresponding memop finish() is only called when it is returned by the driver. So if the application queues buffers and (without calling STREAMON) destroys them all (REQBUFS(0)), you should get 'unbalanced' messages in the kernel log. I'm pretty sure v4l2-compliance tests this scenario, so that would be a good thing to check. Regards, Hans > Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx> > --- > drivers/media/v4l2-core/videobuf2-core.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c > index af6a23a..64fce4d 100644 > --- a/drivers/media/v4l2-core/videobuf2-core.c > +++ b/drivers/media/v4l2-core/videobuf2-core.c > @@ -1636,10 +1636,6 @@ static void __enqueue_in_driver(struct vb2_buffer *vb) > > trace_vb2_buf_queue(q, vb); > > - /* sync buffers */ > - for (plane = 0; plane < vb->num_planes; ++plane) > - call_void_memop(vb, prepare, vb->planes[plane].mem_priv); > - > call_void_vb_qop(vb, buf_queue, vb); > } > > @@ -1694,11 +1690,19 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) > ret = -EINVAL; > } > > - if (ret) > + if (ret) { > dprintk(1, "buffer preparation failed: %d\n", ret); > - vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED; > + vb->state = VB2_BUF_STATE_DEQUEUED; > + return ret; > + } > > - return ret; > + /* sync buffers */ > + for (plane = 0; plane < vb->num_planes; ++plane) > + call_void_memop(vb, prepare, vb->planes[plane].mem_priv); > + > + vb->state = VB2_BUF_STATE_PREPARED; > + > + return 0; > } > > static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b, > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html