From patchwork Wed Mar 9 16:03:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 8547271 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 089A8C0553 for ; Wed, 9 Mar 2016 16:03:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BDD59202B8 for ; Wed, 9 Mar 2016 16:03:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D018920295 for ; Wed, 9 Mar 2016 16:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933172AbcCIQDm (ORCPT ); Wed, 9 Mar 2016 11:03:42 -0500 Received: from smtp207.alice.it ([82.57.200.103]:53521 "EHLO smtp207.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933171AbcCIQDm (ORCPT ); Wed, 9 Mar 2016 11:03:42 -0500 Received: from jcn (87.3.192.69) by smtp207.alice.it (8.6.060.28) id 562CAA691CD6DB37; Wed, 9 Mar 2016 17:03:26 +0100 Received: from ao2 by jcn with local (Exim 4.86_2) (envelope-from ) id 1adga8-00030s-Bc; Wed, 09 Mar 2016 17:03:28 +0100 From: Antonio Ospite To: Linux Media Cc: Hans de Goede , Hans Verkuil , Antonio Ospite Subject: [PATCH 6/7] [media] gspca: fix a v4l2-compliance failure during VIDIOC_REQBUFS Date: Wed, 9 Mar 2016 17:03:20 +0100 Message-Id: <1457539401-11515-7-git-send-email-ao2@ao2.it> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457539401-11515-1-git-send-email-ao2@ao2.it> References: <1457539401-11515-1-git-send-email-ao2@ao2.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 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 When calling VIDIOC_REQBUFS v4l2-compliance fails with this message: fail: v4l2-test-buffers.cpp(476): q.reqbufs(node, 1) test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL By looking at the v4l2-compliance code the failure happens when trying to request V4L2_MEMORY_USERPTR buffers without freeing explicitly the previously allocated V4L2_MEMORY_MMAP buffers. This would suggest that when changing the memory field in struct v4l2_requestbuffers the driver is supposed to free automatically any previous allocated buffers, and looking for inspiration at the code in drivers/media/v4l2-core/videobuf2-core.c::vb2_core_reqbufs() seems to confirm this interpretation; however gspca is just returning -EBUSY in this case. Removing the special handling for the case of a different memory value fixes the compliance failure. Signed-off-by: Antonio Ospite --- This should be safe, but I'd really like a comment from someone with a more global knowledge of v4l2. If my interpretation about how drivers should behave when the value of the memory field changes is correct, I could send also a documentation update for Documentation/DocBook/media/v4l/vidioc-reqbufs.xml Just let me know. Thanks, Antonio drivers/media/usb/gspca/gspca.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c index 84b0d6a..915b6c7 100644 --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c @@ -1402,13 +1402,6 @@ static int vidioc_reqbufs(struct file *file, void *priv, if (mutex_lock_interruptible(&gspca_dev->queue_lock)) return -ERESTARTSYS; - if (gspca_dev->memory != GSPCA_MEMORY_NO - && gspca_dev->memory != GSPCA_MEMORY_READ - && gspca_dev->memory != rb->memory) { - ret = -EBUSY; - goto out; - } - /* only one file may do the capture */ if (gspca_dev->capt_file != NULL && gspca_dev->capt_file != file) {