From patchwork Wed Jun 5 09:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20204 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 40C50BD87C for ; Wed, 5 Jun 2024 09:22:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 42A7D634DB; Wed, 5 Jun 2024 11:22:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ET7VvZ2j"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C98C6634B5 for ; Wed, 5 Jun 2024 11:22:28 +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 4054414B0; Wed, 5 Jun 2024 11:22:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1717579340; bh=lNo3h7nSH6h8TOmyPChAx6fRDDYiUjUd3vsmJLhVP6U=; h=From:To:Cc:Subject:Date:From; b=ET7VvZ2jsVgsumb/79ktqnisFJ6G/4vN+FLs+aR4xiBhSeT20VwGq2qbJbAPzCUGc etPMOPn7lAZcvk+kl+k4wQyTi1l8/WioAt7UzacVz91tT/k0F7g3O9AqrEgeXYCVlq 62uADArBEodbIgFl34EQSL28I+NQcK2JKQ+BET54= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede Subject: [PATCH v2] libcamera: dma_buf_allocator: Work around lack of file seals in uClibc Date: Wed, 5 Jun 2024 12:22:11 +0300 Message-ID: <20240605092211.18954-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. Fixes: ea4baaacc325 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf") Reviewed-by: Kieran Bingham Reviewed-by: Hans de Goede Signed-off-by: Laurent Pinchart --- Changes since v1: - Silence doxygen warning - Move defines before function - Add comment --- meson.build | 4 ++++ src/libcamera/dma_buf_allocator.cpp | 8 ++++++++ 2 files changed, 12 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..c06eca7d04ec 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -127,6 +127,14 @@ DmaBufAllocator::~DmaBufAllocator() = default; * \return True if the DmaBufAllocator is valid, false otherwise */ +/* uClibc doesn't provide the file sealing API. */ +#ifndef __DOXYGEN__ +#if not HAVE_FILE_SEALS +#define F_ADD_SEALS 1033 +#define F_SEAL_SHRINK 0x0002 +#endif +#endif + UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size) { /* Size must be a multiple of the page size. Round it up. */