|
|
@@ -668,6 +668,11 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
|
|
|
return -EBUSY;
|
|
|
}
|
|
|
|
|
|
+ if (q->waiting_in_dqbuf && *count) {
|
|
|
+ dprintk(1, "another dup()ped fd is waiting for a buffer\n");
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
+
|
|
|
if (*count == 0 || q->num_buffers != 0 ||
|
|
|
(q->memory != VB2_MEMORY_UNKNOWN && q->memory != memory)) {
|
|
|
/*
|
|
|
@@ -797,6 +802,10 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
|
|
|
}
|
|
|
|
|
|
if (!q->num_buffers) {
|
|
|
+ if (q->waiting_in_dqbuf && *count) {
|
|
|
+ dprintk(1, "another dup()ped fd is waiting for a buffer\n");
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
|
|
|
q->memory = memory;
|
|
|
q->waiting_for_buffers = !q->is_output;
|
|
|
@@ -1466,6 +1475,11 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
|
|
|
for (;;) {
|
|
|
int ret;
|
|
|
|
|
|
+ if (q->waiting_in_dqbuf) {
|
|
|
+ dprintk(1, "another dup()ped fd is waiting for a buffer\n");
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
+
|
|
|
if (!q->streaming) {
|
|
|
dprintk(1, "streaming off, will not wait for buffers\n");
|
|
|
return -EINVAL;
|
|
|
@@ -1493,6 +1507,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
|
|
|
return -EAGAIN;
|
|
|
}
|
|
|
|
|
|
+ q->waiting_in_dqbuf = 1;
|
|
|
/*
|
|
|
* We are streaming and blocking, wait for another buffer to
|
|
|
* become ready or for streamoff. Driver's lock is released to
|
|
|
@@ -1513,6 +1528,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
|
|
|
* the locks or return an error if one occurred.
|
|
|
*/
|
|
|
call_void_qop(q, wait_finish, q);
|
|
|
+ q->waiting_in_dqbuf = 0;
|
|
|
if (ret) {
|
|
|
dprintk(1, "sleep was interrupted\n");
|
|
|
return ret;
|
|
|
@@ -2361,6 +2377,12 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
|
|
|
if (!data)
|
|
|
return -EINVAL;
|
|
|
|
|
|
+ if (q->waiting_in_dqbuf) {
|
|
|
+ dprintk(3, "another dup()ped fd is %s\n",
|
|
|
+ read ? "reading" : "writing");
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* Initialize emulator on first call.
|
|
|
*/
|