Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Copyright © 2014-2018 Broadcom
0004  * Copyright © 2019 Collabora ltd.
0005  */
0006 #ifndef _PANFROST_DRM_H_
0007 #define _PANFROST_DRM_H_
0008 
0009 #include "drm.h"
0010 
0011 #if defined(__cplusplus)
0012 extern "C" {
0013 #endif
0014 
0015 #define DRM_PANFROST_SUBMIT         0x00
0016 #define DRM_PANFROST_WAIT_BO            0x01
0017 #define DRM_PANFROST_CREATE_BO          0x02
0018 #define DRM_PANFROST_MMAP_BO            0x03
0019 #define DRM_PANFROST_GET_PARAM          0x04
0020 #define DRM_PANFROST_GET_BO_OFFSET      0x05
0021 #define DRM_PANFROST_PERFCNT_ENABLE     0x06
0022 #define DRM_PANFROST_PERFCNT_DUMP       0x07
0023 #define DRM_PANFROST_MADVISE            0x08
0024 
0025 #define DRM_IOCTL_PANFROST_SUBMIT       DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_SUBMIT, struct drm_panfrost_submit)
0026 #define DRM_IOCTL_PANFROST_WAIT_BO      DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_WAIT_BO, struct drm_panfrost_wait_bo)
0027 #define DRM_IOCTL_PANFROST_CREATE_BO        DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_CREATE_BO, struct drm_panfrost_create_bo)
0028 #define DRM_IOCTL_PANFROST_MMAP_BO      DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MMAP_BO, struct drm_panfrost_mmap_bo)
0029 #define DRM_IOCTL_PANFROST_GET_PARAM        DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_PARAM, struct drm_panfrost_get_param)
0030 #define DRM_IOCTL_PANFROST_GET_BO_OFFSET    DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_BO_OFFSET, struct drm_panfrost_get_bo_offset)
0031 #define DRM_IOCTL_PANFROST_MADVISE      DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MADVISE, struct drm_panfrost_madvise)
0032 
0033 /*
0034  * Unstable ioctl(s): only exposed when the unsafe unstable_ioctls module
0035  * param is set to true.
0036  * All these ioctl(s) are subject to deprecation, so please don't rely on
0037  * them for anything but debugging purpose.
0038  */
0039 #define DRM_IOCTL_PANFROST_PERFCNT_ENABLE   DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_ENABLE, struct drm_panfrost_perfcnt_enable)
0040 #define DRM_IOCTL_PANFROST_PERFCNT_DUMP     DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_DUMP, struct drm_panfrost_perfcnt_dump)
0041 
0042 #define PANFROST_JD_REQ_FS (1 << 0)
0043 /**
0044  * struct drm_panfrost_submit - ioctl argument for submitting commands to the 3D
0045  * engine.
0046  *
0047  * This asks the kernel to have the GPU execute a render command list.
0048  */
0049 struct drm_panfrost_submit {
0050 
0051     /** Address to GPU mapping of job descriptor */
0052     __u64 jc;
0053 
0054     /** An optional array of sync objects to wait on before starting this job. */
0055     __u64 in_syncs;
0056 
0057     /** Number of sync objects to wait on before starting this job. */
0058     __u32 in_sync_count;
0059 
0060     /** An optional sync object to place the completion fence in. */
0061     __u32 out_sync;
0062 
0063     /** Pointer to a u32 array of the BOs that are referenced by the job. */
0064     __u64 bo_handles;
0065 
0066     /** Number of BO handles passed in (size is that times 4). */
0067     __u32 bo_handle_count;
0068 
0069     /** A combination of PANFROST_JD_REQ_* */
0070     __u32 requirements;
0071 };
0072 
0073 /**
0074  * struct drm_panfrost_wait_bo - ioctl argument for waiting for
0075  * completion of the last DRM_PANFROST_SUBMIT on a BO.
0076  *
0077  * This is useful for cases where multiple processes might be
0078  * rendering to a BO and you want to wait for all rendering to be
0079  * completed.
0080  */
0081 struct drm_panfrost_wait_bo {
0082     __u32 handle;
0083     __u32 pad;
0084     __s64 timeout_ns;   /* absolute */
0085 };
0086 
0087 /* Valid flags to pass to drm_panfrost_create_bo */
0088 #define PANFROST_BO_NOEXEC  1
0089 #define PANFROST_BO_HEAP    2
0090 
0091 /**
0092  * struct drm_panfrost_create_bo - ioctl argument for creating Panfrost BOs.
0093  *
0094  * The flags argument is a bit mask of PANFROST_BO_* flags.
0095  */
0096 struct drm_panfrost_create_bo {
0097     __u32 size;
0098     __u32 flags;
0099     /** Returned GEM handle for the BO. */
0100     __u32 handle;
0101     /* Pad, must be zero-filled. */
0102     __u32 pad;
0103     /**
0104      * Returned offset for the BO in the GPU address space.  This offset
0105      * is private to the DRM fd and is valid for the lifetime of the GEM
0106      * handle.
0107      *
0108      * This offset value will always be nonzero, since various HW
0109      * units treat 0 specially.
0110      */
0111     __u64 offset;
0112 };
0113 
0114 /**
0115  * struct drm_panfrost_mmap_bo - ioctl argument for mapping Panfrost BOs.
0116  *
0117  * This doesn't actually perform an mmap.  Instead, it returns the
0118  * offset you need to use in an mmap on the DRM device node.  This
0119  * means that tools like valgrind end up knowing about the mapped
0120  * memory.
0121  *
0122  * There are currently no values for the flags argument, but it may be
0123  * used in a future extension.
0124  */
0125 struct drm_panfrost_mmap_bo {
0126     /** Handle for the object being mapped. */
0127     __u32 handle;
0128     __u32 flags;
0129     /** offset into the drm node to use for subsequent mmap call. */
0130     __u64 offset;
0131 };
0132 
0133 enum drm_panfrost_param {
0134     DRM_PANFROST_PARAM_GPU_PROD_ID,
0135     DRM_PANFROST_PARAM_GPU_REVISION,
0136     DRM_PANFROST_PARAM_SHADER_PRESENT,
0137     DRM_PANFROST_PARAM_TILER_PRESENT,
0138     DRM_PANFROST_PARAM_L2_PRESENT,
0139     DRM_PANFROST_PARAM_STACK_PRESENT,
0140     DRM_PANFROST_PARAM_AS_PRESENT,
0141     DRM_PANFROST_PARAM_JS_PRESENT,
0142     DRM_PANFROST_PARAM_L2_FEATURES,
0143     DRM_PANFROST_PARAM_CORE_FEATURES,
0144     DRM_PANFROST_PARAM_TILER_FEATURES,
0145     DRM_PANFROST_PARAM_MEM_FEATURES,
0146     DRM_PANFROST_PARAM_MMU_FEATURES,
0147     DRM_PANFROST_PARAM_THREAD_FEATURES,
0148     DRM_PANFROST_PARAM_MAX_THREADS,
0149     DRM_PANFROST_PARAM_THREAD_MAX_WORKGROUP_SZ,
0150     DRM_PANFROST_PARAM_THREAD_MAX_BARRIER_SZ,
0151     DRM_PANFROST_PARAM_COHERENCY_FEATURES,
0152     DRM_PANFROST_PARAM_TEXTURE_FEATURES0,
0153     DRM_PANFROST_PARAM_TEXTURE_FEATURES1,
0154     DRM_PANFROST_PARAM_TEXTURE_FEATURES2,
0155     DRM_PANFROST_PARAM_TEXTURE_FEATURES3,
0156     DRM_PANFROST_PARAM_JS_FEATURES0,
0157     DRM_PANFROST_PARAM_JS_FEATURES1,
0158     DRM_PANFROST_PARAM_JS_FEATURES2,
0159     DRM_PANFROST_PARAM_JS_FEATURES3,
0160     DRM_PANFROST_PARAM_JS_FEATURES4,
0161     DRM_PANFROST_PARAM_JS_FEATURES5,
0162     DRM_PANFROST_PARAM_JS_FEATURES6,
0163     DRM_PANFROST_PARAM_JS_FEATURES7,
0164     DRM_PANFROST_PARAM_JS_FEATURES8,
0165     DRM_PANFROST_PARAM_JS_FEATURES9,
0166     DRM_PANFROST_PARAM_JS_FEATURES10,
0167     DRM_PANFROST_PARAM_JS_FEATURES11,
0168     DRM_PANFROST_PARAM_JS_FEATURES12,
0169     DRM_PANFROST_PARAM_JS_FEATURES13,
0170     DRM_PANFROST_PARAM_JS_FEATURES14,
0171     DRM_PANFROST_PARAM_JS_FEATURES15,
0172     DRM_PANFROST_PARAM_NR_CORE_GROUPS,
0173     DRM_PANFROST_PARAM_THREAD_TLS_ALLOC,
0174     DRM_PANFROST_PARAM_AFBC_FEATURES,
0175 };
0176 
0177 struct drm_panfrost_get_param {
0178     __u32 param;
0179     __u32 pad;
0180     __u64 value;
0181 };
0182 
0183 /**
0184  * Returns the offset for the BO in the GPU address space for this DRM fd.
0185  * This is the same value returned by drm_panfrost_create_bo, if that was called
0186  * from this DRM fd.
0187  */
0188 struct drm_panfrost_get_bo_offset {
0189     __u32 handle;
0190     __u32 pad;
0191     __u64 offset;
0192 };
0193 
0194 struct drm_panfrost_perfcnt_enable {
0195     __u32 enable;
0196     /*
0197      * On bifrost we have 2 sets of counters, this parameter defines the
0198      * one to track.
0199      */
0200     __u32 counterset;
0201 };
0202 
0203 struct drm_panfrost_perfcnt_dump {
0204     __u64 buf_ptr;
0205 };
0206 
0207 /* madvise provides a way to tell the kernel in case a buffers contents
0208  * can be discarded under memory pressure, which is useful for userspace
0209  * bo cache where we want to optimistically hold on to buffer allocate
0210  * and potential mmap, but allow the pages to be discarded under memory
0211  * pressure.
0212  *
0213  * Typical usage would involve madvise(DONTNEED) when buffer enters BO
0214  * cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache.
0215  * In the WILLNEED case, 'retained' indicates to userspace whether the
0216  * backing pages still exist.
0217  */
0218 #define PANFROST_MADV_WILLNEED 0    /* backing pages are needed, status returned in 'retained' */
0219 #define PANFROST_MADV_DONTNEED 1    /* backing pages not needed */
0220 
0221 struct drm_panfrost_madvise {
0222     __u32 handle;         /* in, GEM handle */
0223     __u32 madv;           /* in, PANFROST_MADV_x */
0224     __u32 retained;       /* out, whether backing store still exists */
0225 };
0226 
0227 #if defined(__cplusplus)
0228 }
0229 #endif
0230 
0231 #endif /* _PANFROST_DRM_H_ */