]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: videobuf: fix epoll() by calling poll_wait first
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Thu, 7 Feb 2019 11:49:47 +0000 (06:49 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 18 Feb 2019 19:48:13 +0000 (14:48 -0500)
The epoll function expects that whenever the poll file op is
called, the poll_wait function is also called. That didn't
always happen in videobuf_poll_stream(). Fix this, otherwise
epoll() would timeout when it shouldn't.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/v4l2-core/videobuf-core.c

index d1bcfa91aaf8010d1bcbea7dc69a6b533b41bea2..ab849052b6dc1d7d21a40ee2f13faaaf70a76d84 100644 (file)
@@ -1119,13 +1119,14 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
 EXPORT_SYMBOL_GPL(videobuf_read_stream);
 
 __poll_t videobuf_poll_stream(struct file *file,
-                                 struct videobuf_queue *q,
-                                 poll_table *wait)
+                             struct videobuf_queue *q,
+                             poll_table *wait)
 {
        __poll_t req_events = poll_requested_events(wait);
        struct videobuf_buffer *buf = NULL;
        __poll_t rc = 0;
 
+       poll_wait(file, &buf->done, wait);
        videobuf_queue_lock(q);
        if (q->streaming) {
                if (!list_empty(&q->stream))
@@ -1149,7 +1150,6 @@ __poll_t videobuf_poll_stream(struct file *file,
                rc = EPOLLERR;
 
        if (0 == rc) {
-               poll_wait(file, &buf->done, wait);
                if (buf->state == VIDEOBUF_DONE ||
                    buf->state == VIDEOBUF_ERROR) {
                        switch (q->type) {