@@ -951,6 +951,30 @@ struct drm_xe_vm_bind_op {
951951
952952/**
953953 * 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+ *
954978 */
955979struct drm_xe_vm_bind {
956980 /** @extensions: Pointer to the first extension struct, if any */
@@ -1012,6 +1036,25 @@ struct drm_xe_vm_bind {
10121036
10131037/**
10141038 * 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+ *
10151058 */
10161059struct drm_xe_exec_queue_create {
10171060#define DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY 0
@@ -1103,6 +1146,30 @@ struct drm_xe_exec_queue_get_property {
11031146 *
11041147 * and the @flags can be:
11051148 * - %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);
11061173 */
11071174struct drm_xe_sync {
11081175 /** @extensions: Pointer to the first extension struct, if any */
@@ -1145,6 +1212,23 @@ struct drm_xe_sync {
11451212
11461213/**
11471214 * 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+ *
11481232 */
11491233struct drm_xe_exec {
11501234 /** @extensions: Pointer to the first extension struct, if any */
0 commit comments