<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Am 25.09.2018 um 11:22 schrieb Jason
Ekstrand:<br>
</div>
<blockquote type="cite"
cite="mid:CAOFGe96fXDQ8Q1piYCWhn2Z8ToOmf1JXyu+2YgUWYbMLCX7nzg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr">On Thu, Sep 20, 2018 at 6:04 AM Chunming Zhou
<<a href="mailto:david1.zhou@amd.com"
moz-do-not-send="true">david1.zhou@amd.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">points
array is one-to-one match with syncobjs array.<br>
v2:<br>
add seperate ioctl for timeline point wait, otherwise break
uapi.<br>
</blockquote>
<div><br>
</div>
<div>I think ioctl structs can be extended as long as fields
aren't re-ordered. I'm not sure on the details of this
though as I'm not a particularly experienced kernel
developer.</div>
</div>
</div>
</blockquote>
<br>
Yeah, that is correct. The problem in this particular case is that
we don't change the direct IOCTL parameter, but rather the array it
points to.<br>
<br>
We could do something like keep the existing handles array and add a
separate optional one for the timeline points. That would also drop
the need for the padding of the structure.<br>
<br>
<blockquote type="cite"
cite="mid:CAOFGe96fXDQ8Q1piYCWhn2Z8ToOmf1JXyu+2YgUWYbMLCX7nzg@mail.gmail.com">
<div dir="ltr">
<div class="gmail_quote">
<div>Another general comment (no good place to put it) is that
I think we want two kinds of waits: Wait for time point to
be completed and wait for time point to become available.
The first is the usual CPU wait for completion while the
second is for use by userspace drivers to wait until the
first moment where they can submit work which depends on a
given time point.<br>
</div>
</div>
</div>
</blockquote>
<br>
Oh, yeah that is a really good point as ell.<br>
<br>
Christian.<br>
<br>
<blockquote type="cite"
cite="mid:CAOFGe96fXDQ8Q1piYCWhn2Z8ToOmf1JXyu+2YgUWYbMLCX7nzg@mail.gmail.com">
<div dir="ltr">
<div class="gmail_quote">
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Signed-off-by: Chunming Zhou <<a
href="mailto:david1.zhou@amd.com" target="_blank"
moz-do-not-send="true">david1.zhou@amd.com</a>><br>
---<br>
drivers/gpu/drm/drm_internal.h | 2 +<br>
drivers/gpu/drm/drm_ioctl.c | 2 +<br>
drivers/gpu/drm/drm_syncobj.c | 99
+++++++++++++++++++++++++++++-----<br>
include/uapi/drm/drm.h | 14 +++++<br>
4 files changed, 103 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/drm_internal.h
b/drivers/gpu/drm/drm_internal.h<br>
index 0c4eb4a9ab31..566d44e3c782 100644<br>
--- a/drivers/gpu/drm/drm_internal.h<br>
+++ b/drivers/gpu/drm/drm_internal.h<br>
@@ -183,6 +183,8 @@ int
drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void
*data,<br>
struct drm_file
*file_private);<br>
int drm_syncobj_wait_ioctl(struct drm_device *dev, void
*data,<br>
struct drm_file *file_private);<br>
+int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev,
void *data,<br>
+ struct drm_file
*file_private);<br>
int drm_syncobj_reset_ioctl(struct drm_device *dev, void
*data,<br>
struct drm_file *file_private);<br>
int drm_syncobj_signal_ioctl(struct drm_device *dev, void
*data,<br>
diff --git a/drivers/gpu/drm/drm_ioctl.c
b/drivers/gpu/drm/drm_ioctl.c<br>
index 6b4a633b4240..c0891614f516 100644<br>
--- a/drivers/gpu/drm/drm_ioctl.c<br>
+++ b/drivers/gpu/drm/drm_ioctl.c<br>
@@ -669,6 +669,8 @@ static const struct drm_ioctl_desc
drm_ioctls[] = {<br>
DRM_UNLOCKED|DRM_RENDER_ALLOW),<br>
DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_WAIT,
drm_syncobj_wait_ioctl,<br>
DRM_UNLOCKED|DRM_RENDER_ALLOW),<br>
+ DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT,
drm_syncobj_timeline_wait_ioctl,<br>
+ DRM_UNLOCKED|DRM_RENDER_ALLOW),<br>
DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_RESET,
drm_syncobj_reset_ioctl,<br>
DRM_UNLOCKED|DRM_RENDER_ALLOW),<br>
DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL,
drm_syncobj_signal_ioctl,<br>
diff --git a/drivers/gpu/drm/drm_syncobj.c
b/drivers/gpu/drm/drm_syncobj.c<br>
index 67472bd77c83..a43de0e4616c 100644<br>
--- a/drivers/gpu/drm/drm_syncobj.c<br>
+++ b/drivers/gpu/drm/drm_syncobj.c<br>
@@ -126,13 +126,14 @@ static void
drm_syncobj_add_callback_locked(struct drm_syncobj *syncobj,<br>
}<br>
<br>
static int drm_syncobj_fence_get_or_add_callback(struct
drm_syncobj *syncobj,<br>
+ u64 point,<br>
struct
dma_fence **fence,<br>
struct
drm_syncobj_cb *cb,<br>
drm_syncobj_func_t func)<br>
{<br>
int ret;<br>
<br>
- ret = drm_syncobj_search_fence(syncobj, 0, 0,
fence);<br>
+ ret = drm_syncobj_search_fence(syncobj, point, 0,
fence);<br>
if (!ret)<br>
return 1;<br>
<br>
@@ -143,7 +144,7 @@ static int
drm_syncobj_fence_get_or_add_callback(struct drm_syncobj
*syncobj,<br>
*/<br>
if (!list_empty(&syncobj->signal_pt_list)) {<br>
spin_unlock(&syncobj->lock);<br>
- drm_syncobj_search_fence(syncobj, 0, 0,
fence);<br>
+ drm_syncobj_search_fence(syncobj, point, 0,
fence);<br>
if (*fence)<br>
return 1;<br>
spin_lock(&syncobj->lock);<br>
@@ -358,7 +359,9 @@ void drm_syncobj_replace_fence(struct
drm_syncobj *syncobj,<br>
spin_lock(&syncobj->lock);<br>
list_for_each_entry_safe(cur, tmp,
&syncobj->cb_list, node) {<br>
list_del_init(&cur->node);<br>
+ spin_unlock(&syncobj->lock);<br>
cur->func(syncobj, cur);<br>
+ spin_lock(&syncobj->lock);<br>
}<br>
spin_unlock(&syncobj->lock);<br>
}<br>
@@ -856,6 +859,7 @@ struct syncobj_wait_entry {<br>
struct dma_fence *fence;<br>
struct dma_fence_cb fence_cb;<br>
struct drm_syncobj_cb syncobj_cb;<br>
+ u64 point;<br>
};<br>
<br>
static void syncobj_wait_fence_func(struct dma_fence
*fence,<br>
@@ -873,12 +877,13 @@ static void
syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,<br>
struct syncobj_wait_entry *wait =<br>
container_of(cb, struct syncobj_wait_entry,
syncobj_cb);<br>
<br>
- drm_syncobj_search_fence(syncobj, 0, 0,
&wait->fence);<br>
+ drm_syncobj_search_fence(syncobj, wait->point, 0,
&wait->fence);<br>
<br>
wake_up_process(wait->task);<br>
}<br>
<br>
static signed long drm_syncobj_array_wait_timeout(struct
drm_syncobj **syncobjs,<br>
+ void
__user *user_points,<br>
uint32_t
count,<br>
uint32_t
flags,<br>
signed
long timeout,<br>
@@ -886,13 +891,27 @@ static signed long
drm_syncobj_array_wait_timeout(struct drm_syncobj
**syncobjs,<br>
{<br>
struct syncobj_wait_entry *entries;<br>
struct dma_fence *fence;<br>
+ uint64_t *points;<br>
signed long ret;<br>
uint32_t signaled_count, i;<br>
<br>
- entries = kcalloc(count, sizeof(*entries),
GFP_KERNEL);<br>
- if (!entries)<br>
+ points = kmalloc_array(count, sizeof(*points),
GFP_KERNEL);<br>
+ if (points == NULL)<br>
return -ENOMEM;<br>
<br>
+ if (!user_points) {<br>
+ memset(points, 0, count * sizeof(uint64_t));<br>
+ } else if (copy_from_user(points, user_points,
sizeof(uint64_t) * count)) {<br>
+ ret = -EFAULT;<br>
+ goto err_free_points;<br>
+ }<br>
+<br>
+<br>
+ entries = kcalloc(count, sizeof(*entries),
GFP_KERNEL);<br>
+ if (!entries) {<br>
+ ret = -ENOMEM;<br>
+ goto err_free_points;<br>
+ }<br>
/* Walk the list of sync objects and initialize
entries. We do<br>
* this up-front so that we can properly return
-EINVAL if there is<br>
* a syncobj with a missing fence and then never
have the chance of<br>
@@ -901,7 +920,8 @@ static signed long
drm_syncobj_array_wait_timeout(struct drm_syncobj
**syncobjs,<br>
signaled_count = 0;<br>
for (i = 0; i < count; ++i) {<br>
entries[i].task = current;<br>
- ret = drm_syncobj_search_fence(syncobjs[i],
0, 0,<br>
+ entries[i].point = points[i];<br>
+ ret = drm_syncobj_search_fence(syncobjs[i],
points[i], 0,<br>
&entries[i].fence);<br>
if (!entries[i].fence) {<br>
if (flags &
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {<br>
@@ -940,6 +960,7 @@ static signed long
drm_syncobj_array_wait_timeout(struct drm_syncobj
**syncobjs,<br>
if (flags &
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {<br>
for (i = 0; i < count; ++i) {<br>
drm_syncobj_fence_get_or_add_callback(syncobjs[i],<br>
+
entries[i].point,<br>
&entries[i].fence,<br>
&entries[i].syncobj_cb,<br>
syncobj_wait_syncobj_func);<br>
@@ -1003,6 +1024,9 @@ static signed long
drm_syncobj_array_wait_timeout(struct drm_syncobj
**syncobjs,<br>
}<br>
kfree(entries);<br>
<br>
+err_free_points:<br>
+ kfree(points);<br>
+<br>
return ret;<br>
}<br>
<br>
@@ -1041,20 +1065,33 @@ static signed long
drm_timeout_abs_to_jiffies(int64_t timeout_nsec)<br>
static int drm_syncobj_array_wait(struct drm_device *dev,<br>
struct drm_file
*file_private,<br>
struct drm_syncobj_wait
*wait,<br>
- struct drm_syncobj
**syncobjs)<br>
+ struct
drm_syncobj_timeline_wait *timeline_wait,<br>
+ struct drm_syncobj
**syncobjs, bool timeline)<br>
{<br>
- signed long timeout =
drm_timeout_abs_to_jiffies(wait->timeout_nsec);<br>
+ signed long timeout = 0;<br>
signed long ret = 0;<br>
uint32_t first = ~0;<br>
<br>
- ret = drm_syncobj_array_wait_timeout(syncobjs,<br>
-
wait->count_handles,<br>
- wait->flags,<br>
- timeout,
&first);<br>
+ if (!timeline) {<br>
+ timeout =
drm_timeout_abs_to_jiffies(wait->timeout_nsec);<br>
+ ret =
drm_syncobj_array_wait_timeout(syncobjs,<br>
+ NULL,<br>
+
wait->count_handles,<br>
+
wait->flags,<br>
+
timeout, &first);<br>
+ wait->first_signaled = first;<br>
+ } else {<br>
+ timeout =
drm_timeout_abs_to_jiffies(timeline_wait->timeout_nsec);<br>
+ ret =
drm_syncobj_array_wait_timeout(syncobjs,<br>
+
u64_to_user_ptr(timeline_wait->points),<br>
+
timeline_wait->count_handles,<br>
+
timeline_wait->flags,<br>
+
timeout, &first);<br>
+ timeline_wait->first_signaled = first;<br>
+ }<br>
if (ret < 0)<br>
return ret;<br>
<br>
- wait->first_signaled = first;<br>
if (ret == 0)<br>
return -ETIME;<br>
return 0;<br>
@@ -1142,13 +1179,47 @@ drm_syncobj_wait_ioctl(struct
drm_device *dev, void *data,<br>
return ret;<br>
<br>
ret = drm_syncobj_array_wait(dev, file_private,<br>
- args, syncobjs);<br>
+ args, NULL, syncobjs,
false);<br>
<br>
drm_syncobj_array_free(syncobjs,
args->count_handles);<br>
<br>
return ret;<br>
}<br>
<br>
+int<br>
+drm_syncobj_timeline_wait_ioctl(struct drm_device *dev,
void *data,<br>
+ struct drm_file
*file_private)<br>
+{<br>
+ struct drm_syncobj_timeline_wait *args = data;<br>
+ struct drm_syncobj **syncobjs;<br>
+ int ret = 0;<br>
+<br>
+ if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))<br>
+ return -ENODEV;<br>
+<br>
+ if (args->flags &
~(DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL |<br>
+
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT))<br>
+ return -EINVAL;<br>
+<br>
+ if (args->count_handles == 0)<br>
+ return -EINVAL;<br>
+<br>
+ ret = drm_syncobj_array_find(file_private,<br>
+
u64_to_user_ptr(args->handles),<br>
+ args->count_handles,<br>
+ &syncobjs);<br>
+ if (ret < 0)<br>
+ return ret;<br>
+<br>
+ ret = drm_syncobj_array_wait(dev, file_private,<br>
+ NULL, args, syncobjs,
true);<br>
+<br>
+ drm_syncobj_array_free(syncobjs,
args->count_handles);<br>
+<br>
+ return ret;<br>
+}<br>
+<br>
+<br>
int<br>
drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,<br>
struct drm_file *file_private)<br>
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h<br>
index cebdb2541eb7..501e86d81f47 100644<br>
--- a/include/uapi/drm/drm.h<br>
+++ b/include/uapi/drm/drm.h<br>
@@ -748,6 +748,19 @@ struct drm_syncobj_wait {<br>
__u32 pad;<br>
};<br>
<br>
+struct drm_syncobj_timeline_wait {<br>
+ __u64 handles;<br>
+ /* wait on specific timeline point for every
handles*/<br>
+ __u64 points;<br>
+ /* absolute timeout */<br>
+ __s64 timeout_nsec;<br>
+ __u32 count_handles;<br>
+ __u32 flags;<br>
+ __u32 first_signaled; /* only valid when not waiting
all */<br>
+ __u32 pad;<br>
+};<br>
+<br>
+<br>
struct drm_syncobj_array {<br>
__u64 handles;<br>
__u32 count_handles;<br>
@@ -910,6 +923,7 @@ extern "C" {<br>
#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8,
struct drm_mode_get_lease)<br>
#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9,
struct drm_mode_revoke_lease)<br>
<br>
+#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT
DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)<br>
/**<br>
* Device specific ioctls should only be in their
respective headers<br>
* The device specific ioctl range is from 0x40 to 0x9f.<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
dri-devel mailing list<br>
<a href="mailto:dri-devel@lists.freedesktop.org"
target="_blank" moz-do-not-send="true">dri-devel@lists.freedesktop.org</a><br>
<a
href="https://lists.freedesktop.org/mailman/listinfo/dri-devel"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</blockquote>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
dri-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/dri-devel">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>