From patchwork Mon Dec 13 14:51:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 15150 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7A646BDB13 for ; Mon, 13 Dec 2021 14:50:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 42FF060897; Mon, 13 Dec 2021 15:50:58 +0100 (CET) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7071D60868 for ; Mon, 13 Dec 2021 15:50:54 +0100 (CET) Received: (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 0ED0460002; Mon, 13 Dec 2021 14:50:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Dec 2021 15:51:42 +0100 Message-Id: <20211213145143.218734-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211213145143.218734-1-jacopo@jmondi.org> References: <20211213145143.218734-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] test: fence: Check write return value 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The ::write() function used to signal a framebuffer fence in the unit test is marked with the 'warn_unused_result'. When building in debugoptimized mode not checking for the return value causes issues at build time: /test/fence.cpp:254:2: error: ignoring return value of function declared with 'warn_unused_result' attribute Fix that by checking the ::write() return value and emitting an error message in case the write fails. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Tested-by: Laurent Pinchart Reviewed-by: Umang Jain --- test/fence.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/fence.cpp b/test/fence.cpp index d2dfc9b615a9..d2865398784e 100644 --- a/test/fence.cpp +++ b/test/fence.cpp @@ -251,7 +251,12 @@ void FenceTest::requestComplete(Request *request) void FenceTest::signalFence() { uint64_t value = 1; - write(efd2_, &value, sizeof(value)); + int ret; + + ret = write(efd2_, &value, sizeof(value)); + if (ret != sizeof(value)) + cerr << "Failed to signal fence" << endl; + dispatcher_->processEvents(); } From patchwork Mon Dec 13 14:51:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 15151 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6E8F8C324B for ; Mon, 13 Dec 2021 14:50:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C4CC6089C; Mon, 13 Dec 2021 15:50:58 +0100 (CET) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 07FE960868 for ; Mon, 13 Dec 2021 15:50:55 +0100 (CET) Received: (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 9B57D6000D; Mon, 13 Dec 2021 14:50:54 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Dec 2021 15:51:43 +0100 Message-Id: <20211213145143.218734-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211213145143.218734-1-jacopo@jmondi.org> References: <20211213145143.218734-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] test: fence: Signal fence once 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The unit test associates a fence with a framebuffer and makes sure the fence is correctly signalled. Once a fence is correctly signalled, it is released by the core, and the underlying file descriptor closed. The unit test however tries to write on the fence file descriptor every time the designated Request is queued, and error which is now visible as the return value of the fence signalling write() is checked. Fix that by associating a fence with a framebuffer only once. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Tested-by: Laurent Pinchart Reviewed-by: Umang Jain --- test/fence.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/fence.cpp b/test/fence.cpp index d2865398784e..524db2a10757 100644 --- a/test/fence.cpp +++ b/test/fence.cpp @@ -56,6 +56,7 @@ private: Stream *stream_; bool expectedCompletionResult_ = true; + bool setFence_ = true; unsigned int completedRequest_; @@ -193,7 +194,7 @@ void FenceTest::requestRequeue(Request *request) request->reuse(); - if (cookie == signalledRequestId_) { + if (cookie == signalledRequestId_ && setFence_) { /* * The second time this request is queued add a fence to it. * @@ -257,6 +258,7 @@ void FenceTest::signalFence() if (ret != sizeof(value)) cerr << "Failed to signal fence" << endl; + setFence_ = false; dispatcher_->processEvents(); } @@ -316,7 +318,7 @@ int FenceTest::run() Timer timer; timer.start(1000); while (timer.isRunning() && expectedCompletionResult_) { - if (completedRequest_ == signalledRequestId_) + if (completedRequest_ == signalledRequestId_ && setFence_) /* * signalledRequestId_ has just completed and it has * been re-queued with a fence. Start the timer to