History

drm/msm: Add VM_BIND ioctl

Add a VM_BIND ioctl for binding/unbinding buffers into a VM. This is only supported if userspace has opted in to MSM_PARAM_EN_VM_BIND.

Rob Clark committed 1 year ago

Commit 2e6a8a11 parent ecfd9fa7 files · +1205 −33Browse files

Showing the changes to include/uapi/drm (1 of 7 files). Show all

Unified · Split

include/uapi/drm/msm_drm.h+73−1
@@ -272,7 +272,10 @@ struct drm_msm_gem_submit_cmd { · 271 unmodified lines
272272 __u32 size; /* in, cmdstream size */
273273 __u32 pad;
274274 __u32 nr_relocs; /* in, number of submit_reloc's */
275− __u64 relocs; /* in, ptr to array of submit_reloc's */
275+ union {
276+ __u64 relocs; /* in, ptr to array of submit_reloc's */
277+ __u64 iova; /* cmdstream address (for VM_BIND contexts) */
278+ };
276279 };
277280
278281 /* Each buffer referenced elsewhere in the cmdstream submit (ie. the
@@ -339,7 +342,74 @@ struct drm_msm_gem_submit { · 60 unmodified lines
339342 __u32 nr_out_syncobjs; /* in, number of entries in out_syncobj. */
340343 __u32 syncobj_stride; /* in, stride of syncobj arrays. */
341344 __u32 pad; /*in, reserved for future use, always 0. */
345+};
346+
347+#define MSM_VM_BIND_OP_UNMAP 0
348+#define MSM_VM_BIND_OP_MAP 1
349+#define MSM_VM_BIND_OP_MAP_NULL 2
350+
351+#define MSM_VM_BIND_OP_DUMP 1
352+#define MSM_VM_BIND_OP_FLAGS ( \
353+ MSM_VM_BIND_OP_DUMP | \
354+ 0)
342355
356+/**
357+ * struct drm_msm_vm_bind_op - bind/unbind op to run
358+ */
359+struct drm_msm_vm_bind_op {
360+ /** @op: one of MSM_VM_BIND_OP_x */
361+ __u32 op;
362+ /** @handle: GEM object handle, MBZ for UNMAP or MAP_NULL */
363+ __u32 handle;
364+ /** @obj_offset: Offset into GEM object, MBZ for UNMAP or MAP_NULL */
365+ __u64 obj_offset;
366+ /** @iova: Address to operate on */
367+ __u64 iova;
368+ /** @range: Number of bites to to map/unmap */
369+ __u64 range;
370+ /** @flags: Bitmask of MSM_VM_BIND_OP_FLAG_x */
371+ __u32 flags;
372+ /** @pad: MBZ */
373+ __u32 pad;
374+};
375+
376+#define MSM_VM_BIND_FENCE_FD_IN 0x00000001
377+#define MSM_VM_BIND_FENCE_FD_OUT 0x00000002
378+#define MSM_VM_BIND_FLAGS ( \
379+ MSM_VM_BIND_FENCE_FD_IN | \
380+ MSM_VM_BIND_FENCE_FD_OUT | \
381+ 0)
382+
383+/**
384+ * struct drm_msm_vm_bind - Input of &DRM_IOCTL_MSM_VM_BIND
385+ */
386+struct drm_msm_vm_bind {
387+ /** @flags: in, bitmask of MSM_VM_BIND_x */
388+ __u32 flags;
389+ /** @nr_ops: the number of bind ops in this ioctl */
390+ __u32 nr_ops;
391+ /** @fence_fd: in/out fence fd (see MSM_VM_BIND_FENCE_FD_IN/OUT) */
392+ __s32 fence_fd;
393+ /** @queue_id: in, submitqueue id */
394+ __u32 queue_id;
395+ /** @in_syncobjs: in, ptr to array of drm_msm_gem_syncobj */
396+ __u64 in_syncobjs;
397+ /** @out_syncobjs: in, ptr to array of drm_msm_gem_syncobj */
398+ __u64 out_syncobjs;
399+ /** @nr_in_syncobjs: in, number of entries in in_syncobj */
400+ __u32 nr_in_syncobjs;
401+ /** @nr_out_syncobjs: in, number of entries in out_syncobj */
402+ __u32 nr_out_syncobjs;
403+ /** @syncobj_stride: in, stride of syncobj arrays */
404+ __u32 syncobj_stride;
405+ /** @op_stride: sizeof each struct drm_msm_vm_bind_op in @ops */
406+ __u32 op_stride;
407+ union {
408+ /** @op: used if num_ops == 1 */
409+ struct drm_msm_vm_bind_op op;
410+ /** @ops: userptr to array of drm_msm_vm_bind_op if num_ops > 1 */
411+ __u64 ops;
412+ };
343413 };
344414
345415 #define MSM_WAIT_FENCE_BOOST 0x00000001
@@ -435,6 +505,7 @@ struct drm_msm_submitqueue_query { · 89 unmodified lines
435505 #define DRM_MSM_SUBMITQUEUE_NEW 0x0A
436506 #define DRM_MSM_SUBMITQUEUE_CLOSE 0x0B
437507 #define DRM_MSM_SUBMITQUEUE_QUERY 0x0C
508+#define DRM_MSM_VM_BIND 0x0D
438509
439510 #define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
440511 #define DRM_IOCTL_MSM_SET_PARAM DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SET_PARAM, struct drm_msm_param)
@@ -448,6 +519,7 @@ struct drm_msm_submitqueue_query { · 7 unmodified lines
448519 #define DRM_IOCTL_MSM_SUBMITQUEUE_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_NEW, struct drm_msm_submitqueue)
449520 #define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32)
450521 #define DRM_IOCTL_MSM_SUBMITQUEUE_QUERY DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_QUERY, struct drm_msm_submitqueue_query)
522+#define DRM_IOCTL_MSM_VM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_VM_BIND, struct drm_msm_vm_bind)
451523
452524 #if defined(__cplusplus)
453525 }