1 From 41079f8602ae082b78e33e7d326ff5f57b7d76e8 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 28 Jun 2019 11:30:49 +0100
4 Subject: [PATCH 696/703] Revert "media: vb2: Allow reqbufs(0) with "in use"
7 This reverts commit a2c73e18c1f657de6d654f51effa0a94863abbd8.
8 An alternative version was accepted upstream. Revert this patch to
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
13 .../media/common/videobuf2/videobuf2-core.c | 23 +++++++++++++++++++
14 1 file changed, 23 insertions(+)
16 --- a/drivers/media/common/videobuf2/videobuf2-core.c
17 +++ b/drivers/media/common/videobuf2/videobuf2-core.c
18 @@ -550,6 +550,20 @@ bool vb2_buffer_in_use(struct vb2_queue
20 EXPORT_SYMBOL(vb2_buffer_in_use);
23 + * __buffers_in_use() - return true if any buffers on the queue are in use and
24 + * the queue cannot be freed (by the means of REQBUFS(0)) call
26 +static bool __buffers_in_use(struct vb2_queue *q)
28 + unsigned int buffer;
29 + for (buffer = 0; buffer < q->num_buffers; ++buffer) {
30 + if (vb2_buffer_in_use(q, q->bufs[buffer]))
36 void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb)
38 call_void_bufop(q, fill_user_buffer, q->bufs[index], pb);
39 @@ -661,7 +675,16 @@ int vb2_core_reqbufs(struct vb2_queue *q
41 if (*count == 0 || q->num_buffers != 0 ||
42 (q->memory != VB2_MEMORY_UNKNOWN && q->memory != memory)) {
44 + * We already have buffers allocated, so first check if they
45 + * are not in use and can be freed.
47 mutex_lock(&q->mmap_lock);
48 + if (q->memory == VB2_MEMORY_MMAP && __buffers_in_use(q)) {
49 + mutex_unlock(&q->mmap_lock);
50 + dprintk(1, "memory in use, cannot free\n");
55 * Call queue_cancel to clean up any buffers in the PREPARED or