From patchwork Thu Apr 21 09:15:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 8897941 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6388BF29F for ; Thu, 21 Apr 2016 09:16:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EDC93202FF for ; Thu, 21 Apr 2016 09:16:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08D87202EC for ; Thu, 21 Apr 2016 09:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752164AbcDUJPb (ORCPT ); Thu, 21 Apr 2016 05:15:31 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:33015 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbcDUJP0 (ORCPT ); Thu, 21 Apr 2016 05:15:26 -0400 Received: by mail-lb0-f173.google.com with SMTP id u8so23526441lbk.0; Thu, 21 Apr 2016 02:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=3pLg0mzUGm2JAWI5sg8MRHrd/m1MReq0nOe4nwHe0Jg=; b=ZOZ6i50zdrnsUcTmssOer829xYrfAJRIOSeAMK0t6FfMh9sW7jLyFJRRb/OO48kK4O /VrLaSFYKR9Up2Jv24PFfGQu3O/gyngS4mcWLCNlFAaZAMRk5OOimG98yW4TwGnU0a5F dLMxymwCQsZhba4wiqncbOxSb3qD/j+ZYLLyceMJVU9e0b3BHgHKTZ95Q8MLsr3pdVDM /n6yM1S+bBKO0Xc7a8B/Hzn9uveK6K6gwIdln44pFOksfKt1a0LluysbH5TkDfbV8Et/ /5hrCFfnfKZ8gZc9l3Cx2F958/UQkUSbceMjx/G+OWc8nqgOUHaiEcZOo17kJNYN5UnH NPgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3pLg0mzUGm2JAWI5sg8MRHrd/m1MReq0nOe4nwHe0Jg=; b=kgFA/TDhityZ898hOW8v1JqkK5WvB+D/LrwZpbsdn7ICggZCcrMkqB5dNIZXJeh0Hr aRczIdl8FCNyDGrqSWvmpNpEJ5xissD7+IU1jcq4jRB1tyJ/eJOnRYBNwiiAVLZKKs6P Ii5RTz1a6MfJzfS6mSUxDIq18lcvb0GxwFXwpGZPjqYe6uERdFwkUPIDK6hVAwWjh2t1 XsBea1Mmi2tXGeT2qDC+IztRtafNc2vHJo5vVXfUfPaZYeYK4moWmC0g7njClqaXJ8RC 0UPb5tOU3Eq2eaWI9faSlN5rQkKxuTHK5BWQuEtzd+sSezjr1K3nghroaVEN9Q4K/xJx DbBA== X-Gm-Message-State: AOPr4FX3xzANiE71KHxLSflYJu03tL+m8PEPy/PEPyDIpxEOypANWcb8yV5tMT9S4Hny6g== X-Received: by 10.112.173.71 with SMTP id bi7mr5754906lbc.61.1461230124022; Thu, 21 Apr 2016 02:15:24 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id rd7sm357901lbb.36.2016.04.21.02.15.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Apr 2016 02:15:23 -0700 (PDT) From: Ricardo Ribalda Delgado To: Pawel Osciak , Marek Szyprowski , Kyungmin Park , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado , Junghak Sung , stable@vger.kernel.org Subject: [PATCH] media: vb2: Fix regression on poll() for RW mode Date: Thu, 21 Apr 2016 11:15:16 +0200 Message-Id: <1461230116-6909-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.8.0.rc3 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 When using a device is read/write mode, vb2 does not handle properly the first select/poll operation. It allways return POLLERR. The reason for this is that when this code has been refactored, some of the operations have changed their order, and now fileio emulator is not started by poll, due to a previous check. Reported-by: Dimitrios Katsaros Cc: Junghak Sung Cc: stable@vger.kernel.org Fixes: 49d8ab9feaf2 ("media] media: videobuf2: Separate vb2_poll()") Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/videobuf2-core.c | 8 ++++++++ drivers/media/v4l2-core/videobuf2-v4l2.c | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 5d016f496e0e..199c65dbe330 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2298,6 +2298,14 @@ unsigned int vb2_core_poll(struct vb2_queue *q, struct file *file, return POLLERR; /* + * For compatibility with vb1: if QBUF hasn't been called yet, then + * return POLLERR as well. This only affects capture queues, output + * queues will always initialize waiting_for_buffers to false. + */ + if (q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM))) + return POLLERR; + + /* * For output streams you can call write() as long as there are fewer * buffers queued than there are buffers available. */ diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c index 91f552124050..c9bad9ef2104 100644 --- a/drivers/media/v4l2-core/videobuf2-v4l2.c +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c @@ -818,14 +818,6 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) poll_wait(file, &fh->wait, wait); } - /* - * For compatibility with vb1: if QBUF hasn't been called yet, then - * return POLLERR as well. This only affects capture queues, output - * queues will always initialize waiting_for_buffers to false. - */ - if (q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM))) - return POLLERR; - return res | vb2_core_poll(q, file, wait); } EXPORT_SYMBOL_GPL(vb2_poll);