From: Hans Verkuil <hans.verkuil@xxxxxxxxx> In queue_cancel we need to call the finish memop for any pending buffers in the PREPARED or QUEUED state. Signed-off-by: Hans Verkuil <hans.verkuil@xxxxxxxxx> --- drivers/media/v4l2-core/videobuf2-core.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index f156475..93b7969 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1937,6 +1937,7 @@ EXPORT_SYMBOL_GPL(vb2_dqbuf); */ static void __vb2_queue_cancel(struct vb2_queue *q) { + unsigned int plane; unsigned int i; /* @@ -1949,10 +1950,23 @@ static void __vb2_queue_cancel(struct vb2_queue *q) q->start_streaming_called = 0; q->queued_count = 0; + 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) + for (plane = 0; plane < vb->num_planes; ++plane) + call_memop(vb, finish, vb->planes[plane].mem_priv); + } 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) - vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR); + for (i = 0; i < q->num_buffers; ++i) { + struct vb2_buffer *vb = q->bufs[i]; + + if (vb->state == VB2_BUF_STATE_ACTIVE) + vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); + else if (vb->state == VB2_BUF_STATE_PREPARED) + for (plane = 0; plane < vb->num_planes; ++plane) + call_memop(vb, finish, vb->planes[plane].mem_priv); + } /* Must be zero now */ WARN_ON(atomic_read(&q->owned_by_drv_count)); } -- 1.9.0 -- 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