[{"id":11413,"web_url":"https://patchwork.libcamera.org/comment/11413/","msgid":"<20200715225701.GH6144@pendragon.ideasonboard.com>","date":"2020-07-15T22:57:01","subject":"Re: [libcamera-devel] [PATCH v2 1/2] include: linux: Add dma-buf.h\n\tand dma-heap.h UAPI headers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Wed, Jul 15, 2020 at 10:39:10AM +0100, Naushir Patuck wrote:\n> This commit adds the dmabuf UAPI headers from the mainline Linux kernel\n> v5.6.19. They are required by the Raspberry Pi library for lens shading\n> table allocations.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/linux/dma-buf.h  | 50 +++++++++++++++++++++++++++++++++++++\n>  include/linux/dma-heap.h | 53 ++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 103 insertions(+)\n>  create mode 100644 include/linux/dma-buf.h\n>  create mode 100644 include/linux/dma-heap.h\n> \n> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h\n> new file mode 100644\n> index 00000000..7f30393b\n> --- /dev/null\n> +++ b/include/linux/dma-buf.h\n> @@ -0,0 +1,50 @@\n> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n> +/*\n> + * Framework for buffer objects that can be shared across devices/subsystems.\n> + *\n> + * Copyright(C) 2015 Intel Ltd\n> + *\n> + * This program is free software; you can redistribute it and/or modify it\n> + * under the terms of the GNU General Public License version 2 as published by\n> + * the Free Software Foundation.\n> + *\n> + * This program is distributed in the hope that it will be useful, but WITHOUT\n> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\n> + * more details.\n> + *\n> + * You should have received a copy of the GNU General Public License along with\n> + * this program.  If not, see <http://www.gnu.org/licenses/>.\n> + */\n> +\n> +#ifndef _DMA_BUF_UAPI_H_\n> +#define _DMA_BUF_UAPI_H_\n> +\n> +#include <linux/types.h>\n> +\n> +/* begin/end dma-buf functions used for userspace mmap. */\n> +struct dma_buf_sync {\n> +\t__u64 flags;\n> +};\n> +\n> +#define DMA_BUF_SYNC_READ      (1 << 0)\n> +#define DMA_BUF_SYNC_WRITE     (2 << 0)\n> +#define DMA_BUF_SYNC_RW        (DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE)\n> +#define DMA_BUF_SYNC_START     (0 << 2)\n> +#define DMA_BUF_SYNC_END       (1 << 2)\n> +#define DMA_BUF_SYNC_VALID_FLAGS_MASK \\\n> +\t(DMA_BUF_SYNC_RW | DMA_BUF_SYNC_END)\n> +\n> +#define DMA_BUF_NAME_LEN\t32\n> +\n> +#define DMA_BUF_BASE\t\t'b'\n> +#define DMA_BUF_IOCTL_SYNC\t_IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)\n> +\n> +/* 32/64bitness of this uapi was botched in android, there's no difference\n> + * between them in actual uapi, they're just different numbers.\n> + */\n> +#define DMA_BUF_SET_NAME\t_IOW(DMA_BUF_BASE, 1, const char *)\n> +#define DMA_BUF_SET_NAME_A\t_IOW(DMA_BUF_BASE, 1, u32)\n> +#define DMA_BUF_SET_NAME_B\t_IOW(DMA_BUF_BASE, 1, u64)\n> +\n> +#endif\n> diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h\n> new file mode 100644\n> index 00000000..6f84fa08\n> --- /dev/null\n> +++ b/include/linux/dma-heap.h\n> @@ -0,0 +1,53 @@\n> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n> +/*\n> + * DMABUF Heaps Userspace API\n> + *\n> + * Copyright (C) 2011 Google, Inc.\n> + * Copyright (C) 2019 Linaro Ltd.\n> + */\n> +#ifndef _UAPI_LINUX_DMABUF_POOL_H\n> +#define _UAPI_LINUX_DMABUF_POOL_H\n> +\n> +#include <linux/ioctl.h>\n> +#include <linux/types.h>\n> +\n> +/**\n> + * DOC: DMABUF Heaps Userspace API\n> + */\n> +\n> +/* Valid FD_FLAGS are O_CLOEXEC, O_RDONLY, O_WRONLY, O_RDWR */\n> +#define DMA_HEAP_VALID_FD_FLAGS (O_CLOEXEC | O_ACCMODE)\n> +\n> +/* Currently no heap flags */\n> +#define DMA_HEAP_VALID_HEAP_FLAGS (0)\n> +\n> +/**\n> + * struct dma_heap_allocation_data - metadata passed from userspace for\n> + *                                      allocations\n> + * @len:\t\tsize of the allocation\n> + * @fd:\t\t\twill be populated with a fd which provides the\n> + *\t\t\thandle to the allocated dma-buf\n> + * @fd_flags:\t\tfile descriptor flags used when allocating\n> + * @heap_flags:\t\tflags passed to heap\n> + *\n> + * Provided by userspace as an argument to the ioctl\n> + */\n> +struct dma_heap_allocation_data {\n> +\t__u64 len;\n> +\t__u32 fd;\n> +\t__u32 fd_flags;\n> +\t__u64 heap_flags;\n> +};\n> +\n> +#define DMA_HEAP_IOC_MAGIC\t\t'H'\n> +\n> +/**\n> + * DOC: DMA_HEAP_IOCTL_ALLOC - allocate memory from pool\n> + *\n> + * Takes a dma_heap_allocation_data struct and returns it with the fd field\n> + * populated with the dmabuf handle of the allocation.\n> + */\n> +#define DMA_HEAP_IOCTL_ALLOC\t_IOWR(DMA_HEAP_IOC_MAGIC, 0x0,\\\n> +\t\t\t\t      struct dma_heap_allocation_data)\n> +\n> +#endif /* _UAPI_LINUX_DMABUF_POOL_H */","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 8EDC6BD790\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 15 Jul 2020 22:57:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0DE3160E78;\n\tThu, 16 Jul 2020 00:57:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9899960493\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Jul 2020 00:57:09 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 199DB564;\n\tThu, 16 Jul 2020 00:57:09 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ukvkmVH6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594853829;\n\tbh=vy2c9EHZx2RCVebhVk6N0hxg6+UuPLvwJ4vrmUIJccA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ukvkmVH6rivDM3wiDMBN7V0dCYC4WOYSnIZY08+RQZYGqDtP0UsvNvmrbksycVXm3\n\tsr/aaMCBStokQxXrrFLiTNmTru5pBc79ImXO1nAwURsx6TnVLCTZR8x1wDStYp+j2X\n\tqFqq5QgYKG6zkgkpxaB29CRswvuoRBj7FIZyHDmg=","Date":"Thu, 16 Jul 2020 01:57:01 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<20200715225701.GH6144@pendragon.ideasonboard.com>","References":"<20200715093911.554684-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200715093911.554684-1-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] include: linux: Add dma-buf.h\n\tand dma-heap.h UAPI headers","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]