Commit fae075e4 authored by Dave Stevenson's avatar Dave Stevenson Committed by popcornmix
Browse files

Revert "media: vb2: Allow reqbufs(0) with "in use" MMAP buffers"



This reverts commit a2c73e18.
An alternative version was accepted upstream. Revert this patch to
apply that one.

Signed-off-by: default avatarDave Stevenson <dave.stevenson@raspberrypi.org>
parent d5248ee3
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -550,6 +550,20 @@ bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
}
EXPORT_SYMBOL(vb2_buffer_in_use);

/*
 * __buffers_in_use() - return true if any buffers on the queue are in use and
 * the queue cannot be freed (by the means of REQBUFS(0)) call
 */
static bool __buffers_in_use(struct vb2_queue *q)
{
	unsigned int buffer;
	for (buffer = 0; buffer < q->num_buffers; ++buffer) {
		if (vb2_buffer_in_use(q, q->bufs[buffer]))
			return true;
	}
	return false;
}

void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb)
{
	call_void_bufop(q, fill_user_buffer, q->bufs[index], pb);
@@ -661,7 +675,16 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,

	if (*count == 0 || q->num_buffers != 0 ||
	    (q->memory != VB2_MEMORY_UNKNOWN && q->memory != memory)) {
		/*
		 * We already have buffers allocated, so first check if they
		 * are not in use and can be freed.
		 */
		mutex_lock(&q->mmap_lock);
		if (q->memory == VB2_MEMORY_MMAP && __buffers_in_use(q)) {
			mutex_unlock(&q->mmap_lock);
			dprintk(1, "memory in use, cannot free\n");
			return -EBUSY;
		}

		/*
		 * Call queue_cancel to clean up any buffers in the PREPARED or