1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ 2460bfc41SGustavo Padovan /* 3460bfc41SGustavo Padovan * Copyright (C) 2012 Google, Inc. 4460bfc41SGustavo Padovan * 5460bfc41SGustavo Padovan * This program is distributed in the hope that it will be useful, 6460bfc41SGustavo Padovan * but WITHOUT ANY WARRANTY; without even the implied warranty of 7460bfc41SGustavo Padovan * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 8460bfc41SGustavo Padovan * GNU General Public License for more details. 9460bfc41SGustavo Padovan * 10460bfc41SGustavo Padovan */ 11460bfc41SGustavo Padovan 12460bfc41SGustavo Padovan #ifndef _UAPI_LINUX_SYNC_H 13460bfc41SGustavo Padovan #define _UAPI_LINUX_SYNC_H 14460bfc41SGustavo Padovan 15460bfc41SGustavo Padovan #include <linux/ioctl.h> 16460bfc41SGustavo Padovan #include <linux/types.h> 17460bfc41SGustavo Padovan 18460bfc41SGustavo Padovan /** 19d71c11ccSRob Clark * struct sync_merge_data - SYNC_IOC_MERGE: merge two fences 20460bfc41SGustavo Padovan * @name: name of new fence 21460bfc41SGustavo Padovan * @fd2: file descriptor of second fence 22460bfc41SGustavo Padovan * @fence: returns the fd of the new fence to userspace 23460bfc41SGustavo Padovan * @flags: merge_data flags 24460bfc41SGustavo Padovan * @pad: padding for 64-bit alignment, should always be zero 25d71c11ccSRob Clark * 26d71c11ccSRob Clark * Creates a new fence containing copies of the sync_pts in both 27d71c11ccSRob Clark * the calling fd and sync_merge_data.fd2. Returns the new fence's 28d71c11ccSRob Clark * fd in sync_merge_data.fence 29460bfc41SGustavo Padovan */ 30460bfc41SGustavo Padovan struct sync_merge_data { 31460bfc41SGustavo Padovan char name[32]; 32460bfc41SGustavo Padovan __s32 fd2; 33460bfc41SGustavo Padovan __s32 fence; 34460bfc41SGustavo Padovan __u32 flags; 35460bfc41SGustavo Padovan __u32 pad; 36460bfc41SGustavo Padovan }; 37460bfc41SGustavo Padovan 38460bfc41SGustavo Padovan /** 39460bfc41SGustavo Padovan * struct sync_fence_info - detailed fence information 40460bfc41SGustavo Padovan * @obj_name: name of parent sync_timeline 41460bfc41SGustavo Padovan * @driver_name: name of driver implementing the parent 42460bfc41SGustavo Padovan * @status: status of the fence 0:active 1:signaled <0:error 43460bfc41SGustavo Padovan * @flags: fence_info flags 44460bfc41SGustavo Padovan * @timestamp_ns: timestamp of status change in nanoseconds 45460bfc41SGustavo Padovan */ 46460bfc41SGustavo Padovan struct sync_fence_info { 47460bfc41SGustavo Padovan char obj_name[32]; 48460bfc41SGustavo Padovan char driver_name[32]; 49460bfc41SGustavo Padovan __s32 status; 50460bfc41SGustavo Padovan __u32 flags; 51460bfc41SGustavo Padovan __u64 timestamp_ns; 52460bfc41SGustavo Padovan }; 53460bfc41SGustavo Padovan 54460bfc41SGustavo Padovan /** 55d71c11ccSRob Clark * struct sync_file_info - SYNC_IOC_FILE_INFO: get detailed information on a sync_file 56460bfc41SGustavo Padovan * @name: name of fence 57460bfc41SGustavo Padovan * @status: status of fence. 1: signaled 0:active <0:error 58460bfc41SGustavo Padovan * @flags: sync_file_info flags 5905d56d80SRob Clark * @num_fences: number of fences in the sync_file 60460bfc41SGustavo Padovan * @pad: padding for 64-bit alignment, should always be zero 61d71c11ccSRob Clark * @sync_fence_info: pointer to array of struct &sync_fence_info with all 62460bfc41SGustavo Padovan * fences in the sync_file 63d71c11ccSRob Clark * 64d71c11ccSRob Clark * Takes a struct sync_file_info. If num_fences is 0, the field is updated 65d71c11ccSRob Clark * with the actual number of fences. If num_fences is > 0, the system will 66d71c11ccSRob Clark * use the pointer provided on sync_fence_info to return up to num_fences of 67d71c11ccSRob Clark * struct sync_fence_info, with detailed fence information. 68460bfc41SGustavo Padovan */ 69460bfc41SGustavo Padovan struct sync_file_info { 70460bfc41SGustavo Padovan char name[32]; 71460bfc41SGustavo Padovan __s32 status; 72460bfc41SGustavo Padovan __u32 flags; 73460bfc41SGustavo Padovan __u32 num_fences; 74460bfc41SGustavo Padovan __u32 pad; 75460bfc41SGustavo Padovan 76460bfc41SGustavo Padovan __u64 sync_fence_info; 77460bfc41SGustavo Padovan }; 78460bfc41SGustavo Padovan 79*63ee4454SRob Clark /** 80*63ee4454SRob Clark * struct sync_set_deadline - SYNC_IOC_SET_DEADLINE - set a deadline hint on a fence 81*63ee4454SRob Clark * @deadline_ns: absolute time of the deadline 82*63ee4454SRob Clark * @pad: must be zero 83*63ee4454SRob Clark * 84*63ee4454SRob Clark * Allows userspace to set a deadline on a fence, see &dma_fence_set_deadline 85*63ee4454SRob Clark * 86*63ee4454SRob Clark * The timebase for the deadline is CLOCK_MONOTONIC (same as vblank). For 87*63ee4454SRob Clark * example 88*63ee4454SRob Clark * 89*63ee4454SRob Clark * clock_gettime(CLOCK_MONOTONIC, &t); 90*63ee4454SRob Clark * deadline_ns = (t.tv_sec * 1000000000L) + t.tv_nsec + ns_until_deadline 91*63ee4454SRob Clark */ 92*63ee4454SRob Clark struct sync_set_deadline { 93*63ee4454SRob Clark __u64 deadline_ns; 94*63ee4454SRob Clark /* Not strictly needed for alignment but gives some possibility 95*63ee4454SRob Clark * for future extension: 96*63ee4454SRob Clark */ 97*63ee4454SRob Clark __u64 pad; 98*63ee4454SRob Clark }; 99*63ee4454SRob Clark 100460bfc41SGustavo Padovan #define SYNC_IOC_MAGIC '>' 101460bfc41SGustavo Padovan 102d71c11ccSRob Clark /* 103460bfc41SGustavo Padovan * Opcodes 0, 1 and 2 were burned during a API change to avoid users of the 104460bfc41SGustavo Padovan * old API to get weird errors when trying to handling sync_files. The API 105460bfc41SGustavo Padovan * change happened during the de-stage of the Sync Framework when there was 106460bfc41SGustavo Padovan * no upstream users available. 107460bfc41SGustavo Padovan */ 108460bfc41SGustavo Padovan 109460bfc41SGustavo Padovan #define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data) 110460bfc41SGustavo Padovan #define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info) 111*63ee4454SRob Clark #define SYNC_IOC_SET_DEADLINE _IOW(SYNC_IOC_MAGIC, 5, struct sync_set_deadline) 112460bfc41SGustavo Padovan 113460bfc41SGustavo Padovan #endif /* _UAPI_LINUX_SYNC_H */ 114