From patchwork Wed Jun 5 08:35:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20202 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 4B3DDBDE6B for ; Wed, 5 Jun 2024 08:35:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 637996543A; Wed, 5 Jun 2024 10:35:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ReARiLVO"; 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 B631F634DB for ; Wed, 5 Jun 2024 10:35:51 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4C51CEA2; Wed, 5 Jun 2024 10:35:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1717576543; bh=ekGB7iRKPwuG+3OTyABtMofh5S6nZAy7antPo1E04rg=; h=From:To:Cc:Subject:Date:From; b=ReARiLVOGcffE+jLxWBJlSHb3kaZzH2iM8/bq+wHfITK7krjgknXLEC5FTgOLdnBn GEjh/N0ksElXh/M50gqUyj6/iynzPm6jKAJB04nOLvezqwuC5kWAEc5H2ezBlPVycJ z4A4A04jxK9jqBFvs+rqCdoWQwCLfmpI87wwr4nc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede Subject: [PATCH] libcamera: dma_buf_allocator: Work around lack of file seals in uClibc Date: Wed, 5 Jun 2024 11:35:33 +0300 Message-ID: <20240605083533.30718-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 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" uClibc doesn't provide the macros defining parameters for the file sealing API. Define them manually as a work around. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Hans de Goede --- An alternative would be to disable udmabuf support on such platforms. I think we can expect someone running libcamera on a uClibc system to be able to enable DMA heaps. --- meson.build | 4 ++++ src/libcamera/dma_buf_allocator.cpp | 5 +++++ 2 files changed, 9 insertions(+) base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a diff --git a/meson.build b/meson.build index 1902ea2fd3ff..0ef4cdaafd76 100644 --- a/meson.build +++ b/meson.build @@ -74,6 +74,10 @@ cc = meson.get_compiler('c') cxx = meson.get_compiler('cpp') config_h = configuration_data() +if cc.has_header_symbol('fcntl.h', 'F_ADD_SEALS', prefix : '#define _GNU_SOURCE') + config_h.set('HAVE_FILE_SEALS', 1) +endif + if cc.has_header_symbol('unistd.h', 'issetugid') config_h.set('HAVE_ISSETUGID', 1) endif diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp index d7d08e188a62..1c39441a3415 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -157,6 +157,11 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size) return {}; } +#if not HAVE_FILE_SEALS +#define F_ADD_SEALS 1033 +#define F_SEAL_SHRINK 0x0002 +#endif + /* udmabuf dma-buffers *must* have the F_SEAL_SHRINK seal. */ ret = fcntl(memfd.get(), F_ADD_SEALS, F_SEAL_SHRINK); if (ret < 0) {