{"id":20747,"url":"https://patchwork.libcamera.org/api/patches/20747/?format=json","web_url":"https://patchwork.libcamera.org/patch/20747/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20240802072416.25297-2-umang.jain@ideasonboard.com>","date":"2024-08-02T07:24:15","name":"[1/2] libcamera: v4l2_device: Retry ::ioctl on EINTR","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"736db5e4dd684c90cf119352e2831dabc8ecf57d","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20747/mbox/","series":[{"id":4473,"url":"https://patchwork.libcamera.org/api/series/4473/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4473","date":"2024-08-02T07:24:14","name":"Retry ::ioctl() on EINTR","version":1,"mbox":"https://patchwork.libcamera.org/series/4473/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20747/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20747/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CF823BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Aug 2024 07:24:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5CE0A63387;\n\tFri,  2 Aug 2024 09:24:24 +0200 (CEST)","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 3CBC56337E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Aug 2024 09:24:22 +0200 (CEST)","from fedora.local (unknown\n\t[IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E9F17F3;\n\tFri,  2 Aug 2024 09:23:32 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"CqJ9hnJ3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1722583413;\n\tbh=3aE8RBibmfS7XOF6uIaV9DG1Olx5JjQZSaJf29fo5UM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=CqJ9hnJ3uLVpsqMAScAvLxxQvNtU8v8DXT7nfM5j9PhoXkwXevgRk/m6bC9+KMh5j\n\tdiaa4dQJmIgWRNPkMa9RNSAfSajBR26KbTi4W5AHQlIaLMeS9Okr4KAgHY+o83XfpC\n\t3cGYpU9tATAVQGmdY6AhXrJO6gpcSHklEO1KKLqI=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Umang Jain <umang.jain@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"V4L userspace API documentation clearly mentions the handling of\nEINTR on ioctl(). Align with the xioctl() reference provided in [1].\n\nRetry the ::ioctl() if failed with errno == EINTR. Use a do..while{}\nto check the return value of ::ioctl() and errno value. If the return\nvalue is found to be -1, and errno is set with EINTR, the ioctl() call\nshould be retried.\n\n[1]: https://docs.kernel.org/userspace-api/media/v4l/capture.c.html\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/libcamera/v4l2_device.cpp | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 4a2048cf..2e92db0f 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -454,11 +454,17 @@ int V4L2Device::setFrameStartEnabled(bool enable)\n  */\n int V4L2Device::ioctl(unsigned long request, void *argp)\n {\n+\tint ret;\n+\n+\tdo {\n+\t\tret = ::ioctl(fd_.get(), request, argp);\n+\t} while (ret == -1 && errno == EINTR);\n+\n \t/*\n \t * Printing out an error message is usually better performed\n \t * in the caller, which can provide more context.\n \t */\n-\tif (::ioctl(fd_.get(), request, argp) < 0)\n+\tif (ret < 0)\n \t\treturn -errno;\n \n \treturn 0;\n","prefixes":["1/2"]}