[{"id":29769,"web_url":"https://patchwork.libcamera.org/comment/29769/","msgid":"<20240605084126.GA31074@pendragon.ideasonboard.com>","date":"2024-06-05T08:41:26","subject":"Re: [PATCH] libcamera: dma_buf_allocator: Work around lack of file\n\tseals in uClibc","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Jun 05, 2024 at 11:35:33AM +0300, Laurent Pinchart wrote:\n> uClibc doesn't provide the macros defining parameters for the file\n> sealing API. Define them manually as a work around.\n> \n\nFixes: ea4baaacc325 (\"libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf\")\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n> An alternative would be to disable udmabuf support on such platforms. I\n> think we can expect someone running libcamera on a uClibc system to be\n> able to enable DMA heaps.\n> ---\n>  meson.build                         | 4 ++++\n>  src/libcamera/dma_buf_allocator.cpp | 5 +++++\n>  2 files changed, 9 insertions(+)\n> \n> diff --git a/meson.build b/meson.build\n> index 1902ea2fd3ff..0ef4cdaafd76 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -74,6 +74,10 @@ cc = meson.get_compiler('c')\n>  cxx = meson.get_compiler('cpp')\n>  config_h = configuration_data()\n>  \n> +if cc.has_header_symbol('fcntl.h', 'F_ADD_SEALS', prefix : '#define _GNU_SOURCE')\n> +    config_h.set('HAVE_FILE_SEALS', 1)\n> +endif\n> +\n>  if cc.has_header_symbol('unistd.h', 'issetugid')\n>      config_h.set('HAVE_ISSETUGID', 1)\n>  endif\n> diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp\n> index d7d08e188a62..1c39441a3415 100644\n> --- a/src/libcamera/dma_buf_allocator.cpp\n> +++ b/src/libcamera/dma_buf_allocator.cpp\n> @@ -157,6 +157,11 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)\n>  \t\treturn {};\n>  \t}\n>  \n> +#if not HAVE_FILE_SEALS\n> +#define F_ADD_SEALS\t1033\n> +#define F_SEAL_SHRINK\t0x0002\n> +#endif\n> +\n>  \t/* udmabuf dma-buffers *must* have the F_SEAL_SHRINK seal. */\n>  \tret = fcntl(memfd.get(), F_ADD_SEALS, F_SEAL_SHRINK);\n>  \tif (ret < 0) {\n> \n> base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a","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 9616BBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 08:41:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 45D2065444;\n\tWed,  5 Jun 2024 10:41:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 764306543E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 10:41:44 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1F12915C5;\n\tWed,  5 Jun 2024 10:41:36 +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=\"GTQRqcgI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717576896;\n\tbh=GgzNFw30e3o8kbZYE3gPg8yRerKCWoabgrkcBZaJdHo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=GTQRqcgI3YRmxhu0aDnIEi/DnR3iPf8Q2UNmWrvDwNnmYRtYk2e4Pp4AsUE70ftpq\n\thfINjalYtFHK8oehsLsspCPjtJk5dcDQu1uqNxlfXRcHuihWlkZhI/PRWw0ktQ2bea\n\tXqdULCZQEFHlfsZ+mQ1yw6boFTY2sN9+nWWUJ4w8=","Date":"Wed, 5 Jun 2024 11:41:26 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Hans de Goede <hdegoede@redhat.com>","Subject":"Re: [PATCH] libcamera: dma_buf_allocator: Work around lack of file\n\tseals in uClibc","Message-ID":"<20240605084126.GA31074@pendragon.ideasonboard.com>","References":"<20240605083533.30718-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240605083533.30718-1-laurent.pinchart@ideasonboard.com>","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>"}},{"id":29771,"web_url":"https://patchwork.libcamera.org/comment/29771/","msgid":"<171757712828.205609.11756686108252935800@ping.linuxembedded.co.uk>","date":"2024-06-05T08:45:28","subject":"Re: [PATCH] libcamera: dma_buf_allocator: Work around lack of file\n\tseals in uClibc","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-06-05 09:35:33)\n> uClibc doesn't provide the macros defining parameters for the file\n> sealing API. Define them manually as a work around.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n> An alternative would be to disable udmabuf support on such platforms. I\n> think we can expect someone running libcamera on a uClibc system to be\n> able to enable DMA heaps.\n\nI think this is fine, and keeps our uClibc compile coverage up.\n\n> ---\n>  meson.build                         | 4 ++++\n>  src/libcamera/dma_buf_allocator.cpp | 5 +++++\n>  2 files changed, 9 insertions(+)\n> \n> diff --git a/meson.build b/meson.build\n> index 1902ea2fd3ff..0ef4cdaafd76 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -74,6 +74,10 @@ cc = meson.get_compiler('c')\n>  cxx = meson.get_compiler('cpp')\n>  config_h = configuration_data()\n>  \n> +if cc.has_header_symbol('fcntl.h', 'F_ADD_SEALS', prefix : '#define _GNU_SOURCE')\n> +    config_h.set('HAVE_FILE_SEALS', 1)\n> +endif\n> +\n>  if cc.has_header_symbol('unistd.h', 'issetugid')\n>      config_h.set('HAVE_ISSETUGID', 1)\n>  endif\n> diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp\n> index d7d08e188a62..1c39441a3415 100644\n> --- a/src/libcamera/dma_buf_allocator.cpp\n> +++ b/src/libcamera/dma_buf_allocator.cpp\n> @@ -157,6 +157,11 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)\n>                 return {};\n>         }\n>  \n> +#if not HAVE_FILE_SEALS\n\nA one line comment above saying why they are hardcoded here for context\nto readers coming across this would be nice but optional.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +#define F_ADD_SEALS    1033\n> +#define F_SEAL_SHRINK  0x0002\n> +#endif\n> +\n>         /* udmabuf dma-buffers *must* have the F_SEAL_SHRINK seal. */\n>         ret = fcntl(memfd.get(), F_ADD_SEALS, F_SEAL_SHRINK);\n>         if (ret < 0) {\n> \n> base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 A9B04BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 08:45:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CFAC765440;\n\tWed,  5 Jun 2024 10:45:32 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A43DC6543C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 10:45:31 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 42D9BEA2;\n\tWed,  5 Jun 2024 10:45:23 +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=\"ob/uc2vG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717577123;\n\tbh=dEJY3im3R5bPPJStALt6ZsFkbkMPOZ4xGvvDGWVggQc=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ob/uc2vGi9SZboeaitlDvGqtJvi+b0Ik/UgIyNY/YdIAtqmX4NBJuLDsEDdVISAGj\n\tSmO+0BC79hMWQfeVP6lSxNwdYsBs9jbhQwvn3v+XBP9i5e9VTIaPb8CoZIAO6PQzZV\n\t+P1Z/y6tuT+fYTQXhUz88PO1UKCYTArEmvhjAgy4=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240605083533.30718-1-laurent.pinchart@ideasonboard.com>","References":"<20240605083533.30718-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH] libcamera: dma_buf_allocator: Work around lack of file\n\tseals in uClibc","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Hans de Goede <hdegoede@redhat.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 05 Jun 2024 09:45:28 +0100","Message-ID":"<171757712828.205609.11756686108252935800@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":29775,"web_url":"https://patchwork.libcamera.org/comment/29775/","msgid":"<ff502645-e5e7-44e0-b8b3-a497a71f3f7a@redhat.com>","date":"2024-06-05T09:08:23","subject":"Re: [PATCH] libcamera: dma_buf_allocator: Work around lack of file\n\tseals in uClibc","submitter":{"id":102,"url":"https://patchwork.libcamera.org/api/people/102/","name":"Hans de Goede","email":"hdegoede@redhat.com"},"content":"Hi,\n\nOn 6/5/24 10:35 AM, Laurent Pinchart wrote:\n> uClibc doesn't provide the macros defining parameters for the file\n> sealing API. Define them manually as a work around.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nThanks, patch looks good to me:\n\nReviewed-by: Hans de Goede <hdegoede@redhat.com>\n\nRegards,\n\nHans\n\n\n> ---\n> An alternative would be to disable udmabuf support on such platforms. I\n> think we can expect someone running libcamera on a uClibc system to be\n> able to enable DMA heaps.\n> ---\n>  meson.build                         | 4 ++++\n>  src/libcamera/dma_buf_allocator.cpp | 5 +++++\n>  2 files changed, 9 insertions(+)\n> \n> diff --git a/meson.build b/meson.build\n> index 1902ea2fd3ff..0ef4cdaafd76 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -74,6 +74,10 @@ cc = meson.get_compiler('c')\n>  cxx = meson.get_compiler('cpp')\n>  config_h = configuration_data()\n>  \n> +if cc.has_header_symbol('fcntl.h', 'F_ADD_SEALS', prefix : '#define _GNU_SOURCE')\n> +    config_h.set('HAVE_FILE_SEALS', 1)\n> +endif\n> +\n>  if cc.has_header_symbol('unistd.h', 'issetugid')\n>      config_h.set('HAVE_ISSETUGID', 1)\n>  endif\n> diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp\n> index d7d08e188a62..1c39441a3415 100644\n> --- a/src/libcamera/dma_buf_allocator.cpp\n> +++ b/src/libcamera/dma_buf_allocator.cpp\n> @@ -157,6 +157,11 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)\n>  \t\treturn {};\n>  \t}\n>  \n> +#if not HAVE_FILE_SEALS\n> +#define F_ADD_SEALS\t1033\n> +#define F_SEAL_SHRINK\t0x0002\n> +#endif\n> +\n>  \t/* udmabuf dma-buffers *must* have the F_SEAL_SHRINK seal. */\n>  \tret = fcntl(memfd.get(), F_ADD_SEALS, F_SEAL_SHRINK);\n>  \tif (ret < 0) {\n> \n> base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a","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 C08B1BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 09:08:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A0C996543C;\n\tWed,  5 Jun 2024 11:08:33 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9FE4634B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 11:08:31 +0200 (CEST)","from mail-ej1-f72.google.com (mail-ej1-f72.google.com\n\t[209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-646-WBZwvQUiPYaInMThmfUtug-1; Wed, 05 Jun 2024 05:08:29 -0400","by mail-ej1-f72.google.com with SMTP id\n\ta640c23a62f3a-a68c70ab413so77716266b.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 05 Jun 2024 02:08:28 -0700 (PDT)","from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec?\n\t(2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl.\n\t[2001:1c00:c32:7800:5bfa:a036:83f0:f9ec])\n\tby smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-a68cbda6734sm559779466b.114.2024.06.05.02.08.23\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tWed, 05 Jun 2024 02:08:23 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"T0I1/MlP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1717578510;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=6nivcmCerj9FCjKZsFdIID0OynlP1yJ7qghN4bGZaKs=;\n\tb=T0I1/MlPkp7xo4KtSzHRyNNC0ObszeywqtNxD0oOd9h5kBhzRJnJwmLsV0u0OIezLsnKOE\n\tR1p6dfMVo5S+N2j9z6wJEVN/dfPDN9u6B+M85LtiRwlv1sFhciL6ZGYS3784klcIWFMci0\n\t/sg4PSERFtJ2dQqJuZGivHypV0eS+aI=","X-MC-Unique":"WBZwvQUiPYaInMThmfUtug-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1717578507; x=1718183307;\n\th=content-transfer-encoding:in-reply-to:from:content-language\n\t:references:to:subject:user-agent:mime-version:date:message-id\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=6nivcmCerj9FCjKZsFdIID0OynlP1yJ7qghN4bGZaKs=;\n\tb=sQk2QOpJBVu2pC6ZrNWLlqj1/WkXDg5qutf2nqk534SoHhLFcB1AbJeGw6vn1w7OrO\n\tXndQRnezm2cR61/vBhQYRZWaUo6k+CwXSYyeAs3tcNnhiAtJ/vZoDnfkZQvriFUxxNRp\n\tM6wzosZevD/VRkdKMj11wj7V7nEGTzyNVgVptgk3D8WJotcevLTslJ1X+3CFnYXV3V5G\n\tSK9MkMxIlK2p1nO8HnjsbNq9/8/YxS1SRewoMwnXes9PZvovs7rh1TH1bxVXXJiiXppK\n\tlOkt4IK+W9e3EVAZEGNive5czvn/v9b5ekuuFMla57EP/D1Pb0yr17Zqh70Avucq0ohz\n\t6nIA==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCXd0Bl2q0ywH28yXLKqV9Qao6rw6pTc9BTBgeyOpn/sAwKGy445M6nUR4B2CTnpVe0wVwcJFMUaUHm0KyMZivHDcM4CUacuY5S+/qH3tQnlH+nSQg==","X-Gm-Message-State":"AOJu0YwA+dvEpjuheCCE48yoR/OPUPRW+0SNuoTWsslOrUCmS4En2yPw\n\twEkvPhyTMJIhtTgRwQ5xs+exV6Olg/BR+asIRwCnZcB0qyWvt5itdQbXE1MRnDAyMhvYdE58rb8\n\tcuK2+fEIBHMpty6LJP8aat2u0NI7athlCmANOtLABdowSGYCnpd+7aqRTfAtU3zU0QPehD6gKsV\n\tEVq9c=","X-Received":["by 2002:a17:906:1814:b0:a59:c698:41ae with SMTP id\n\ta640c23a62f3a-a699d76da85mr156074666b.34.1717578507543; \n\tWed, 05 Jun 2024 02:08:27 -0700 (PDT)","by 2002:a17:906:1814:b0:a59:c698:41ae with SMTP id\n\ta640c23a62f3a-a699d76da85mr156071466b.34.1717578506121; \n\tWed, 05 Jun 2024 02:08:26 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IHY1lh1pyhKosVwJfUfCewfRdPjzOnjLdgFMid4YHub6cBALzAqndkcKnzdIQ632D+jzcrOqg==","Message-ID":"<ff502645-e5e7-44e0-b8b3-a497a71f3f7a@redhat.com>","Date":"Wed, 5 Jun 2024 11:08:23 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] libcamera: dma_buf_allocator: Work around lack of file\n\tseals in uClibc","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20240605083533.30718-1-laurent.pinchart@ideasonboard.com>","From":"Hans de Goede <hdegoede@redhat.com>","In-Reply-To":"<20240605083533.30718-1-laurent.pinchart@ideasonboard.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Language":"en-US, nl","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","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>"}},{"id":29776,"web_url":"https://patchwork.libcamera.org/comment/29776/","msgid":"<20240605091034.GJ879@pendragon.ideasonboard.com>","date":"2024-06-05T09:10:34","subject":"Re: [PATCH] libcamera: dma_buf_allocator: Work around lack of file\n\tseals in uClibc","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Jun 05, 2024 at 09:45:28AM +0100, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2024-06-05 09:35:33)\n> > uClibc doesn't provide the macros defining parameters for the file\n> > sealing API. Define them manually as a work around.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> > An alternative would be to disable udmabuf support on such platforms. I\n> > think we can expect someone running libcamera on a uClibc system to be\n> > able to enable DMA heaps.\n> \n> I think this is fine, and keeps our uClibc compile coverage up.\n> \n> > ---\n> >  meson.build                         | 4 ++++\n> >  src/libcamera/dma_buf_allocator.cpp | 5 +++++\n> >  2 files changed, 9 insertions(+)\n> > \n> > diff --git a/meson.build b/meson.build\n> > index 1902ea2fd3ff..0ef4cdaafd76 100644\n> > --- a/meson.build\n> > +++ b/meson.build\n> > @@ -74,6 +74,10 @@ cc = meson.get_compiler('c')\n> >  cxx = meson.get_compiler('cpp')\n> >  config_h = configuration_data()\n> >  \n> > +if cc.has_header_symbol('fcntl.h', 'F_ADD_SEALS', prefix : '#define _GNU_SOURCE')\n> > +    config_h.set('HAVE_FILE_SEALS', 1)\n> > +endif\n> > +\n> >  if cc.has_header_symbol('unistd.h', 'issetugid')\n> >      config_h.set('HAVE_ISSETUGID', 1)\n> >  endif\n> > diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp\n> > index d7d08e188a62..1c39441a3415 100644\n> > --- a/src/libcamera/dma_buf_allocator.cpp\n> > +++ b/src/libcamera/dma_buf_allocator.cpp\n> > @@ -157,6 +157,11 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)\n> >                 return {};\n> >         }\n> >  \n> > +#if not HAVE_FILE_SEALS\n> \n> A one line comment above saying why they are hardcoded here for context\n> to readers coming across this would be nice but optional.\n\nI'll add\n\n\t/* uClibc doesn't provide the file sealig API. */\n\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > +#define F_ADD_SEALS    1033\n> > +#define F_SEAL_SHRINK  0x0002\n> > +#endif\n> > +\n> >         /* udmabuf dma-buffers *must* have the F_SEAL_SHRINK seal. */\n> >         ret = fcntl(memfd.get(), F_ADD_SEALS, F_SEAL_SHRINK);\n> >         if (ret < 0) {\n> > \n> > base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a","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 9962DBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 09:10:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CB4086543F;\n\tWed,  5 Jun 2024 11:10:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9C87634B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 11:10:51 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3785214B0;\n\tWed,  5 Jun 2024 11:10:43 +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=\"cifYJdzI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717578643;\n\tbh=eBiKMpYagc5UB+jZEZFHfaOHrQF0qaBDgV7HnQxykZo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=cifYJdzIqxSNDAYMmxkh7SUzKZ6K9+s35M5mVZvLOYO3JAUsKCDFopD3S4Jgwu/k1\n\tX39nb3NGlYH/KpfdwEqpR+sXhDRBNW4/Gsjd62t8oWoB4aWciaZtpZgvdpuCiXYHhv\n\tT0VoCeDji0EXnz3+GU6BtpGwitpPz+ZtDTBoZxo8=","Date":"Wed, 5 Jun 2024 12:10:34 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Hans de Goede <hdegoede@redhat.com>","Subject":"Re: [PATCH] libcamera: dma_buf_allocator: Work around lack of file\n\tseals in uClibc","Message-ID":"<20240605091034.GJ879@pendragon.ideasonboard.com>","References":"<20240605083533.30718-1-laurent.pinchart@ideasonboard.com>\n\t<171757712828.205609.11756686108252935800@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<171757712828.205609.11756686108252935800@ping.linuxembedded.co.uk>","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>"}}]