<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext">>></span> 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.<o:p></o:p></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">Hi Jason,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">How about adding two new wait flags?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">DRM_SYNCOBJ_WAIT_FLAGS_WAIT_COMPLETED<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">David<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="color:windowtext">From:</span></b><span style="color:windowtext"> Christian König <ckoenig.leichtzumerken@gmail.com>
<br>
<b>Sent:</b> Tuesday, September 25, 2018 5:50 PM<br>
<b>To:</b> Jason Ekstrand <jason@jlekstrand.net>; Zhou, David(ChunMing) <David1.Zhou@amd.com><br>
<b>Cc:</b> amd-gfx mailing list <amd-gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-devel@lists.freedesktop.org><br>
<b>Subject:</b> Re: [PATCH 3/6] drm: add support of syncobj timeline point wait v2<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Am 25.09.2018 um 11:22 schrieb Jason Ekstrand:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="MsoNormal">On Thu, Sep 20, 2018 at 6:04 AM Chunming Zhou <<a href="mailto:david1.zhou@amd.com">david1.zhou@amd.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">points array is one-to-one match with syncobjs array.<br>
v2:<br>
add seperate ioctl for timeline point wait, otherwise break uapi.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal"><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>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal"><br>
Oh, yeah that is a really good point as ell.<br>
<br>
Christian.<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Signed-off-by: Chunming Zhou <<a href="mailto:david1.zhou@amd.com" target="_blank">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">dri-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><o:p></o:p></p>
</blockquote>
</div>
</div>
<p class="MsoNormal"><br>
<br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>dri-devel mailing list<o:p></o:p></pre>
<pre><a href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a><o:p></o:p></pre>
<pre><a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>