From patchwork Wed Jun 3 14:16:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 3907 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B988D6114D for ; Wed, 3 Jun 2020 16:16:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rvA2fels"; dkim-atps=neutral Received: from emerald.amanokami.net (fs76eef344.knge213.ap.nuro.jp [118.238.243.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8FE5827C; Wed, 3 Jun 2020 16:16:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1591193786; bh=0jvjRyLFjW1dQ/QuY+iycDWse4ctjcTQ5yW9YRmxhMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rvA2felsjYH5KhBFV3+yP8g5F+dNeUzHatLLb0BNEQyeyfNS2ngmOA7uNsQZ3EWon ti7KlIcORQJBCPhOlKmbYqWKqlwsJ93CKwEkN+zbbuPt3C5RpkdB93uHU6yN3jEa3L 3xgtVaHGY/rkVGiXb/l5EZ8hVrH1QN+vPyybtR1Q= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Jun 2020 23:16:07 +0900 Message-Id: <20200603141609.18584-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200603141609.18584-1-paul.elder@ideasonboard.com> References: <20200603141609.18584-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] v4l2: v4l2_camera_proxy: Acquire only one buffer semaphore on VIDIOC_DQBUF X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 14:16:27 -0000 We use a semaphore to atomically keep track of how many buffers are available for dequeueing. The check for how to acquire the semaphore was incorrect, leading to a double acquire upon a successful nonblocking acquire. Fix this. Signed-off-by: Paul Elder --- src/v4l2/v4l2_camera_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index ec6d265d..d2419b96 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -428,7 +428,7 @@ int V4L2CameraProxy::vidioc_dqbuf(struct v4l2_buffer *arg) if (nonBlocking_ && !vcam_->bufferSema_.tryAcquire()) return -EAGAIN; - else + else if (!nonBlocking_) vcam_->bufferSema_.acquire(); updateBuffers();