Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 914c6868 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

media: vb2: fix epoll() by calling poll_wait first



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 vb2_core_poll() and vb2_poll(). Fix this,
otherwise epoll() would timeout when it shouldn't.

Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: default avatarYi Qingliang <niqingliang2003@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent f4dd471b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2291,6 +2291,8 @@ __poll_t vb2_core_poll(struct vb2_queue *q, struct file *file,
	if (q->is_output && !(req_events & (EPOLLOUT | EPOLLWRNORM)))
		return 0;

	poll_wait(file, &q->done_wq, wait);

	/*
	 * Start file I/O emulator only if streaming API has not been used yet.
	 */
@@ -2342,8 +2344,6 @@ __poll_t vb2_core_poll(struct vb2_queue *q, struct file *file,
		 */
		if (q->last_buffer_dequeued)
			return EPOLLIN | EPOLLRDNORM;

		poll_wait(file, &q->done_wq, wait);
	}

	/*
+1 −3
Original line number Diff line number Diff line
@@ -868,16 +868,14 @@ EXPORT_SYMBOL_GPL(vb2_queue_release);
__poll_t vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
{
	struct video_device *vfd = video_devdata(file);
	__poll_t req_events = poll_requested_events(wait);
	__poll_t res = 0;

	if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
		struct v4l2_fh *fh = file->private_data;

		poll_wait(file, &fh->wait, wait);
		if (v4l2_event_pending(fh))
			res = EPOLLPRI;
		else if (req_events & EPOLLPRI)
			poll_wait(file, &fh->wait, wait);
	}

	return res | vb2_core_poll(q, file, wait);