From patchwork Fri Aug 2 07:24:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 20747 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 CF823BDC71 for ; Fri, 2 Aug 2024 07:24:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5CE0A63387; Fri, 2 Aug 2024 09:24:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CqJ9hnJ3"; dkim-atps=neutral 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 3CBC56337E for ; Fri, 2 Aug 2024 09:24:22 +0200 (CEST) Received: from fedora.local (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E9F17F3; Fri, 2 Aug 2024 09:23:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722583413; bh=3aE8RBibmfS7XOF6uIaV9DG1Olx5JjQZSaJf29fo5UM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CqJ9hnJ3uLVpsqMAScAvLxxQvNtU8v8DXT7nfM5j9PhoXkwXevgRk/m6bC9+KMh5j diaa4dQJmIgWRNPkMa9RNSAfSajBR26KbTi4W5AHQlIaLMeS9Okr4KAgHY+o83XfpC 3cGYpU9tATAVQGmdY6AhXrJO6gpcSHklEO1KKLqI= From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Umang Jain Subject: [PATCH 1/2] libcamera: v4l2_device: Retry ::ioctl on EINTR Date: Fri, 2 Aug 2024 12:54:15 +0530 Message-ID: <20240802072416.25297-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802072416.25297-1-umang.jain@ideasonboard.com> References: <20240802072416.25297-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 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" V4L userspace API documentation clearly mentions the handling of EINTR on ioctl(). Align with the xioctl() reference provided in [1]. Retry the ::ioctl() if failed with errno == EINTR. Use a do..while{} to check the return value of ::ioctl() and errno value. If the return value is found to be -1, and errno is set with EINTR, the ioctl() call should be retried. [1]: https://docs.kernel.org/userspace-api/media/v4l/capture.c.html Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- src/libcamera/v4l2_device.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 4a2048cf..2e92db0f 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -454,11 +454,17 @@ int V4L2Device::setFrameStartEnabled(bool enable) */ int V4L2Device::ioctl(unsigned long request, void *argp) { + int ret; + + do { + ret = ::ioctl(fd_.get(), request, argp); + } while (ret == -1 && errno == EINTR); + /* * Printing out an error message is usually better performed * in the caller, which can provide more context. */ - if (::ioctl(fd_.get(), request, argp) < 0) + if (ret < 0) return -errno; return 0;