Commit 2093dea3 authored by Chunming Zhou's avatar Chunming Zhou Committed by Christian König

drm/syncobj: extend syncobj query ability v3

user space needs a flexiable query ability.
So that umd can get last signaled or submitted point.
v2:
add sanitizer checking.
v3:
rebase

Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea
Signed-off-by: default avatarChunming Zhou <david1.zhou@amd.com>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Christian König <Christian.Koenig@amd.com>
Reviewed-by: default avatarLionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/series/64044/
parent be428f24
...@@ -1280,7 +1280,7 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, ...@@ -1280,7 +1280,7 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE)) if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (args->pad != 0) if (args->flags != 0)
return -EINVAL; return -EINVAL;
if (args->count_handles == 0) if (args->count_handles == 0)
...@@ -1351,7 +1351,7 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, ...@@ -1351,7 +1351,7 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE)) if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (args->pad != 0) if (args->flags & ~DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED)
return -EINVAL; return -EINVAL;
if (args->count_handles == 0) if (args->count_handles == 0)
...@@ -1372,25 +1372,32 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, ...@@ -1372,25 +1372,32 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
fence = drm_syncobj_fence_get(syncobjs[i]); fence = drm_syncobj_fence_get(syncobjs[i]);
chain = to_dma_fence_chain(fence); chain = to_dma_fence_chain(fence);
if (chain) { if (chain) {
struct dma_fence *iter, *last_signaled = NULL; struct dma_fence *iter, *last_signaled =
dma_fence_get(fence);
dma_fence_chain_for_each(iter, fence) {
if (iter->context != fence->context) { if (args->flags &
dma_fence_put(iter); DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) {
/* It is most likely that timeline has point = fence->seqno;
* unorder points. */ } else {
break; dma_fence_chain_for_each(iter, fence) {
if (iter->context != fence->context) {
dma_fence_put(iter);
/* It is most likely that timeline has
* unorder points. */
break;
}
dma_fence_put(last_signaled);
last_signaled = dma_fence_get(iter);
} }
dma_fence_put(last_signaled); point = dma_fence_is_signaled(last_signaled) ?
last_signaled = dma_fence_get(iter); last_signaled->seqno :
to_dma_fence_chain(last_signaled)->prev_seqno;
} }
point = dma_fence_is_signaled(last_signaled) ?
last_signaled->seqno :
to_dma_fence_chain(last_signaled)->prev_seqno;
dma_fence_put(last_signaled); dma_fence_put(last_signaled);
} else { } else {
point = 0; point = 0;
} }
dma_fence_put(fence);
ret = copy_to_user(&points[i], &point, sizeof(uint64_t)); ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
ret = ret ? -EFAULT : 0; ret = ret ? -EFAULT : 0;
if (ret) if (ret)
......
...@@ -778,11 +778,12 @@ struct drm_syncobj_array { ...@@ -778,11 +778,12 @@ struct drm_syncobj_array {
__u32 pad; __u32 pad;
}; };
#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */
struct drm_syncobj_timeline_array { struct drm_syncobj_timeline_array {
__u64 handles; __u64 handles;
__u64 points; __u64 points;
__u32 count_handles; __u32 count_handles;
__u32 pad; __u32 flags;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment