From patchwork Tue Sep 16 13:50:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 4918061 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 382609F2EC for ; Tue, 16 Sep 2014 13:49:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35F6C20131 for ; Tue, 16 Sep 2014 13:51:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 649FE2010F for ; Tue, 16 Sep 2014 13:51:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753817AbaIPNvE (ORCPT ); Tue, 16 Sep 2014 09:51:04 -0400 Received: from mailout2.w2.samsung.com ([211.189.100.12]:10178 "EHLO usmailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753413AbaIPNvC (ORCPT ); Tue, 16 Sep 2014 09:51:02 -0400 Received: from uscpsbgm1.samsung.com (u114.gpu85.samsung.co.kr [203.254.195.114]) by mailout2.w2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NBZ0007SYH1WW00@mailout2.w2.samsung.com> for linux-media@vger.kernel.org; Tue, 16 Sep 2014 09:51:01 -0400 (EDT) X-AuditID: cbfec372-b7f2f6d0000052b3-12-541840450d46 Received: from ussync4.samsung.com ( [203.254.195.84]) by uscpsbgm1.samsung.com (USCPMTA) with SMTP id CF.40.21171.54048145; Tue, 16 Sep 2014 09:51:01 -0400 (EDT) Received: from concha.lan ([105.144.34.6]) by ussync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NBZ00CECYGVCR10@ussync4.samsung.com>; Tue, 16 Sep 2014 09:51:01 -0400 (EDT) Date: Tue, 16 Sep 2014 10:50:53 -0300 From: Mauro Carvalho Chehab To: Hans Verkuil Cc: linux-media , Laurent Pinchart , Pawel Osciak , Nicolas Dufresne Subject: Re: [RFC PATCH] vb2: regression fix for vbi capture & poll Message-id: <20140916105053.6b8504cf.m.chehab@samsung.com> In-reply-to: <541802B0.2020805@xs4all.nl> References: <541802B0.2020805@xs4all.nl> X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.22; x86_64-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMLMWRmVeSWpSXmKPExsVy+t/hEF1XB4kQg5XLmC1OTX7GZNE5cQm7 Rc+GrawWu77cY7OY8vYnuwOrx467Sxg9ZnfMZPV4/Oslm8fnTXIep75+Zg9gjeKySUnNySxL LdK3S+DK2L/nF0vBeaGK9X+WMjcwTuHvYuTgkBAwkfh8o7qLkRPIFJO4cG89WxcjF4eQwBJG iWtTXzKBJIQEGpgkWp8bgdgsAqoScxc9YQex2QSMJF41trCC2CJA8de7fjGDNDML7GWU+HOq mxkkISzgLLFsWj8biM0rYCXRcGMjWAOngKbEt6mPWCEWaEi0Lp7ABHGFs8TPmZMYIeoFJX5M vscCYjMLaEls3tbECmHLS2xe85Z5AqPALCRls5CUzUJStoCReRWjaGlxckFxUnquoV5xYm5x aV66XnJ+7iZGSEAX7WB8tsHqEKMAB6MSD++H++IhQqyJZcWVuYcYJTiYlUR4PTQlQoR4UxIr q1KL8uOLSnNSiw8xMnFwSjUwZr17FZk9wzw8VDlV7N+q0u4rHB82RkSeb/JpPPdph+Sk2s2P k9xOGe1ZuGHTxu8Wjy0um0semC8e7z3vyG1vz8hNWp2rj9abFxaY/Z+feLv06cG2QJ8df8w4 /Qrs9m/g+G42Ib7ha8yfmLjGnbabj+1//IdXoMX6ntWH9eyxK2VOmbbNTNvRrcRSnJFoqMVc VJwIAMfvUYxGAgAA 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 Em Tue, 16 Sep 2014 11:28:16 +0200 Hans Verkuil escreveu: > (My proposal to fix this. Note that it is untested, I plan to do that this > evening) > > Commit 9241650d62f7 broke vbi capture applications that expect POLLERR to be > returned if STREAMON wasn't called. > > Rather than checking whether buffers were queued AND vb2 was not yet streaming, > just check whether streaming is in progress and return POLLERR if not. > > This change makes it impossible to poll in one thread and call STREAMON in > another, but doing that breaks existing applications and is also not according > to the spec. So be it. > > Signed-off-by: Hans Verkuil > > diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c > index 7e6aff6..0452fb2 100644 > --- a/drivers/media/v4l2-core/videobuf2-core.c > +++ b/drivers/media/v4l2-core/videobuf2-core.c > @@ -2583,10 +2583,10 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) > } > > /* > - * There is nothing to wait for if no buffer has been queued and the > - * queue isn't streaming, or if the error flag is set. > + * There is nothing to wait for if the queue isn't streaming, or if > + * the error flag is set. > */ > - if ((list_empty(&q->queued_list) && !vb2_is_streaming(q)) || q->error) > + if (!vb2_is_streaming(q) || q->error) > return res | POLLERR; This makes the code even more different than what VB1 does. I suspect that this will likely cause even more regressions. The following (untested) patch seems to be what matches best what VB1 does, and are likely to cause less harm, but needs test of course. --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 5b808e25fc09..0d86526cbcb0 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2586,6 +2586,9 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) * There is nothing to wait for if no buffer has been queued and the * queue isn't streaming, or if the error flag is set. */ + if (!vb2_is_streaming(q)) + vb2_internal_streamon(q, q->type); + if ((list_empty(&q->queued_list) && !vb2_is_streaming(q)) || q->error) return res | POLLERR;