]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.16.4/media-vb2-core-finish-buffers-at-the-end-of-the-stream.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.16.4 / media-vb2-core-finish-buffers-at-the-end-of-the-stream.patch
1 From 03703ed1debf777ea845aa9b50ba2e80a5e7dd3c Mon Sep 17 00:00:00 2001
2 From: Sakari Ailus <sakari.ailus@linux.intel.com>
3 Date: Fri, 2 Feb 2018 05:08:59 -0500
4 Subject: media: vb2: core: Finish buffers at the end of the stream
5
6 From: Sakari Ailus <sakari.ailus@linux.intel.com>
7
8 commit 03703ed1debf777ea845aa9b50ba2e80a5e7dd3c upstream.
9
10 If buffers were prepared or queued and the buffers were released without
11 starting the queue, the finish mem op (corresponding to the prepare mem
12 op) was never called to the buffers.
13
14 Before commit a136f59c0a1f there was no need to do this as in such a case
15 the prepare mem op had not been called yet. Address the problem by
16 explicitly calling finish mem op when the queue is stopped if the buffer
17 is in either prepared or queued state.
18
19 Fixes: a136f59c0a1f ("[media] vb2: Move buffer cache synchronisation to prepare from queue")
20
21 Cc: stable@vger.kernel.org # for v4.13 and up
22 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
23 Tested-by: Devin Heitmueller <dheitmueller@kernellabs.com>
24 Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
25 Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28 ---
29 drivers/media/common/videobuf2/videobuf2-core.c | 9 +++++++++
30 1 file changed, 9 insertions(+)
31
32 --- a/drivers/media/common/videobuf2/videobuf2-core.c
33 +++ b/drivers/media/common/videobuf2/videobuf2-core.c
34 @@ -1696,6 +1696,15 @@ static void __vb2_queue_cancel(struct vb
35 for (i = 0; i < q->num_buffers; ++i) {
36 struct vb2_buffer *vb = q->bufs[i];
37
38 + if (vb->state == VB2_BUF_STATE_PREPARED ||
39 + vb->state == VB2_BUF_STATE_QUEUED) {
40 + unsigned int plane;
41 +
42 + for (plane = 0; plane < vb->num_planes; ++plane)
43 + call_void_memop(vb, finish,
44 + vb->planes[plane].mem_priv);
45 + }
46 +
47 if (vb->state != VB2_BUF_STATE_DEQUEUED) {
48 vb->state = VB2_BUF_STATE_PREPARED;
49 call_void_vb_qop(vb, buf_finish, vb);