18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: MIT */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright © 2014-2018 Broadcom 48c2ecf20Sopenharmony_ci * Copyright © 2019 Collabora ltd. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef _PANFROST_DRM_H_ 78c2ecf20Sopenharmony_ci#define _PANFROST_DRM_H_ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "drm.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#if defined(__cplusplus) 128c2ecf20Sopenharmony_ciextern "C" { 138c2ecf20Sopenharmony_ci#endif 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define DRM_PANFROST_SUBMIT 0x00 168c2ecf20Sopenharmony_ci#define DRM_PANFROST_WAIT_BO 0x01 178c2ecf20Sopenharmony_ci#define DRM_PANFROST_CREATE_BO 0x02 188c2ecf20Sopenharmony_ci#define DRM_PANFROST_MMAP_BO 0x03 198c2ecf20Sopenharmony_ci#define DRM_PANFROST_GET_PARAM 0x04 208c2ecf20Sopenharmony_ci#define DRM_PANFROST_GET_BO_OFFSET 0x05 218c2ecf20Sopenharmony_ci#define DRM_PANFROST_PERFCNT_ENABLE 0x06 228c2ecf20Sopenharmony_ci#define DRM_PANFROST_PERFCNT_DUMP 0x07 238c2ecf20Sopenharmony_ci#define DRM_PANFROST_MADVISE 0x08 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_SUBMIT DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_SUBMIT, struct drm_panfrost_submit) 268c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_WAIT_BO DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_WAIT_BO, struct drm_panfrost_wait_bo) 278c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_CREATE_BO, struct drm_panfrost_create_bo) 288c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MMAP_BO, struct drm_panfrost_mmap_bo) 298c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_PARAM, struct drm_panfrost_get_param) 308c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_GET_BO_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_BO_OFFSET, struct drm_panfrost_get_bo_offset) 318c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MADVISE, struct drm_panfrost_madvise) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* 348c2ecf20Sopenharmony_ci * Unstable ioctl(s): only exposed when the unsafe unstable_ioctls module 358c2ecf20Sopenharmony_ci * param is set to true. 368c2ecf20Sopenharmony_ci * All these ioctl(s) are subject to deprecation, so please don't rely on 378c2ecf20Sopenharmony_ci * them for anything but debugging purpose. 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_PERFCNT_ENABLE DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_ENABLE, struct drm_panfrost_perfcnt_enable) 408c2ecf20Sopenharmony_ci#define DRM_IOCTL_PANFROST_PERFCNT_DUMP DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_DUMP, struct drm_panfrost_perfcnt_dump) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define PANFROST_JD_REQ_FS (1 << 0) 438c2ecf20Sopenharmony_ci/** 448c2ecf20Sopenharmony_ci * struct drm_panfrost_submit - ioctl argument for submitting commands to the 3D 458c2ecf20Sopenharmony_ci * engine. 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * This asks the kernel to have the GPU execute a render command list. 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_cistruct drm_panfrost_submit { 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci /** Address to GPU mapping of job descriptor */ 528c2ecf20Sopenharmony_ci __u64 jc; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci /** An optional array of sync objects to wait on before starting this job. */ 558c2ecf20Sopenharmony_ci __u64 in_syncs; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci /** Number of sync objects to wait on before starting this job. */ 588c2ecf20Sopenharmony_ci __u32 in_sync_count; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci /** An optional sync object to place the completion fence in. */ 618c2ecf20Sopenharmony_ci __u32 out_sync; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci /** Pointer to a u32 array of the BOs that are referenced by the job. */ 648c2ecf20Sopenharmony_ci __u64 bo_handles; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci /** Number of BO handles passed in (size is that times 4). */ 678c2ecf20Sopenharmony_ci __u32 bo_handle_count; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci /** A combination of PANFROST_JD_REQ_* */ 708c2ecf20Sopenharmony_ci __u32 requirements; 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/** 748c2ecf20Sopenharmony_ci * struct drm_panfrost_wait_bo - ioctl argument for waiting for 758c2ecf20Sopenharmony_ci * completion of the last DRM_PANFROST_SUBMIT on a BO. 768c2ecf20Sopenharmony_ci * 778c2ecf20Sopenharmony_ci * This is useful for cases where multiple processes might be 788c2ecf20Sopenharmony_ci * rendering to a BO and you want to wait for all rendering to be 798c2ecf20Sopenharmony_ci * completed. 808c2ecf20Sopenharmony_ci */ 818c2ecf20Sopenharmony_cistruct drm_panfrost_wait_bo { 828c2ecf20Sopenharmony_ci __u32 handle; 838c2ecf20Sopenharmony_ci __u32 pad; 848c2ecf20Sopenharmony_ci __s64 timeout_ns; /* absolute */ 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define PANFROST_BO_NOEXEC 1 888c2ecf20Sopenharmony_ci#define PANFROST_BO_HEAP 2 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/** 918c2ecf20Sopenharmony_ci * struct drm_panfrost_create_bo - ioctl argument for creating Panfrost BOs. 928c2ecf20Sopenharmony_ci * 938c2ecf20Sopenharmony_ci * There are currently no values for the flags argument, but it may be 948c2ecf20Sopenharmony_ci * used in a future extension. 958c2ecf20Sopenharmony_ci */ 968c2ecf20Sopenharmony_cistruct drm_panfrost_create_bo { 978c2ecf20Sopenharmony_ci __u32 size; 988c2ecf20Sopenharmony_ci __u32 flags; 998c2ecf20Sopenharmony_ci /** Returned GEM handle for the BO. */ 1008c2ecf20Sopenharmony_ci __u32 handle; 1018c2ecf20Sopenharmony_ci /* Pad, must be zero-filled. */ 1028c2ecf20Sopenharmony_ci __u32 pad; 1038c2ecf20Sopenharmony_ci /** 1048c2ecf20Sopenharmony_ci * Returned offset for the BO in the GPU address space. This offset 1058c2ecf20Sopenharmony_ci * is private to the DRM fd and is valid for the lifetime of the GEM 1068c2ecf20Sopenharmony_ci * handle. 1078c2ecf20Sopenharmony_ci * 1088c2ecf20Sopenharmony_ci * This offset value will always be nonzero, since various HW 1098c2ecf20Sopenharmony_ci * units treat 0 specially. 1108c2ecf20Sopenharmony_ci */ 1118c2ecf20Sopenharmony_ci __u64 offset; 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/** 1158c2ecf20Sopenharmony_ci * struct drm_panfrost_mmap_bo - ioctl argument for mapping Panfrost BOs. 1168c2ecf20Sopenharmony_ci * 1178c2ecf20Sopenharmony_ci * This doesn't actually perform an mmap. Instead, it returns the 1188c2ecf20Sopenharmony_ci * offset you need to use in an mmap on the DRM device node. This 1198c2ecf20Sopenharmony_ci * means that tools like valgrind end up knowing about the mapped 1208c2ecf20Sopenharmony_ci * memory. 1218c2ecf20Sopenharmony_ci * 1228c2ecf20Sopenharmony_ci * There are currently no values for the flags argument, but it may be 1238c2ecf20Sopenharmony_ci * used in a future extension. 1248c2ecf20Sopenharmony_ci */ 1258c2ecf20Sopenharmony_cistruct drm_panfrost_mmap_bo { 1268c2ecf20Sopenharmony_ci /** Handle for the object being mapped. */ 1278c2ecf20Sopenharmony_ci __u32 handle; 1288c2ecf20Sopenharmony_ci __u32 flags; 1298c2ecf20Sopenharmony_ci /** offset into the drm node to use for subsequent mmap call. */ 1308c2ecf20Sopenharmony_ci __u64 offset; 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cienum drm_panfrost_param { 1348c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_GPU_PROD_ID, 1358c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_GPU_REVISION, 1368c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_SHADER_PRESENT, 1378c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_TILER_PRESENT, 1388c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_L2_PRESENT, 1398c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_STACK_PRESENT, 1408c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_AS_PRESENT, 1418c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_PRESENT, 1428c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_L2_FEATURES, 1438c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_CORE_FEATURES, 1448c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_TILER_FEATURES, 1458c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_MEM_FEATURES, 1468c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_MMU_FEATURES, 1478c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_THREAD_FEATURES, 1488c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_MAX_THREADS, 1498c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_THREAD_MAX_WORKGROUP_SZ, 1508c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_THREAD_MAX_BARRIER_SZ, 1518c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_COHERENCY_FEATURES, 1528c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_TEXTURE_FEATURES0, 1538c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_TEXTURE_FEATURES1, 1548c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_TEXTURE_FEATURES2, 1558c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_TEXTURE_FEATURES3, 1568c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES0, 1578c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES1, 1588c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES2, 1598c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES3, 1608c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES4, 1618c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES5, 1628c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES6, 1638c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES7, 1648c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES8, 1658c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES9, 1668c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES10, 1678c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES11, 1688c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES12, 1698c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES13, 1708c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES14, 1718c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_JS_FEATURES15, 1728c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_NR_CORE_GROUPS, 1738c2ecf20Sopenharmony_ci DRM_PANFROST_PARAM_THREAD_TLS_ALLOC, 1748c2ecf20Sopenharmony_ci}; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistruct drm_panfrost_get_param { 1778c2ecf20Sopenharmony_ci __u32 param; 1788c2ecf20Sopenharmony_ci __u32 pad; 1798c2ecf20Sopenharmony_ci __u64 value; 1808c2ecf20Sopenharmony_ci}; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/** 1838c2ecf20Sopenharmony_ci * Returns the offset for the BO in the GPU address space for this DRM fd. 1848c2ecf20Sopenharmony_ci * This is the same value returned by drm_panfrost_create_bo, if that was called 1858c2ecf20Sopenharmony_ci * from this DRM fd. 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_cistruct drm_panfrost_get_bo_offset { 1888c2ecf20Sopenharmony_ci __u32 handle; 1898c2ecf20Sopenharmony_ci __u32 pad; 1908c2ecf20Sopenharmony_ci __u64 offset; 1918c2ecf20Sopenharmony_ci}; 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cistruct drm_panfrost_perfcnt_enable { 1948c2ecf20Sopenharmony_ci __u32 enable; 1958c2ecf20Sopenharmony_ci /* 1968c2ecf20Sopenharmony_ci * On bifrost we have 2 sets of counters, this parameter defines the 1978c2ecf20Sopenharmony_ci * one to track. 1988c2ecf20Sopenharmony_ci */ 1998c2ecf20Sopenharmony_ci __u32 counterset; 2008c2ecf20Sopenharmony_ci}; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_cistruct drm_panfrost_perfcnt_dump { 2038c2ecf20Sopenharmony_ci __u64 buf_ptr; 2048c2ecf20Sopenharmony_ci}; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci/* madvise provides a way to tell the kernel in case a buffers contents 2078c2ecf20Sopenharmony_ci * can be discarded under memory pressure, which is useful for userspace 2088c2ecf20Sopenharmony_ci * bo cache where we want to optimistically hold on to buffer allocate 2098c2ecf20Sopenharmony_ci * and potential mmap, but allow the pages to be discarded under memory 2108c2ecf20Sopenharmony_ci * pressure. 2118c2ecf20Sopenharmony_ci * 2128c2ecf20Sopenharmony_ci * Typical usage would involve madvise(DONTNEED) when buffer enters BO 2138c2ecf20Sopenharmony_ci * cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache. 2148c2ecf20Sopenharmony_ci * In the WILLNEED case, 'retained' indicates to userspace whether the 2158c2ecf20Sopenharmony_ci * backing pages still exist. 2168c2ecf20Sopenharmony_ci */ 2178c2ecf20Sopenharmony_ci#define PANFROST_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */ 2188c2ecf20Sopenharmony_ci#define PANFROST_MADV_DONTNEED 1 /* backing pages not needed */ 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_cistruct drm_panfrost_madvise { 2218c2ecf20Sopenharmony_ci __u32 handle; /* in, GEM handle */ 2228c2ecf20Sopenharmony_ci __u32 madv; /* in, PANFROST_MADV_x */ 2238c2ecf20Sopenharmony_ci __u32 retained; /* out, whether backing store still exists */ 2248c2ecf20Sopenharmony_ci}; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci#if defined(__cplusplus) 2278c2ecf20Sopenharmony_ci} 2288c2ecf20Sopenharmony_ci#endif 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci#endif /* _PANFROST_DRM_H_ */ 231