@@ -951,6 +951,30 @@ struct drm_xe_vm_bind_op {
951
951
952
952
/**
953
953
* struct drm_xe_vm_bind - Input of &DRM_IOCTL_XE_VM_BIND
954
+ *
955
+ * Below is an example of a minimal use of @drm_xe_vm_bind to
956
+ * asynchronously bind the buffer `data` at address `BIND_ADDRESS` to
957
+ * illustrate `userptr`. It can be synchronized by using the example
958
+ * provided for @drm_xe_sync.
959
+ *
960
+ * .. code-block:: C
961
+ *
962
+ * data = aligned_alloc(ALIGNMENT, BO_SIZE);
963
+ * struct drm_xe_vm_bind bind = {
964
+ * .vm_id = vm,
965
+ * .num_binds = 1,
966
+ * .bind.obj = 0,
967
+ * .bind.obj_offset = to_user_pointer(data),
968
+ * .bind.range = BO_SIZE,
969
+ * .bind.addr = BIND_ADDRESS,
970
+ * .bind.op = DRM_XE_VM_BIND_OP_MAP_USERPTR,
971
+ * .bind.flags = 0,
972
+ * .num_syncs = 1,
973
+ * .syncs = &sync,
974
+ * .exec_queue_id = 0,
975
+ * };
976
+ * ioctl(fd, DRM_IOCTL_XE_VM_BIND, &bind);
977
+ *
954
978
*/
955
979
struct drm_xe_vm_bind {
956
980
/** @extensions: Pointer to the first extension struct, if any */
@@ -1012,6 +1036,25 @@ struct drm_xe_vm_bind {
1012
1036
1013
1037
/**
1014
1038
* struct drm_xe_exec_queue_create - Input of &DRM_IOCTL_XE_EXEC_QUEUE_CREATE
1039
+ *
1040
+ * The example below shows how to use @drm_xe_exec_queue_create to create
1041
+ * a simple exec_queue (no parallel submission) of class
1042
+ * &DRM_XE_ENGINE_CLASS_RENDER.
1043
+ *
1044
+ * .. code-block:: C
1045
+ *
1046
+ * struct drm_xe_engine_class_instance instance = {
1047
+ * .engine_class = DRM_XE_ENGINE_CLASS_RENDER,
1048
+ * };
1049
+ * struct drm_xe_exec_queue_create exec_queue_create = {
1050
+ * .extensions = 0,
1051
+ * .vm_id = vm,
1052
+ * .num_bb_per_exec = 1,
1053
+ * .num_eng_per_bb = 1,
1054
+ * .instances = to_user_pointer(&instance),
1055
+ * };
1056
+ * ioctl(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &exec_queue_create);
1057
+ *
1015
1058
*/
1016
1059
struct drm_xe_exec_queue_create {
1017
1060
#define DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY 0
@@ -1103,6 +1146,30 @@ struct drm_xe_exec_queue_get_property {
1103
1146
*
1104
1147
* and the @flags can be:
1105
1148
* - %DRM_XE_SYNC_FLAG_SIGNAL
1149
+ *
1150
+ * A minimal use of @drm_xe_sync looks like this:
1151
+ *
1152
+ * .. code-block:: C
1153
+ *
1154
+ * struct drm_xe_sync sync = {
1155
+ * .flags = DRM_XE_SYNC_FLAG_SIGNAL,
1156
+ * .type = DRM_XE_SYNC_TYPE_SYNCOBJ,
1157
+ * };
1158
+ * struct drm_syncobj_create syncobj_create = { 0 };
1159
+ * ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &syncobj_create);
1160
+ * sync.handle = syncobj_create.handle;
1161
+ * ...
1162
+ * use of &sync in drm_xe_exec or drm_xe_vm_bind
1163
+ * ...
1164
+ * struct drm_syncobj_wait wait = {
1165
+ * .handles = &sync.handle,
1166
+ * .timeout_nsec = INT64_MAX,
1167
+ * .count_handles = 1,
1168
+ * .flags = 0,
1169
+ * .first_signaled = 0,
1170
+ * .pad = 0,
1171
+ * };
1172
+ * ioctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);
1106
1173
*/
1107
1174
struct drm_xe_sync {
1108
1175
/** @extensions: Pointer to the first extension struct, if any */
@@ -1145,6 +1212,23 @@ struct drm_xe_sync {
1145
1212
1146
1213
/**
1147
1214
* struct drm_xe_exec - Input of &DRM_IOCTL_XE_EXEC
1215
+ *
1216
+ * This is an example to use @drm_xe_exec for execution of the object
1217
+ * at BIND_ADDRESS (see example in @drm_xe_vm_bind) by an exec_queue
1218
+ * (see example in @drm_xe_exec_queue_create). It can be synchronized
1219
+ * by using the example provided for @drm_xe_sync.
1220
+ *
1221
+ * .. code-block:: C
1222
+ *
1223
+ * struct drm_xe_exec exec = {
1224
+ * .exec_queue_id = exec_queue,
1225
+ * .syncs = &sync,
1226
+ * .num_syncs = 1,
1227
+ * .address = BIND_ADDRESS,
1228
+ * .num_batch_buffer = 1,
1229
+ * };
1230
+ * ioctl(fd, DRM_IOCTL_XE_EXEC, &exec);
1231
+ *
1148
1232
*/
1149
1233
struct drm_xe_exec {
1150
1234
/** @extensions: Pointer to the first extension struct, if any */
0 commit comments