Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/include/uapi/drm/panfrost_drm.h
26282 views
1
/* SPDX-License-Identifier: MIT */
2
/*
3
* Copyright © 2014-2018 Broadcom
4
* Copyright © 2019 Collabora ltd.
5
*/
6
#ifndef _PANFROST_DRM_H_
7
#define _PANFROST_DRM_H_
8
9
#include "drm.h"
10
11
#if defined(__cplusplus)
12
extern "C" {
13
#endif
14
15
#define DRM_PANFROST_SUBMIT 0x00
16
#define DRM_PANFROST_WAIT_BO 0x01
17
#define DRM_PANFROST_CREATE_BO 0x02
18
#define DRM_PANFROST_MMAP_BO 0x03
19
#define DRM_PANFROST_GET_PARAM 0x04
20
#define DRM_PANFROST_GET_BO_OFFSET 0x05
21
#define DRM_PANFROST_PERFCNT_ENABLE 0x06
22
#define DRM_PANFROST_PERFCNT_DUMP 0x07
23
#define DRM_PANFROST_MADVISE 0x08
24
#define DRM_PANFROST_SET_LABEL_BO 0x09
25
26
#define DRM_IOCTL_PANFROST_SUBMIT DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_SUBMIT, struct drm_panfrost_submit)
27
#define DRM_IOCTL_PANFROST_WAIT_BO DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_WAIT_BO, struct drm_panfrost_wait_bo)
28
#define DRM_IOCTL_PANFROST_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_CREATE_BO, struct drm_panfrost_create_bo)
29
#define DRM_IOCTL_PANFROST_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MMAP_BO, struct drm_panfrost_mmap_bo)
30
#define DRM_IOCTL_PANFROST_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_PARAM, struct drm_panfrost_get_param)
31
#define DRM_IOCTL_PANFROST_GET_BO_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_BO_OFFSET, struct drm_panfrost_get_bo_offset)
32
#define DRM_IOCTL_PANFROST_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MADVISE, struct drm_panfrost_madvise)
33
#define DRM_IOCTL_PANFROST_SET_LABEL_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_SET_LABEL_BO, struct drm_panfrost_set_label_bo)
34
35
/*
36
* Unstable ioctl(s): only exposed when the unsafe unstable_ioctls module
37
* param is set to true.
38
* All these ioctl(s) are subject to deprecation, so please don't rely on
39
* them for anything but debugging purpose.
40
*/
41
#define DRM_IOCTL_PANFROST_PERFCNT_ENABLE DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_ENABLE, struct drm_panfrost_perfcnt_enable)
42
#define DRM_IOCTL_PANFROST_PERFCNT_DUMP DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_DUMP, struct drm_panfrost_perfcnt_dump)
43
44
#define PANFROST_JD_REQ_FS (1 << 0)
45
#define PANFROST_JD_REQ_CYCLE_COUNT (1 << 1)
46
/**
47
* struct drm_panfrost_submit - ioctl argument for submitting commands to the 3D
48
* engine.
49
*
50
* This asks the kernel to have the GPU execute a render command list.
51
*/
52
struct drm_panfrost_submit {
53
54
/** Address to GPU mapping of job descriptor */
55
__u64 jc;
56
57
/** An optional array of sync objects to wait on before starting this job. */
58
__u64 in_syncs;
59
60
/** Number of sync objects to wait on before starting this job. */
61
__u32 in_sync_count;
62
63
/** An optional sync object to place the completion fence in. */
64
__u32 out_sync;
65
66
/** Pointer to a u32 array of the BOs that are referenced by the job. */
67
__u64 bo_handles;
68
69
/** Number of BO handles passed in (size is that times 4). */
70
__u32 bo_handle_count;
71
72
/** A combination of PANFROST_JD_REQ_* */
73
__u32 requirements;
74
};
75
76
/**
77
* struct drm_panfrost_wait_bo - ioctl argument for waiting for
78
* completion of the last DRM_PANFROST_SUBMIT on a BO.
79
*
80
* This is useful for cases where multiple processes might be
81
* rendering to a BO and you want to wait for all rendering to be
82
* completed.
83
*/
84
struct drm_panfrost_wait_bo {
85
__u32 handle;
86
__u32 pad;
87
__s64 timeout_ns; /* absolute */
88
};
89
90
/* Valid flags to pass to drm_panfrost_create_bo */
91
#define PANFROST_BO_NOEXEC 1
92
#define PANFROST_BO_HEAP 2
93
94
/**
95
* struct drm_panfrost_create_bo - ioctl argument for creating Panfrost BOs.
96
*
97
* The flags argument is a bit mask of PANFROST_BO_* flags.
98
*/
99
struct drm_panfrost_create_bo {
100
__u32 size;
101
__u32 flags;
102
/** Returned GEM handle for the BO. */
103
__u32 handle;
104
/* Pad, must be zero-filled. */
105
__u32 pad;
106
/**
107
* Returned offset for the BO in the GPU address space. This offset
108
* is private to the DRM fd and is valid for the lifetime of the GEM
109
* handle.
110
*
111
* This offset value will always be nonzero, since various HW
112
* units treat 0 specially.
113
*/
114
__u64 offset;
115
};
116
117
/**
118
* struct drm_panfrost_mmap_bo - ioctl argument for mapping Panfrost BOs.
119
*
120
* This doesn't actually perform an mmap. Instead, it returns the
121
* offset you need to use in an mmap on the DRM device node. This
122
* means that tools like valgrind end up knowing about the mapped
123
* memory.
124
*
125
* There are currently no values for the flags argument, but it may be
126
* used in a future extension.
127
*/
128
struct drm_panfrost_mmap_bo {
129
/** Handle for the object being mapped. */
130
__u32 handle;
131
__u32 flags;
132
/** offset into the drm node to use for subsequent mmap call. */
133
__u64 offset;
134
};
135
136
enum drm_panfrost_param {
137
DRM_PANFROST_PARAM_GPU_PROD_ID,
138
DRM_PANFROST_PARAM_GPU_REVISION,
139
DRM_PANFROST_PARAM_SHADER_PRESENT,
140
DRM_PANFROST_PARAM_TILER_PRESENT,
141
DRM_PANFROST_PARAM_L2_PRESENT,
142
DRM_PANFROST_PARAM_STACK_PRESENT,
143
DRM_PANFROST_PARAM_AS_PRESENT,
144
DRM_PANFROST_PARAM_JS_PRESENT,
145
DRM_PANFROST_PARAM_L2_FEATURES,
146
DRM_PANFROST_PARAM_CORE_FEATURES,
147
DRM_PANFROST_PARAM_TILER_FEATURES,
148
DRM_PANFROST_PARAM_MEM_FEATURES,
149
DRM_PANFROST_PARAM_MMU_FEATURES,
150
DRM_PANFROST_PARAM_THREAD_FEATURES,
151
DRM_PANFROST_PARAM_MAX_THREADS,
152
DRM_PANFROST_PARAM_THREAD_MAX_WORKGROUP_SZ,
153
DRM_PANFROST_PARAM_THREAD_MAX_BARRIER_SZ,
154
DRM_PANFROST_PARAM_COHERENCY_FEATURES,
155
DRM_PANFROST_PARAM_TEXTURE_FEATURES0,
156
DRM_PANFROST_PARAM_TEXTURE_FEATURES1,
157
DRM_PANFROST_PARAM_TEXTURE_FEATURES2,
158
DRM_PANFROST_PARAM_TEXTURE_FEATURES3,
159
DRM_PANFROST_PARAM_JS_FEATURES0,
160
DRM_PANFROST_PARAM_JS_FEATURES1,
161
DRM_PANFROST_PARAM_JS_FEATURES2,
162
DRM_PANFROST_PARAM_JS_FEATURES3,
163
DRM_PANFROST_PARAM_JS_FEATURES4,
164
DRM_PANFROST_PARAM_JS_FEATURES5,
165
DRM_PANFROST_PARAM_JS_FEATURES6,
166
DRM_PANFROST_PARAM_JS_FEATURES7,
167
DRM_PANFROST_PARAM_JS_FEATURES8,
168
DRM_PANFROST_PARAM_JS_FEATURES9,
169
DRM_PANFROST_PARAM_JS_FEATURES10,
170
DRM_PANFROST_PARAM_JS_FEATURES11,
171
DRM_PANFROST_PARAM_JS_FEATURES12,
172
DRM_PANFROST_PARAM_JS_FEATURES13,
173
DRM_PANFROST_PARAM_JS_FEATURES14,
174
DRM_PANFROST_PARAM_JS_FEATURES15,
175
DRM_PANFROST_PARAM_NR_CORE_GROUPS,
176
DRM_PANFROST_PARAM_THREAD_TLS_ALLOC,
177
DRM_PANFROST_PARAM_AFBC_FEATURES,
178
DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP,
179
DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP_FREQUENCY,
180
};
181
182
struct drm_panfrost_get_param {
183
__u32 param;
184
__u32 pad;
185
__u64 value;
186
};
187
188
/**
189
* Returns the offset for the BO in the GPU address space for this DRM fd.
190
* This is the same value returned by drm_panfrost_create_bo, if that was called
191
* from this DRM fd.
192
*/
193
struct drm_panfrost_get_bo_offset {
194
__u32 handle;
195
__u32 pad;
196
__u64 offset;
197
};
198
199
struct drm_panfrost_perfcnt_enable {
200
__u32 enable;
201
/*
202
* On bifrost we have 2 sets of counters, this parameter defines the
203
* one to track.
204
*/
205
__u32 counterset;
206
};
207
208
struct drm_panfrost_perfcnt_dump {
209
__u64 buf_ptr;
210
};
211
212
/* madvise provides a way to tell the kernel in case a buffers contents
213
* can be discarded under memory pressure, which is useful for userspace
214
* bo cache where we want to optimistically hold on to buffer allocate
215
* and potential mmap, but allow the pages to be discarded under memory
216
* pressure.
217
*
218
* Typical usage would involve madvise(DONTNEED) when buffer enters BO
219
* cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache.
220
* In the WILLNEED case, 'retained' indicates to userspace whether the
221
* backing pages still exist.
222
*/
223
#define PANFROST_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */
224
#define PANFROST_MADV_DONTNEED 1 /* backing pages not needed */
225
226
struct drm_panfrost_madvise {
227
__u32 handle; /* in, GEM handle */
228
__u32 madv; /* in, PANFROST_MADV_x */
229
__u32 retained; /* out, whether backing store still exists */
230
};
231
232
/**
233
* struct drm_panfrost_set_label_bo - ioctl argument for labelling Panfrost BOs.
234
*/
235
struct drm_panfrost_set_label_bo {
236
/** @handle: Handle of the buffer object to label. */
237
__u32 handle;
238
239
/** @pad: MBZ. */
240
__u32 pad;
241
242
/**
243
* @label: User pointer to a NUL-terminated string
244
*
245
* Length cannot be greater than 4096.
246
* NULL is permitted and means clear the label.
247
*/
248
__u64 label;
249
};
250
251
/* Definitions for coredump decoding in user space */
252
#define PANFROSTDUMP_MAJOR 1
253
#define PANFROSTDUMP_MINOR 0
254
255
#define PANFROSTDUMP_MAGIC 0x464E4150 /* PANF */
256
257
#define PANFROSTDUMP_BUF_REG 0
258
#define PANFROSTDUMP_BUF_BOMAP (PANFROSTDUMP_BUF_REG + 1)
259
#define PANFROSTDUMP_BUF_BO (PANFROSTDUMP_BUF_BOMAP + 1)
260
#define PANFROSTDUMP_BUF_TRAILER (PANFROSTDUMP_BUF_BO + 1)
261
262
/*
263
* This structure is the native endianness of the dumping machine, tools can
264
* detect the endianness by looking at the value in 'magic'.
265
*/
266
struct panfrost_dump_object_header {
267
__u32 magic;
268
__u32 type;
269
__u32 file_size;
270
__u32 file_offset;
271
272
union {
273
struct {
274
__u64 jc;
275
__u32 gpu_id;
276
__u32 major;
277
__u32 minor;
278
__u64 nbos;
279
} reghdr;
280
281
struct {
282
__u32 valid;
283
__u64 iova;
284
__u32 data[2];
285
} bomap;
286
287
/*
288
* Force same size in case we want to expand the header
289
* with new fields and also keep it 512-byte aligned
290
*/
291
292
__u32 sizer[496];
293
};
294
};
295
296
/* Registers object, an array of these */
297
struct panfrost_dump_registers {
298
__u32 reg;
299
__u32 value;
300
};
301
302
#if defined(__cplusplus)
303
}
304
#endif
305
306
#endif /* _PANFROST_DRM_H_ */
307
308