Path: blob/21.2-virgl/include/drm-uapi/panfrost_drm.h
4545 views
/* SPDX-License-Identifier: MIT */1/*2* Copyright © 2014-2018 Broadcom3* Copyright © 2019 Collabora ltd.4*/5#ifndef _PANFROST_DRM_H_6#define _PANFROST_DRM_H_78#include "drm.h"910#if defined(__cplusplus)11extern "C" {12#endif1314#define DRM_PANFROST_SUBMIT 0x0015#define DRM_PANFROST_WAIT_BO 0x0116#define DRM_PANFROST_CREATE_BO 0x0217#define DRM_PANFROST_MMAP_BO 0x0318#define DRM_PANFROST_GET_PARAM 0x0419#define DRM_PANFROST_GET_BO_OFFSET 0x0520#define DRM_PANFROST_PERFCNT_ENABLE 0x0621#define DRM_PANFROST_PERFCNT_DUMP 0x0722#define DRM_PANFROST_MADVISE 0x082324#define DRM_IOCTL_PANFROST_SUBMIT DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_SUBMIT, struct drm_panfrost_submit)25#define DRM_IOCTL_PANFROST_WAIT_BO DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_WAIT_BO, struct drm_panfrost_wait_bo)26#define DRM_IOCTL_PANFROST_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_CREATE_BO, struct drm_panfrost_create_bo)27#define DRM_IOCTL_PANFROST_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MMAP_BO, struct drm_panfrost_mmap_bo)28#define DRM_IOCTL_PANFROST_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_PARAM, struct drm_panfrost_get_param)29#define DRM_IOCTL_PANFROST_GET_BO_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_BO_OFFSET, struct drm_panfrost_get_bo_offset)30#define DRM_IOCTL_PANFROST_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MADVISE, struct drm_panfrost_madvise)3132/*33* Unstable ioctl(s): only exposed when the unsafe unstable_ioctls module34* param is set to true.35* All these ioctl(s) are subject to deprecation, so please don't rely on36* them for anything but debugging purpose.37*/38#define DRM_IOCTL_PANFROST_PERFCNT_ENABLE DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_ENABLE, struct drm_panfrost_perfcnt_enable)39#define DRM_IOCTL_PANFROST_PERFCNT_DUMP DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_DUMP, struct drm_panfrost_perfcnt_dump)4041#define PANFROST_JD_REQ_FS (1 << 0)42/**43* struct drm_panfrost_submit - ioctl argument for submitting commands to the 3D44* engine.45*46* This asks the kernel to have the GPU execute a render command list.47*/48struct drm_panfrost_submit {4950/** Address to GPU mapping of job descriptor */51__u64 jc;5253/** An optional array of sync objects to wait on before starting this job. */54__u64 in_syncs;5556/** Number of sync objects to wait on before starting this job. */57__u32 in_sync_count;5859/** An optional sync object to place the completion fence in. */60__u32 out_sync;6162/** Pointer to a u32 array of the BOs that are referenced by the job. */63__u64 bo_handles;6465/** Number of BO handles passed in (size is that times 4). */66__u32 bo_handle_count;6768/** A combination of PANFROST_JD_REQ_* */69__u32 requirements;70};7172/**73* struct drm_panfrost_wait_bo - ioctl argument for waiting for74* completion of the last DRM_PANFROST_SUBMIT on a BO.75*76* This is useful for cases where multiple processes might be77* rendering to a BO and you want to wait for all rendering to be78* completed.79*/80struct drm_panfrost_wait_bo {81__u32 handle;82__u32 pad;83__s64 timeout_ns; /* absolute */84};8586#define PANFROST_BO_NOEXEC 187#define PANFROST_BO_HEAP 28889/**90* struct drm_panfrost_create_bo - ioctl argument for creating Panfrost BOs.91*92* There are currently no values for the flags argument, but it may be93* used in a future extension.94*/95struct drm_panfrost_create_bo {96__u32 size;97__u32 flags;98/** Returned GEM handle for the BO. */99__u32 handle;100/* Pad, must be zero-filled. */101__u32 pad;102/**103* Returned offset for the BO in the GPU address space. This offset104* is private to the DRM fd and is valid for the lifetime of the GEM105* handle.106*107* This offset value will always be nonzero, since various HW108* units treat 0 specially.109*/110__u64 offset;111};112113/**114* struct drm_panfrost_mmap_bo - ioctl argument for mapping Panfrost BOs.115*116* This doesn't actually perform an mmap. Instead, it returns the117* offset you need to use in an mmap on the DRM device node. This118* means that tools like valgrind end up knowing about the mapped119* memory.120*121* There are currently no values for the flags argument, but it may be122* used in a future extension.123*/124struct drm_panfrost_mmap_bo {125/** Handle for the object being mapped. */126__u32 handle;127__u32 flags;128/** offset into the drm node to use for subsequent mmap call. */129__u64 offset;130};131132enum drm_panfrost_param {133DRM_PANFROST_PARAM_GPU_PROD_ID,134DRM_PANFROST_PARAM_GPU_REVISION,135DRM_PANFROST_PARAM_SHADER_PRESENT,136DRM_PANFROST_PARAM_TILER_PRESENT,137DRM_PANFROST_PARAM_L2_PRESENT,138DRM_PANFROST_PARAM_STACK_PRESENT,139DRM_PANFROST_PARAM_AS_PRESENT,140DRM_PANFROST_PARAM_JS_PRESENT,141DRM_PANFROST_PARAM_L2_FEATURES,142DRM_PANFROST_PARAM_CORE_FEATURES,143DRM_PANFROST_PARAM_TILER_FEATURES,144DRM_PANFROST_PARAM_MEM_FEATURES,145DRM_PANFROST_PARAM_MMU_FEATURES,146DRM_PANFROST_PARAM_THREAD_FEATURES,147DRM_PANFROST_PARAM_MAX_THREADS,148DRM_PANFROST_PARAM_THREAD_MAX_WORKGROUP_SZ,149DRM_PANFROST_PARAM_THREAD_MAX_BARRIER_SZ,150DRM_PANFROST_PARAM_COHERENCY_FEATURES,151DRM_PANFROST_PARAM_TEXTURE_FEATURES0,152DRM_PANFROST_PARAM_TEXTURE_FEATURES1,153DRM_PANFROST_PARAM_TEXTURE_FEATURES2,154DRM_PANFROST_PARAM_TEXTURE_FEATURES3,155DRM_PANFROST_PARAM_JS_FEATURES0,156DRM_PANFROST_PARAM_JS_FEATURES1,157DRM_PANFROST_PARAM_JS_FEATURES2,158DRM_PANFROST_PARAM_JS_FEATURES3,159DRM_PANFROST_PARAM_JS_FEATURES4,160DRM_PANFROST_PARAM_JS_FEATURES5,161DRM_PANFROST_PARAM_JS_FEATURES6,162DRM_PANFROST_PARAM_JS_FEATURES7,163DRM_PANFROST_PARAM_JS_FEATURES8,164DRM_PANFROST_PARAM_JS_FEATURES9,165DRM_PANFROST_PARAM_JS_FEATURES10,166DRM_PANFROST_PARAM_JS_FEATURES11,167DRM_PANFROST_PARAM_JS_FEATURES12,168DRM_PANFROST_PARAM_JS_FEATURES13,169DRM_PANFROST_PARAM_JS_FEATURES14,170DRM_PANFROST_PARAM_JS_FEATURES15,171DRM_PANFROST_PARAM_NR_CORE_GROUPS,172DRM_PANFROST_PARAM_THREAD_TLS_ALLOC,173DRM_PANFROST_PARAM_AFBC_FEATURES,174};175176struct drm_panfrost_get_param {177__u32 param;178__u32 pad;179__u64 value;180};181182/**183* Returns the offset for the BO in the GPU address space for this DRM fd.184* This is the same value returned by drm_panfrost_create_bo, if that was called185* from this DRM fd.186*/187struct drm_panfrost_get_bo_offset {188__u32 handle;189__u32 pad;190__u64 offset;191};192193struct drm_panfrost_perfcnt_enable {194__u32 enable;195/*196* On bifrost we have 2 sets of counters, this parameter defines the197* one to track.198*/199__u32 counterset;200};201202struct drm_panfrost_perfcnt_dump {203__u64 buf_ptr;204};205206/* madvise provides a way to tell the kernel in case a buffers contents207* can be discarded under memory pressure, which is useful for userspace208* bo cache where we want to optimistically hold on to buffer allocate209* and potential mmap, but allow the pages to be discarded under memory210* pressure.211*212* Typical usage would involve madvise(DONTNEED) when buffer enters BO213* cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache.214* In the WILLNEED case, 'retained' indicates to userspace whether the215* backing pages still exist.216*/217#define PANFROST_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */218#define PANFROST_MADV_DONTNEED 1 /* backing pages not needed */219220struct drm_panfrost_madvise {221__u32 handle; /* in, GEM handle */222__u32 madv; /* in, PANFROST_MADV_x */223__u32 retained; /* out, whether backing store still exists */224};225226#if defined(__cplusplus)227}228#endif229230#endif /* _PANFROST_DRM_H_ */231232233