From patchwork Wed Jun 5 08:37:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20203 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 786BBBD87C for ; Wed, 5 Jun 2024 08:38:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 319F26543F; Wed, 5 Jun 2024 10:38:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZkuPjSoz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AAC096543A for ; Wed, 5 Jun 2024 10:38:15 +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 30A1AEA2; Wed, 5 Jun 2024 10:38:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1717576687; bh=CKTFWWPqBU2qEfA6DymNQJHIv1XweVs29nexopEjs9g=; h=From:To:Cc:Subject:Date:From; b=ZkuPjSozsOLhE3t53zs8QTY8mqot7pugwFKN//ycAm7i2wXHGns3cIINeKfCYV+Li EFzWYWD70noVpUkM80HquTnkYuWsLYZTwQC/lxQlRt4p0XTkV54tpCtvI+4vF7jK7V 4IA8mA65rNW/lmYl95j0PTMWLkAY9o3sfsKlw818= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede Subject: [PATCH] libcamera: dma_buf_allocator: Work around lack of memfd_create() in uClibc Date: Wed, 5 Jun 2024 11:37:57 +0300 Message-ID: <20240605083757.31553-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 a memfd_create() implementation. Fix it by using a direct syscall when the function isn't available. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Hans de Goede --- I should have bundled this in a series with "[PATCH] libcamera: dma_buf_allocator: Work around lack of file seals in uClibc", sorry about that. --- src/libcamera/dma_buf_allocator.cpp | 5 +++++ 1 file changed, 5 insertions(+) base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp index 5ec29949c66a..d7d08e188a62 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -132,7 +133,11 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size) std::size_t pageMask = sysconf(_SC_PAGESIZE) - 1; size = (size + pageMask) & ~pageMask; +#if HAVE_MEMFD_CREATE int ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC); +#else + int ret = syscall(SYS_memfd_create, name, MFD_ALLOW_SEALING | MFD_CLOEXEC); +#endif if (ret < 0) { ret = errno; LOG(DmaBufAllocator, Error)