From patchwork Thu Feb 7 11:49:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10800949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAA951823 for ; Thu, 7 Feb 2019 11:50:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4E8A2C7DA for ; Thu, 7 Feb 2019 11:50:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 971582C7CB; Thu, 7 Feb 2019 11:50:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B3C12C736 for ; Thu, 7 Feb 2019 11:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbfBGLt7 (ORCPT ); Thu, 7 Feb 2019 06:49:59 -0500 Received: from lb2-smtp-cloud8.xs4all.net ([194.109.24.25]:48537 "EHLO lb2-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbfBGLtw (ORCPT ); Thu, 7 Feb 2019 06:49:52 -0500 Received: from test-nl.fritz.box ([80.101.105.217]) by smtp-cloud8.xs4all.net with ESMTPA id riBggvrMUNR5yriBig1JmK; Thu, 07 Feb 2019 12:49:50 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Michael Ira Krufky , Brad Love , Sakari Ailus , Hans Verkuil , Yi Qingliang Subject: [RFC PATCH 3/8] vb2: fix epoll() by calling poll_wait first Date: Thu, 7 Feb 2019 12:49:43 +0100 Message-Id: <20190207114948.37750-4-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190207114948.37750-1-hverkuil-cisco@xs4all.nl> References: <20190207114948.37750-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfEiePhVJVg4gVkpx4rn8cwFm9GXweq0Bm9PHG20cjJAVw0PWeTWNnvjElmt11l3ppcqMSDvl6rAYAVgBF3rIFLu5WmNWi3wi1tfVmlMtYnc5wl/zUAhb aJTstGC/JGSgagSDc4RyavjDNumcOQalchNWE6RgJu+S3x/UD/7+RgobF9r72kfJeJg93LbmjTZN2ylxSEdIch6wLxkuw9oFxDRu+giVfUPXpGrQg6qN4H/T vpl5c3Fb8RF68sLWy+TwN7cQIKwBRo9XBSMOS6Uv708wyZetvHuWik4Vv7JCWDE2xLlhWxOVVl2MMlmoAqGt6jywxL2Yc0C3j9dAuY8gto87oZMQwAJ4Iu4n e4XFeUIsX/80iDiRp8dCF4qoISP5Og== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil 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: Hans Verkuil Reported-by: Yi Qingliang --- drivers/media/common/videobuf2/videobuf2-core.c | 4 ++-- drivers/media/common/videobuf2/videobuf2-v4l2.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index e07b6bdb6982..b40e9f48a943 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -2289,6 +2289,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. */ @@ -2340,8 +2342,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); } /* diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 3aeaea3af42a..101479768f91 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -867,16 +867,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);