1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * (C) COPYRIGHT 2012-2013, 2017, 2020-2021 ARM Limited. All rights reserved. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * This program is free software and is provided to you under the terms of the 7*4882a593Smuzhiyun * GNU General Public License version 2 as published by the Free Software 8*4882a593Smuzhiyun * Foundation, and any use by you of this program is subject to the terms 9*4882a593Smuzhiyun * of such GNU license. 10*4882a593Smuzhiyun * 11*4882a593Smuzhiyun * This program is distributed in the hope that it will be useful, 12*4882a593Smuzhiyun * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*4882a593Smuzhiyun * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*4882a593Smuzhiyun * GNU General Public License for more details. 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * You should have received a copy of the GNU General Public License 17*4882a593Smuzhiyun * along with this program; if not, you can access it online at 18*4882a593Smuzhiyun * http://www.gnu.org/licenses/gpl-2.0.html. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun */ 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun #ifndef _LINUX_DMA_BUF_TEST_EXPORTER_H_ 23*4882a593Smuzhiyun #define _LINUX_DMA_BUF_TEST_EXPORTER_H_ 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun #include <linux/types.h> 26*4882a593Smuzhiyun #include <linux/ioctl.h> 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun #define DMA_BUF_TE_VER_MAJOR 1 29*4882a593Smuzhiyun #define DMA_BUF_TE_VER_MINOR 0 30*4882a593Smuzhiyun #define DMA_BUF_TE_ENQ 0x642d7465 31*4882a593Smuzhiyun #define DMA_BUF_TE_ACK 0x68692100 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun struct dma_buf_te_ioctl_version { 34*4882a593Smuzhiyun int op; /**< Must be set to DMA_BUF_TE_ENQ by client, driver will set it to DMA_BUF_TE_ACK */ 35*4882a593Smuzhiyun int major; /**< Major version */ 36*4882a593Smuzhiyun int minor; /**< Minor version */ 37*4882a593Smuzhiyun }; 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun struct dma_buf_te_ioctl_alloc { 40*4882a593Smuzhiyun __u64 size; /* size of buffer to allocate, in pages */ 41*4882a593Smuzhiyun }; 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun struct dma_buf_te_ioctl_status { 44*4882a593Smuzhiyun /* in */ 45*4882a593Smuzhiyun int fd; /* the dma_buf to query, only dma_buf objects exported by this driver is supported */ 46*4882a593Smuzhiyun /* out */ 47*4882a593Smuzhiyun int attached_devices; /* number of devices attached (active 'dma_buf_attach's) */ 48*4882a593Smuzhiyun int device_mappings; /* number of device mappings (active 'dma_buf_map_attachment's) */ 49*4882a593Smuzhiyun int cpu_mappings; /* number of cpu mappings (active 'mmap's) */ 50*4882a593Smuzhiyun }; 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun struct dma_buf_te_ioctl_set_failing { 53*4882a593Smuzhiyun /* in */ 54*4882a593Smuzhiyun int fd; /* the dma_buf to set failure mode for, only dma_buf objects exported by this driver is supported */ 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun /* zero = no fail injection, non-zero = inject failure */ 57*4882a593Smuzhiyun int fail_attach; 58*4882a593Smuzhiyun int fail_map; 59*4882a593Smuzhiyun int fail_mmap; 60*4882a593Smuzhiyun }; 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun struct dma_buf_te_ioctl_fill { 63*4882a593Smuzhiyun int fd; 64*4882a593Smuzhiyun unsigned int value; 65*4882a593Smuzhiyun }; 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun #define DMA_BUF_TE_IOCTL_BASE 'E' 68*4882a593Smuzhiyun /* Below all returning 0 if successful or -errcode except DMA_BUF_TE_ALLOC which will return fd or -errcode */ 69*4882a593Smuzhiyun #define DMA_BUF_TE_VERSION _IOR(DMA_BUF_TE_IOCTL_BASE, 0x00, struct dma_buf_te_ioctl_version) 70*4882a593Smuzhiyun #define DMA_BUF_TE_ALLOC _IOR(DMA_BUF_TE_IOCTL_BASE, 0x01, struct dma_buf_te_ioctl_alloc) 71*4882a593Smuzhiyun #define DMA_BUF_TE_QUERY _IOR(DMA_BUF_TE_IOCTL_BASE, 0x02, struct dma_buf_te_ioctl_status) 72*4882a593Smuzhiyun #define DMA_BUF_TE_SET_FAILING _IOW(DMA_BUF_TE_IOCTL_BASE, 0x03, struct dma_buf_te_ioctl_set_failing) 73*4882a593Smuzhiyun #define DMA_BUF_TE_ALLOC_CONT _IOR(DMA_BUF_TE_IOCTL_BASE, 0x04, struct dma_buf_te_ioctl_alloc) 74*4882a593Smuzhiyun #define DMA_BUF_TE_FILL _IOR(DMA_BUF_TE_IOCTL_BASE, 0x05, struct dma_buf_te_ioctl_fill) 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun #endif /* _LINUX_DMA_BUF_TEST_EXPORTER_H_ */ 77