History

drm/syncobj: Add a signal ioctl (v3)

This IOCTL provides a mechanism for userspace to trigger a sync object directly. There are other ways that userspace can trigger a syncobj such as submitting a dummy batch somewhere or hanging on to a triggered sync_file and doing an import. This just provides an easy way to manually trigger the sync object without weird hacks. The motivation for this IOCTL is Vulkan fences. Vulkan lets you create a fence already in the signaled state so that you can wait on it immediatly without stalling. We could also handle this with a new create flag to ask the driver to create a syncobj that is already signaled but the IOCTL seemed a bit cleaner and more generic. v2: - Take an array of sync objects (Dave Airlie) v3: - Throw -EINVAL if pad != 0

Jason Ekstrand committed 9 years ago

Commit ffa94431 parent aa4035d4 files · +41 −0Browse files

Unified · Split

4 files
  1. drivers/gpu/drm/drm_internal.h +2 −0
  2. drivers/gpu/drm/drm_ioctl.c +2 −0
  3. drivers/gpu/drm/drm_syncobj.c +36 −0
  4. include/uapi/drm/drm.h +1 −0
drivers/gpu/drm/drm_internal.h+2−0
@@ -171,3 +171,5 @@ int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data, · 170 unmodified lines
171 struct drm_file *file_private);171 struct drm_file *file_private);
172int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,172int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
173 struct drm_file *file_private);173 struct drm_file *file_private);
174int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
175 struct drm_file *file_private);
drivers/gpu/drm/drm_ioctl.c+2−0
@@ -661,6 +661,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { · 660 unmodified lines
661 DRM_UNLOCKED|DRM_RENDER_ALLOW),661 DRM_UNLOCKED|DRM_RENDER_ALLOW),
662 DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_RESET, drm_syncobj_reset_ioctl,662 DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_RESET, drm_syncobj_reset_ioctl,
663 DRM_UNLOCKED|DRM_RENDER_ALLOW),663 DRM_UNLOCKED|DRM_RENDER_ALLOW),
664 DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL, drm_syncobj_signal_ioctl,
665 DRM_UNLOCKED|DRM_RENDER_ALLOW),
664};666};
665 667
666#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )668#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
drivers/gpu/drm/drm_syncobj.c+36−0
@@ -918,3 +918,39 @@ drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, · 917 unmodified lines
918 918
919 return 0;919 return 0;
920}920}
921
922int
923drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
924 struct drm_file *file_private)
925{
926 struct drm_syncobj_array *args = data;
927 struct drm_syncobj **syncobjs;
928 uint32_t i;
929 int ret;
930
931 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
932 return -ENODEV;
933
934 if (args->pad != 0)
935 return -EINVAL;
936
937 if (args->count_handles == 0)
938 return -EINVAL;
939
940 ret = drm_syncobj_array_find(file_private,
941 u64_to_user_ptr(args->handles),
942 args->count_handles,
943 &syncobjs);
944 if (ret < 0)
945 return ret;
946
947 for (i = 0; i < args->count_handles; i++) {
948 ret = drm_syncobj_assign_null_handle(syncobjs[i]);
949 if (ret < 0)
950 break;
951 }
952
953 drm_syncobj_array_free(syncobjs, args->count_handles);
954
955 return ret;
956}
include/uapi/drm/drm.h+1−0
@@ -861,6 +861,7 @@ extern "C" { · 860 unmodified lines
861#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle)861#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle)
862#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait)862#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait)
863#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array)863#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array)
864#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array)
864 865
865/**866/**
866 * Device specific ioctls should only be in their respective headers867 * Device specific ioctls should only be in their respective headers

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t