diff mbox series

[2/2] drm/syncobj: add submit point query capability

Message ID 20190807133745.4110-3-lionel.g.landwerlin@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/syncobj: add syncobj sideband payload for threaded submission | expand

Commit Message

Lionel Landwerlin Aug. 7, 2019, 1:37 p.m. UTC
This feature was talked about by David. It allows userspace to query
the last submitted point on a timeline.

Following the previous commit it made sense to add it.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/drm_syncobj.c | 15 ++++++++++++++-
 include/uapi/drm/drm.h        |  1 +
 2 files changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index c437fb6aaf7c..ad2f5672d707 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -1291,7 +1291,8 @@  int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
 		return -EOPNOTSUPP;
 
 	if (args->selector != DRM_SYNCOBJ_TIMELINE_ARRAY_SELECTOR_SIGNALED_POINT &&
-	    args->selector != DRM_SYNCOBJ_TIMELINE_ARRAY_SELECTOR_SIDEBAND_PAYLOAD)
+	    args->selector != DRM_SYNCOBJ_TIMELINE_ARRAY_SELECTOR_SIDEBAND_PAYLOAD &&
+	    args->selector != DRM_SYNCOBJ_TIMELINE_ARRAY_SELECTOR_SUBMIT_POINT)
 		return -EINVAL;
 
 	if (args->count_handles == 0)
@@ -1346,6 +1347,18 @@  int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
 			if (ret)
 				goto error;
 			break;
+
+		case DRM_SYNCOBJ_TIMELINE_ARRAY_SELECTOR_SUBMIT_POINT:
+			fence = drm_syncobj_fence_get(syncobjs[i]);
+			chain = to_dma_fence_chain(fence);
+			point = chain ? chain->base.seqno : 0;
+			dma_fence_put(fence);
+
+			ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
+			ret = ret ? -EFAULT : 0;
+			if (ret)
+				goto error;
+			break;
 		}
 	}
 
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index dea759a36d37..3b8cdb3ffa94 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -785,6 +785,7 @@  struct drm_syncobj_timeline_array {
 	__u32 selector;
 #define DRM_SYNCOBJ_TIMELINE_ARRAY_SELECTOR_SIGNALED_POINT   (0)
 #define DRM_SYNCOBJ_TIMELINE_ARRAY_SELECTOR_SIDEBAND_PAYLOAD (1)
+#define DRM_SYNCOBJ_TIMELINE_ARRAY_SELECTOR_SUBMIT_POINT     (2)
 };