[{"id":11394,"web_url":"https://patchwork.libcamera.org/comment/11394/","msgid":"<20200714222612.GJ5854@pendragon.ideasonboard.com>","date":"2020-07-14T22:26:12","subject":"Re: [libcamera-devel] [PATCH 1/2] include: linux: Add dma-buf.h and\n\tdma-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 Tue, Jul 14, 2020 at 01:08:43PM +0100, Naushir Patuck wrote:\n> These are required for the Raspberry Pi library for lens shading\n> table allocations.\n\nThis looks good to me, but could you add a note telling which kernel\nversion these files come from ? Something along the lines of\n\n\"This commit adds the dmabuf UAPI headers from the mainline Linux kernel\nv5.x. They are required for the Raspberry Pi library for lens shading\ntable 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 E3212BD790\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Jul 2020 22:26:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C09260913;\n\tWed, 15 Jul 2020 00:26:20 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A95D7605B0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Jul 2020 00:26:19 +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 25BA271D;\n\tWed, 15 Jul 2020 00:26:19 +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=\"vcfYglju\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594765579;\n\tbh=hrpI5YSgxwGVpolj463nb692QWwNRwUbLhmmLOXF9ao=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=vcfYglju8wvpW8DgA9nrnpWONWHTF8eM7s5ECUWxl3YpQnJoZJL9DaczZDK7AFO+2\n\ttAqb0f57tbUcAcidFmmVCIxvy3R9xPB95hsOkZUnZkukWO0Njk7X8UNThofJEKWImS\n\tFxhjMLis6/Se9SVB65o7/zyURj6coKMrCpj3hgUI=","Date":"Wed, 15 Jul 2020 01:26:12 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<20200714222612.GJ5854@pendragon.ideasonboard.com>","References":"<20200714120844.520732-1-naush@raspberrypi.com>\n\t<20200714120844.520732-2-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200714120844.520732-2-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 1/2] include: linux: Add dma-buf.h and\n\tdma-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>"}}]