Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/include/uapi/drm/panfrost_drm.h
49631 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
#define DRM_PANFROST_JM_CTX_CREATE 0x0a
26
#define DRM_PANFROST_JM_CTX_DESTROY 0x0b
27
28
#define DRM_IOCTL_PANFROST_SUBMIT DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_SUBMIT, struct drm_panfrost_submit)
29
#define DRM_IOCTL_PANFROST_WAIT_BO DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_WAIT_BO, struct drm_panfrost_wait_bo)
30
#define DRM_IOCTL_PANFROST_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_CREATE_BO, struct drm_panfrost_create_bo)
31
#define DRM_IOCTL_PANFROST_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MMAP_BO, struct drm_panfrost_mmap_bo)
32
#define DRM_IOCTL_PANFROST_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_PARAM, struct drm_panfrost_get_param)
33
#define DRM_IOCTL_PANFROST_GET_BO_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_BO_OFFSET, struct drm_panfrost_get_bo_offset)
34
#define DRM_IOCTL_PANFROST_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MADVISE, struct drm_panfrost_madvise)
35
#define DRM_IOCTL_PANFROST_SET_LABEL_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_SET_LABEL_BO, struct drm_panfrost_set_label_bo)
36
#define DRM_IOCTL_PANFROST_JM_CTX_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_JM_CTX_CREATE, struct drm_panfrost_jm_ctx_create)
37
#define DRM_IOCTL_PANFROST_JM_CTX_DESTROY DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_JM_CTX_DESTROY, struct drm_panfrost_jm_ctx_destroy)
38
39
/*
40
* Unstable ioctl(s): only exposed when the unsafe unstable_ioctls module
41
* param is set to true.
42
* All these ioctl(s) are subject to deprecation, so please don't rely on
43
* them for anything but debugging purpose.
44
*/
45
#define DRM_IOCTL_PANFROST_PERFCNT_ENABLE DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_ENABLE, struct drm_panfrost_perfcnt_enable)
46
#define DRM_IOCTL_PANFROST_PERFCNT_DUMP DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_DUMP, struct drm_panfrost_perfcnt_dump)
47
48
#define PANFROST_JD_REQ_FS (1 << 0)
49
#define PANFROST_JD_REQ_CYCLE_COUNT (1 << 1)
50
/**
51
* struct drm_panfrost_submit - ioctl argument for submitting commands to the 3D
52
* engine.
53
*
54
* This asks the kernel to have the GPU execute a render command list.
55
*/
56
struct drm_panfrost_submit {
57
/**
58
* @jc: Address to GPU mapping of job descriptor
59
*/
60
__u64 jc;
61
/**
62
* @in_syncs: An optional array of sync objects to wait on
63
* before starting this job.
64
*/
65
__u64 in_syncs;
66
/**
67
* @in_sync_count: Number of sync objects to wait on before
68
* starting this job.
69
*/
70
__u32 in_sync_count;
71
/**
72
* @out_sync: An optional sync object to place the completion fence in.
73
*/
74
__u32 out_sync;
75
/**
76
* @bo_handles: Pointer to a u32 array of the BOs that are
77
* referenced by the job.
78
*/
79
__u64 bo_handles;
80
/**
81
* @bo_handle_count: Number of BO handles passed in (size is
82
* that times 4).
83
*/
84
__u32 bo_handle_count;
85
/**
86
* @requirements: A combination of PANFROST_JD_REQ_*
87
*/
88
__u32 requirements;
89
/**
90
* @jm_ctx_handle: JM context handle. Zero if you want to use the
91
* default context.
92
*/
93
__u32 jm_ctx_handle;
94
/**
95
* @pad: Padding field. Must be zero.
96
*/
97
__u32 pad;
98
};
99
100
/**
101
* struct drm_panfrost_wait_bo - ioctl argument for waiting for
102
* completion of the last DRM_PANFROST_SUBMIT on a BO.
103
*
104
* This is useful for cases where multiple processes might be
105
* rendering to a BO and you want to wait for all rendering to be
106
* completed.
107
*/
108
struct drm_panfrost_wait_bo {
109
/**
110
* @handle: Handle for the object to wait for.
111
*/
112
__u32 handle;
113
/**
114
* @pad: Padding, must be zero-filled.
115
*/
116
__u32 pad;
117
/**
118
* @timeout_ns: absolute number of nanoseconds to wait.
119
*/
120
__s64 timeout_ns;
121
};
122
123
/* Valid flags to pass to drm_panfrost_create_bo */
124
#define PANFROST_BO_NOEXEC 1
125
#define PANFROST_BO_HEAP 2
126
127
/**
128
* struct drm_panfrost_create_bo - ioctl argument for creating Panfrost BOs.
129
*
130
* The flags argument is a bit mask of PANFROST_BO_* flags.
131
*/
132
struct drm_panfrost_create_bo {
133
/**
134
* @size: size of shmem/BO area to create (bytes)
135
*/
136
__u32 size;
137
/**
138
* @flags: see PANFROST_BO_* flags
139
*/
140
__u32 flags;
141
/**
142
* @handle: Returned GEM handle for the BO.
143
*/
144
__u32 handle;
145
/**
146
* @pad: Padding, must be zero-filled.
147
*/
148
__u32 pad;
149
/**
150
* @offset: Returned offset for the BO in the GPU address space.
151
* This offset is private to the DRM fd and is valid for the
152
* lifetime of the GEM handle.
153
*
154
* This offset value will always be nonzero, since various HW
155
* units treat 0 specially.
156
*/
157
__u64 offset;
158
};
159
160
/**
161
* struct drm_panfrost_mmap_bo - ioctl argument for mapping Panfrost BOs.
162
*
163
* This doesn't actually perform an mmap. Instead, it returns the
164
* offset you need to use in an mmap on the DRM device node. This
165
* means that tools like valgrind end up knowing about the mapped
166
* memory.
167
*
168
* There are currently no values for the flags argument, but it may be
169
* used in a future extension.
170
*/
171
struct drm_panfrost_mmap_bo {
172
/**
173
* @handle: Handle for the object being mapped.
174
*/
175
__u32 handle;
176
/**
177
* @flags: currently not used (should be zero)
178
*/
179
__u32 flags;
180
/**
181
* @offset: offset into the drm node to use for subsequent mmap call.
182
*/
183
__u64 offset;
184
};
185
186
enum drm_panfrost_param {
187
DRM_PANFROST_PARAM_GPU_PROD_ID,
188
DRM_PANFROST_PARAM_GPU_REVISION,
189
DRM_PANFROST_PARAM_SHADER_PRESENT,
190
DRM_PANFROST_PARAM_TILER_PRESENT,
191
DRM_PANFROST_PARAM_L2_PRESENT,
192
DRM_PANFROST_PARAM_STACK_PRESENT,
193
DRM_PANFROST_PARAM_AS_PRESENT,
194
DRM_PANFROST_PARAM_JS_PRESENT,
195
DRM_PANFROST_PARAM_L2_FEATURES,
196
DRM_PANFROST_PARAM_CORE_FEATURES,
197
DRM_PANFROST_PARAM_TILER_FEATURES,
198
DRM_PANFROST_PARAM_MEM_FEATURES,
199
DRM_PANFROST_PARAM_MMU_FEATURES,
200
DRM_PANFROST_PARAM_THREAD_FEATURES,
201
DRM_PANFROST_PARAM_MAX_THREADS,
202
DRM_PANFROST_PARAM_THREAD_MAX_WORKGROUP_SZ,
203
DRM_PANFROST_PARAM_THREAD_MAX_BARRIER_SZ,
204
DRM_PANFROST_PARAM_COHERENCY_FEATURES,
205
DRM_PANFROST_PARAM_TEXTURE_FEATURES0,
206
DRM_PANFROST_PARAM_TEXTURE_FEATURES1,
207
DRM_PANFROST_PARAM_TEXTURE_FEATURES2,
208
DRM_PANFROST_PARAM_TEXTURE_FEATURES3,
209
DRM_PANFROST_PARAM_JS_FEATURES0,
210
DRM_PANFROST_PARAM_JS_FEATURES1,
211
DRM_PANFROST_PARAM_JS_FEATURES2,
212
DRM_PANFROST_PARAM_JS_FEATURES3,
213
DRM_PANFROST_PARAM_JS_FEATURES4,
214
DRM_PANFROST_PARAM_JS_FEATURES5,
215
DRM_PANFROST_PARAM_JS_FEATURES6,
216
DRM_PANFROST_PARAM_JS_FEATURES7,
217
DRM_PANFROST_PARAM_JS_FEATURES8,
218
DRM_PANFROST_PARAM_JS_FEATURES9,
219
DRM_PANFROST_PARAM_JS_FEATURES10,
220
DRM_PANFROST_PARAM_JS_FEATURES11,
221
DRM_PANFROST_PARAM_JS_FEATURES12,
222
DRM_PANFROST_PARAM_JS_FEATURES13,
223
DRM_PANFROST_PARAM_JS_FEATURES14,
224
DRM_PANFROST_PARAM_JS_FEATURES15,
225
DRM_PANFROST_PARAM_NR_CORE_GROUPS,
226
DRM_PANFROST_PARAM_THREAD_TLS_ALLOC,
227
DRM_PANFROST_PARAM_AFBC_FEATURES,
228
DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP,
229
DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP_FREQUENCY,
230
DRM_PANFROST_PARAM_ALLOWED_JM_CTX_PRIORITIES,
231
};
232
233
struct drm_panfrost_get_param {
234
__u32 param;
235
__u32 pad;
236
__u64 value;
237
};
238
239
/*
240
* Returns the offset for the BO in the GPU address space for this DRM fd.
241
* This is the same value returned by drm_panfrost_create_bo, if that was called
242
* from this DRM fd.
243
*/
244
struct drm_panfrost_get_bo_offset {
245
__u32 handle;
246
__u32 pad;
247
__u64 offset;
248
};
249
250
struct drm_panfrost_perfcnt_enable {
251
__u32 enable;
252
/*
253
* On bifrost we have 2 sets of counters, this parameter defines the
254
* one to track.
255
*/
256
__u32 counterset;
257
};
258
259
struct drm_panfrost_perfcnt_dump {
260
__u64 buf_ptr;
261
};
262
263
/* madvise provides a way to tell the kernel in case a buffers contents
264
* can be discarded under memory pressure, which is useful for userspace
265
* bo cache where we want to optimistically hold on to buffer allocate
266
* and potential mmap, but allow the pages to be discarded under memory
267
* pressure.
268
*
269
* Typical usage would involve madvise(DONTNEED) when buffer enters BO
270
* cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache.
271
* In the WILLNEED case, 'retained' indicates to userspace whether the
272
* backing pages still exist.
273
*/
274
#define PANFROST_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */
275
#define PANFROST_MADV_DONTNEED 1 /* backing pages not needed */
276
277
struct drm_panfrost_madvise {
278
__u32 handle; /* in, GEM handle */
279
__u32 madv; /* in, PANFROST_MADV_x */
280
__u32 retained; /* out, whether backing store still exists */
281
};
282
283
/**
284
* struct drm_panfrost_set_label_bo - ioctl argument for labelling Panfrost BOs.
285
*/
286
struct drm_panfrost_set_label_bo {
287
/**
288
* @handle: Handle of the buffer object to label.
289
*/
290
__u32 handle;
291
/**
292
* @pad: Must be zero.
293
*/
294
__u32 pad;
295
/**
296
* @label: User pointer to a NUL-terminated string
297
*
298
* Length cannot be greater than 4096.
299
* NULL is permitted and means clear the label.
300
*/
301
__u64 label;
302
};
303
304
/* Definitions for coredump decoding in user space */
305
#define PANFROSTDUMP_MAJOR 1
306
#define PANFROSTDUMP_MINOR 0
307
308
#define PANFROSTDUMP_MAGIC 0x464E4150 /* PANF */
309
310
#define PANFROSTDUMP_BUF_REG 0
311
#define PANFROSTDUMP_BUF_BOMAP (PANFROSTDUMP_BUF_REG + 1)
312
#define PANFROSTDUMP_BUF_BO (PANFROSTDUMP_BUF_BOMAP + 1)
313
#define PANFROSTDUMP_BUF_TRAILER (PANFROSTDUMP_BUF_BO + 1)
314
315
/*
316
* This structure is the native endianness of the dumping machine, tools can
317
* detect the endianness by looking at the value in 'magic'.
318
*/
319
struct panfrost_dump_object_header {
320
__u32 magic;
321
__u32 type;
322
__u32 file_size;
323
__u32 file_offset;
324
325
union {
326
struct {
327
__u64 jc;
328
__u32 gpu_id;
329
__u32 major;
330
__u32 minor;
331
__u64 nbos;
332
} reghdr;
333
334
struct {
335
__u32 valid;
336
__u64 iova;
337
__u32 data[2];
338
} bomap;
339
340
/*
341
* Force same size in case we want to expand the header
342
* with new fields and also keep it 512-byte aligned
343
*/
344
345
__u32 sizer[496];
346
};
347
};
348
349
/* Registers object, an array of these */
350
struct panfrost_dump_registers {
351
__u32 reg;
352
__u32 value;
353
};
354
355
enum drm_panfrost_jm_ctx_priority {
356
/**
357
* @PANFROST_JM_CTX_PRIORITY_LOW: Low priority context.
358
*/
359
PANFROST_JM_CTX_PRIORITY_LOW = 0,
360
361
/**
362
* @PANFROST_JM_CTX_PRIORITY_MEDIUM: Medium priority context.
363
*/
364
PANFROST_JM_CTX_PRIORITY_MEDIUM,
365
366
/**
367
* @PANFROST_JM_CTX_PRIORITY_HIGH: High priority context.
368
*
369
* Requires CAP_SYS_NICE or DRM_MASTER.
370
*/
371
PANFROST_JM_CTX_PRIORITY_HIGH,
372
};
373
374
struct drm_panfrost_jm_ctx_create {
375
/**
376
* @handle: Handle of the created JM context
377
*/
378
__u32 handle;
379
/**
380
* @priority: Context priority (see enum drm_panfrost_jm_ctx_priority).
381
*/
382
__u32 priority;
383
};
384
385
struct drm_panfrost_jm_ctx_destroy {
386
/**
387
* @handle: Handle of the JM context to destroy.
388
*
389
* Must be a valid context handle returned by DRM_IOCTL_PANTHOR_JM_CTX_CREATE.
390
*/
391
__u32 handle;
392
/**
393
* @pad: Padding field, must be zero.
394
*/
395
__u32 pad;
396
};
397
398
#if defined(__cplusplus)
399
}
400
#endif
401
402
#endif /* _PANFROST_DRM_H_ */
403
404