{"id":3939,"url":"https://patchwork.libcamera.org/api/1.1/patches/3939/?format=json","web_url":"https://patchwork.libcamera.org/patch/3939/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200605090106.15424-5-paul.elder@ideasonboard.com>","date":"2020-06-05T09:01:03","name":"[libcamera-devel,v2,4/7] v4l2: v4l2_camera_proxy: Acquire only one buffer semaphore on VIDIOC_DQBUF","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"78b0f8725dc4d15d7e2b13465d287af842022f4d","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3939/mbox/","series":[{"id":956,"url":"https://patchwork.libcamera.org/api/1.1/series/956/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=956","date":"2020-06-05T09:00:59","name":"Support qv4l2 with v4l2-compat","version":2,"mbox":"https://patchwork.libcamera.org/series/956/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3939/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3939/checks/","tags":{},"headers":{"Return-Path":"<paul.elder@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 8591E61027\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Jun 2020 11:01:22 +0200 (CEST)","from emerald.amanokami.net (fs76eef344.knge213.ap.nuro.jp\n\t[118.238.243.68])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 57D6B27C;\n\tFri,  5 Jun 2020 11:01:21 +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=\"XZ7280gF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591347682;\n\tbh=QB20CXQv4BOODnqeSakNDMIm1j3itxDVfiqH16KTQ/Q=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XZ7280gFjPQF05Rh1AnVS28JHClLRD5mYIAFZB53Y6xfhLkH9mqjG12GfoId/ttCZ\n\tmwpxgN4AnW0FSbUhByLZt3BrHD+OrZ1QsjvsAfD1HNdR/q1jrYoZsPcax5AvLkZRMz\n\tY0iu31m51U8zVExOxLMLsxuZI0tZ7rvifD5aS/AY=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  5 Jun 2020 18:01:03 +0900","Message-Id":"<20200605090106.15424-5-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200605090106.15424-1-paul.elder@ideasonboard.com>","References":"<20200605090106.15424-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 4/7] 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":"Fri, 05 Jun 2020 09:01:22 -0000"},"content":"We use a semaphore to atomically keep track of how many buffers are\navailable for dequeueing. The check for how to acquire the semaphore was\nincorrect, leading to a double acquire upon a successful nonblocking\nacquire. Fix this.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges 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(-)","diff":"diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 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","prefixes":["libcamera-devel","v2","4/7"]}