[{"id":4989,"web_url":"https://patchwork.libcamera.org/comment/4989/","msgid":"<20200603205533.GH5959@pendragon.ideasonboard.com>","date":"2020-06-03T20:55:33","subject":"Re: [libcamera-devel] [PATCH 3/5] v4l2: v4l2_camera_proxy: Acquire\n\tonly 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 Wed, Jun 03, 2020 at 11:16:07PM +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\nGood catch.\n\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/v4l2/v4l2_camera_proxy.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index ec6d265d..d2419b96 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -428,7 +428,7 @@ int V4L2CameraProxy::vidioc_dqbuf(struct v4l2_buffer *arg)\n>  \n>  \tif (nonBlocking_ && !vcam_->bufferSema_.tryAcquire())\n>  \t\treturn -EAGAIN;\n> -\telse\n> +\telse if (!nonBlocking_)\n>  \t\tvcam_->bufferSema_.acquire();\n\nThis looks a bit confusing. How about the following ?\n\n\tif (nonBlocking_) {\n\t\tif (!vcam_->bufferSema_.tryAcquire())\n\t\t\treturn -EAGAIN;\n\t} else {\n\t\tvcam_->bufferSema_.acquire();\n\t}\n\nor\n\n\tif (!nonBlocking_)\n\t\tvcam_->bufferSema_.acquire();\n\telse if (!vcam_->bufferSema_.tryAcquire())\n\t\treturn -EAGAIN;\n\nPick the one you like best.\n\n>  \n>  \tupdateBuffers();","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2396E6110A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Jun 2020 22:55:50 +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 8C34B29B;\n\tWed,  3 Jun 2020 22:55:49 +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=\"VmNtD50H\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591217749;\n\tbh=6yhvtls3/R/paEA73mnPXcS6/ABYsYgRm2pZzppCIsI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VmNtD50HndGL7UelbIEKr9i8HqxEX6HfB0+Ewa6mbhVWakvvqV89wUZSe/z7QId8e\n\teJE5MmtjaGNUDbdNMUMeNzr/gPzdK1R1MdFosPARtuczpOal4xbJMYJxO+5Bxwe4QR\n\tJL1NAlTwZfaQTvAUgvY81lAWeLYPAbRbEpmb282I=","Date":"Wed, 3 Jun 2020 23:55:33 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200603205533.GH5959@pendragon.ideasonboard.com>","References":"<20200603141609.18584-1-paul.elder@ideasonboard.com>\n\t<20200603141609.18584-4-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200603141609.18584-4-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 3/5] v4l2: v4l2_camera_proxy: Acquire\n\tonly 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":"Wed, 03 Jun 2020 20:55:50 -0000"}}]