From patchwork Wed Oct 2 13:45:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 2974851 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EA5819F245 for ; Wed, 2 Oct 2013 13:44:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 632DF20413 for ; Wed, 2 Oct 2013 13:44:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34275203DD for ; Wed, 2 Oct 2013 13:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754447Ab3JBNou (ORCPT ); Wed, 2 Oct 2013 09:44:50 -0400 Received: from mga09.intel.com ([134.134.136.24]:27430 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754416Ab3JBNos (ORCPT ); Wed, 2 Oct 2013 09:44:48 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 02 Oct 2013 06:41:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,1019,1371106800"; d="scan'208";a="412969459" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga002.jf.intel.com with ESMTP; 02 Oct 2013 06:44:46 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 460A72038C; Wed, 2 Oct 2013 16:44:45 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id 63AE820208; Wed, 2 Oct 2013 16:45:35 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, teemux.tuominen@intel.com Subject: [RFC v2 2/4] v4l: vb2: Only poll for events if the user is interested in them Date: Wed, 2 Oct 2013 16:45:14 +0300 Message-Id: <1380721516-488-3-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1380721516-488-1-git-send-email-sakari.ailus@linux.intel.com> References: <1380721516-488-1-git-send-email-sakari.ailus@linux.intel.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Also poll_wait() before checking the events since otherwise it's possible to go to sleep and not getting woken up if the event arrives between the two operations. Signed-off-by: Sakari Ailus Acked-by: Hans Verkuil --- drivers/media/v4l2-core/videobuf2-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 594c75e..79acf5e 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2003,13 +2003,14 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) unsigned int res = 0; unsigned long flags; - if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { + if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) && + req_events & POLLPRI) { struct v4l2_fh *fh = file->private_data; + poll_wait(file, &fh->wait, wait); + if (v4l2_event_pending(fh)) res = POLLPRI; - else if (req_events & POLLPRI) - poll_wait(file, &fh->wait, wait); } if (!V4L2_TYPE_IS_OUTPUT(q->type) && !(req_events & (POLLIN | POLLRDNORM)))