[{"id":5041,"web_url":"https://patchwork.libcamera.org/comment/5041/","msgid":"<20200605101603.GF5852@pendragon.ideasonboard.com>","date":"2020-06-05T10:16:03","subject":"Re: [libcamera-devel] [PATCH v2 4/7] v4l2: v4l2_camera_proxy:\n\tAcquire only one buffer semaphore on VIDIOC_DQBUF","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Fri, Jun 05, 2020 at 06:01:03PM +0900, Paul Elder wrote:\n> We use a semaphore to atomically keep track of how many buffers are\n> available for dequeueing. The check for how to acquire the semaphore was\n> incorrect, leading to a double acquire upon a successful nonblocking\n> acquire. Fix this.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> \n> ---\n> Changes in v2: restructured the if block so it's easier to read\n> ---\n>  src/v4l2/v4l2_camera_proxy.cpp | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index ec6d265d..a0c6deea 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -426,10 +426,10 @@ int V4L2CameraProxy::vidioc_dqbuf(struct v4l2_buffer *arg)\n>  \t    !validateMemoryType(arg->memory))\n>  \t\treturn -EINVAL;\n>  \n> -\tif (nonBlocking_ && !vcam_->bufferSema_.tryAcquire())\n> -\t\treturn -EAGAIN;\n> -\telse\n> +\tif (!nonBlocking_)\n>  \t\tvcam_->bufferSema_.acquire();\n> +\telse if (!vcam_->bufferSema_.tryAcquire())\n> +\t\treturn -EAGAIN;\n>  \n>  \tupdateBuffers();\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 06BBB603C9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Jun 2020 12:16:21 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9C79B27C;\n\tFri,  5 Jun 2020 12:16:20 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"vDxRWaS7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591352180;\n\tbh=6HIIB7rWEVDjN5qyaiLOTrBg9HFuNbdoV0Ukn4LueA4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=vDxRWaS74cfeDZo99DWaF+z/RUNwupT2eZGIfO7PK/fLt6CIKG3hiHxRk2OK8OO0m\n\tsgvNriiG6TdU/EYyBHaRup6l73m8YqPtzDzQE41sGqevV+yzOMPiJPigMJE1NmsTOn\n\tI4kO0dOw7HozFEXSikgDV2bLtgKGh5nv0nA6FSZ8=","Date":"Fri, 5 Jun 2020 13:16:03 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200605101603.GF5852@pendragon.ideasonboard.com>","References":"<20200605090106.15424-1-paul.elder@ideasonboard.com>\n\t<20200605090106.15424-5-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200605090106.15424-5-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 4/7] v4l2: v4l2_camera_proxy:\n\tAcquire only one buffer semaphore on VIDIOC_DQBUF","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 05 Jun 2020 10:16:21 -0000"}},{"id":5056,"web_url":"https://patchwork.libcamera.org/comment/5056/","msgid":"<20200605181824.GG5864@oden.dyn.berto.se>","date":"2020-06-05T18:18:24","subject":"Re: [libcamera-devel] [PATCH v2 4/7] v4l2: v4l2_camera_proxy:\n\tAcquire only one buffer semaphore on VIDIOC_DQBUF","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Paul,\n\nThanks for your patch.\n\nOn 2020-06-05 18:01:03 +0900, Paul Elder wrote:\n> We use a semaphore to atomically keep track of how many buffers are\n> available for dequeueing. The check for how to acquire the semaphore was\n> incorrect, leading to a double acquire upon a successful nonblocking\n> acquire. Fix this.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> \n> ---\n> Changes in v2: restructured the if block so it's easier to read\n> ---\n>  src/v4l2/v4l2_camera_proxy.cpp | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index ec6d265d..a0c6deea 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -426,10 +426,10 @@ int V4L2CameraProxy::vidioc_dqbuf(struct v4l2_buffer *arg)\n>  \t    !validateMemoryType(arg->memory))\n>  \t\treturn -EINVAL;\n>  \n> -\tif (nonBlocking_ && !vcam_->bufferSema_.tryAcquire())\n> -\t\treturn -EAGAIN;\n> -\telse\n> +\tif (!nonBlocking_)\n>  \t\tvcam_->bufferSema_.acquire();\n> +\telse if (!vcam_->bufferSema_.tryAcquire())\n> +\t\treturn -EAGAIN;\n>  \n>  \tupdateBuffers();\n>  \n> -- \n> 2.20.1\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 30F82603C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Jun 2020 20:18:26 +0200 (CEST)","by mail-lj1-x244.google.com with SMTP id z9so12856458ljh.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 05 Jun 2020 11:18:26 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\t130sm1256696lfl.37.2020.06.05.11.18.24\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 05 Jun 2020 11:18:24 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"Fggyfyq7\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=wxNHU8ZiVpUwhB8Q4aCTyh4b0NN+Na8L4Y+z7Bpaacs=;\n\tb=Fggyfyq7w6bbwUNTs6i0/FrTV9CwWbpzL/tK/AtQQxeCtuIk/ifoXgPdXggn5f1/PK\n\tx16XBIYDSkV4fvaOt8CqZaou4XfUxaBuxjkWjcakJBgkkinrMamORT1NYkCTqvjdy+DO\n\thldOz8kojGdxD2KVJ3OV6CTbeB7+HpSOxZKsK7elVJwnYbz0huysjMTX56iQXwheaRCl\n\tmshi29/dxpHuBkIPxNke3okaHTExodzw2S3bArQc6QnlyDrP0Hogx3f7f0op7Cos2p8m\n\tq3VEbUt+/Zqp43t77n6acXcx70ufl4HKHFItc4fwtxrKFmLbq/cTj/c1vSy0c1pFFlG8\n\tFSfg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=wxNHU8ZiVpUwhB8Q4aCTyh4b0NN+Na8L4Y+z7Bpaacs=;\n\tb=Q4vqD3aPQPXLYFJ01yaiBAp9MKhLVkhdq2SxigzCPn1svgsa7L/Ra0MUGQldRVemaC\n\tla61BBB5m2IChLo3xvXjDqJ20X6g0sLpSsHFtdiGP4bmZQKEQP5dn35nnNadqrB9IMSO\n\tTj8j5ltq74DUW/iZo4Yd/vLD/qlz3MoA75uBenEc2JMpQqK2SpniGaKbSgGRp8JgqovE\n\tdWExjhY2hX4tmu6xUUOJkPWSK2Ug0lOJc/0oowTIwE4T2mb0ImkkktaEI7sXI4xNM/q+\n\tYhdqTyzgIbeABH5OO0KfSw5ydWeBhK1j0fdssLFXpiWhIdHyLzv3hF23wBpRRZSSeT2L\n\t6LVw==","X-Gm-Message-State":"AOAM532NbwF601u4cjIXBT70yhalU7DqUFB5nK6bURMwocmedcRuj587\n\tV3I73eMIuct2XG6eshVv3M36EQ==","X-Google-Smtp-Source":"ABdhPJyGCnAmr99cY0aFK5WN4pu30ChhAcO/fmIAqEfx2epHI4FaarN0cD4UmDeJZVRmyuD5ZybzRw==","X-Received":"by 2002:a2e:b611:: with SMTP id\n\tr17mr5292797ljn.321.1591381105628; \n\tFri, 05 Jun 2020 11:18:25 -0700 (PDT)","Date":"Fri, 5 Jun 2020 20:18:24 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200605181824.GG5864@oden.dyn.berto.se>","References":"<20200605090106.15424-1-paul.elder@ideasonboard.com>\n\t<20200605090106.15424-5-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200605090106.15424-5-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 4/7] v4l2: v4l2_camera_proxy:\n\tAcquire only one buffer semaphore on VIDIOC_DQBUF","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 05 Jun 2020 18:18:26 -0000"}}]