<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">I should mentioned that this is going
      to make the find_fence() function a fair bit more complex :)<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 23/05/2019 14:35, Lionel Landwerlin
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:fc0c95ca-f500-f2e2-2011-82c43e9c18e0@intel.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div class="moz-cite-prefix">Sure</div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">-Lionel<br>
      </div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">On 23/05/2019 13:11, Zhou,
        David(ChunMing) wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:-puwqkvl1kf9u-b7x3md-nw9l5d8fjhc1-57ay9i80p3ne5zfq-v36laytxxssb-707g2imrn1o7-kvonq5nbuaig-6dlanc9wrlar1w0zlrxn0apu-qaxsb6-ac864zux0f2o3d8y3zq369i3-f7fg8.1558613478804@email.android.com">
        <meta name="Generator" content="Microsoft Exchange Server">
        <!-- converted from text -->
        <style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
        <div>can you make the parameter optional? Otherwise looks good
          to me.<br>
          <br>
          -David<br>
          <br>
          -------- Original Message --------<br>
          Subject: [PATCH 1/2] drm/syncobj: add an output syncobj
          parameter to find_fence<br>
          From: Lionel Landwerlin <br>
          To: <a class="moz-txt-link-abbreviated"
            href="mailto:intel-gfx@lists.freedesktop.org"
            moz-do-not-send="true">intel-gfx@lists.freedesktop.org</a><br>
          CC: Lionel Landwerlin ,"Koenig, Christian" ,"Zhou,
          David(ChunMing)" ,Eric Anholt ,DRI-Devel <br>
          <br>
        </div>
        <font size="2"><span style="font-size:11pt;">
            <div class="PlainText">[CAUTION: External Email]<br>
              <br>
              We would like to get both the fence & the syncobj in
              i915 rather than<br>
              doing 2 calls to drm_syncobj_find() &
              drm_syncobj_find_fence().<br>
              <br>
              Signed-off-by: Lionel Landwerlin <a
                class="moz-txt-link-rfc2396E"
                href="mailto:lionel.g.landwerlin@intel.com"
                moz-do-not-send="true"><lionel.g.landwerlin@intel.com></a><br>
              Cc: Christian Koenig <a class="moz-txt-link-rfc2396E"
                href="mailto:Christian.Koenig@amd.com"
                moz-do-not-send="true"><Christian.Koenig@amd.com></a><br>
              Cc: David(ChunMing) Zhou <a class="moz-txt-link-rfc2396E"
                href="mailto:David1.Zhou@amd.com" moz-do-not-send="true"><David1.Zhou@amd.com></a><br>
              Cc: Eric Anholt <a class="moz-txt-link-rfc2396E"
                href="mailto:eric@anholt.net" moz-do-not-send="true"><eric@anholt.net></a><br>
              CC: DRI-Devel <a class="moz-txt-link-rfc2396E"
                href="mailto:dri-devel@lists.freedesktop.org"
                moz-do-not-send="true"><dri-devel@lists.freedesktop.org></a><br>
              ---<br>
               drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c |  4 ++-<br>
               drivers/gpu/drm/drm_syncobj.c          | 45
              +++++++++++++++++---------<br>
               drivers/gpu/drm/v3d/v3d_gem.c          |  5 ++-<br>
               include/drm/drm_syncobj.h              |  1 +<br>
               4 files changed, 38 insertions(+), 17 deletions(-)<br>
              <br>
              diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
              b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
              index 2f6239b6be6f..09fde3c73a2c 100644<br>
              --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
              +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
              @@ -1124,10 +1124,11 @@ static int
              amdgpu_syncobj_lookup_and_add_to_sync(struct
              amdgpu_cs_parser *p,<br>
                                                               uint32_t
              handle, u64 point,<br>
                                                               u64
              flags)<br>
               {<br>
              +       struct drm_syncobj *syncobj;<br>
                      struct dma_fence *fence;<br>
                      int r;<br>
              <br>
              -       r = drm_syncobj_find_fence(p->filp, handle,
              point, flags, &fence);<br>
              +       r = drm_syncobj_find_fence(p->filp, handle,
              point, flags, &syncobj, &fence);<br>
                      if (r) {<br>
                              DRM_ERROR("syncobj %u failed to find fence
              @ %llu (%d)!\n",<br>
                                        handle, point, r);<br>
              @@ -1136,6 +1137,7 @@ static int
              amdgpu_syncobj_lookup_and_add_to_sync(struct
              amdgpu_cs_parser *p,<br>
              <br>
                      r = amdgpu_sync_fence(p->adev,
              &p->job->sync, fence, true);<br>
                      dma_fence_put(fence);<br>
              +       drm_syncobj_put(syncobj);<br>
              <br>
                      return r;<br>
               }<br>
              diff --git a/drivers/gpu/drm/drm_syncobj.c
              b/drivers/gpu/drm/drm_syncobj.c<br>
              index 3d400905100b..f2fd0c1fb1d3 100644<br>
              --- a/drivers/gpu/drm/drm_syncobj.c<br>
              +++ b/drivers/gpu/drm/drm_syncobj.c<br>
              @@ -222,29 +222,32 @@ static void
              drm_syncobj_assign_null_handle(struct drm_syncobj
              *syncobj)<br>
                * @handle: sync object handle to lookup.<br>
                * @point: timeline point<br>
                * @flags: DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT or not<br>
              + * @syncobj: out parameter for the syncobj<br>
                * @fence: out parameter for the fence<br>
                *<br>
                * This is just a convenience function that combines
              drm_syncobj_find() and<br>
                * drm_syncobj_fence_get().<br>
                *<br>
              - * Returns 0 on success or a negative error value on
              failure. On success @fence<br>
              - * contains a reference to the fence, which must be
              released by calling<br>
              - * dma_fence_put().<br>
              + * Returns 0 on success or a negative error value on
              failure. On<br>
              + * success @syncobj and @fence contains a reference
              respectively to<br>
              + * the syncobj and to the fence, which must be released
              by calling<br>
              + * respectively drm_syncobj_put() and dma_fence_put().<br>
                */<br>
               int drm_syncobj_find_fence(struct drm_file *file_private,<br>
                                         u32 handle, u64 point, u64
              flags,<br>
              +                          struct drm_syncobj **syncobj,<br>
                                         struct dma_fence **fence)<br>
               {<br>
              -       struct drm_syncobj *syncobj =
              drm_syncobj_find(file_private, handle);<br>
                      struct syncobj_wait_entry wait;<br>
                      u64 timeout =
              nsecs_to_jiffies64(DRM_SYNCOBJ_WAIT_FOR_SUBMIT_TIMEOUT);<br>
                      int ret;<br>
              <br>
              -       if (!syncobj)<br>
              +       *syncobj = drm_syncobj_find(file_private, handle);<br>
              +<br>
              +       if (!(*syncobj))<br>
                              return -ENOENT;<br>
              <br>
              -       *fence = drm_syncobj_fence_get(syncobj);<br>
              -       drm_syncobj_put(syncobj);<br>
              +       *fence = drm_syncobj_fence_get(*syncobj);<br>
              <br>
                      if (*fence) {<br>
                              ret = dma_fence_chain_find_seqno(fence,
              point);<br>
              @@ -255,13 +258,15 @@ int drm_syncobj_find_fence(struct
              drm_file *file_private,<br>
                              ret = -EINVAL;<br>
                      }<br>
              <br>
              -       if (!(flags &
              DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT))<br>
              +       if (!(flags &
              DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT)) {<br>
              +               drm_syncobj_put(*syncobj);<br>
                              return ret;<br>
              +       }<br>
              <br>
                      memset(&wait, 0, sizeof(wait));<br>
                      wait.task = current;<br>
                      wait.point = point;<br>
              -       drm_syncobj_fence_add_wait(syncobj, &wait);<br>
              +       drm_syncobj_fence_add_wait(*syncobj, &wait);<br>
              <br>
                      do {<br>
                              set_current_state(TASK_INTERRUPTIBLE);<br>
              @@ -286,7 +291,10 @@ int drm_syncobj_find_fence(struct
              drm_file *file_private,<br>
                      *fence = wait.fence;<br>
              <br>
                      if (wait.node.next)<br>
              -               drm_syncobj_remove_wait(syncobj,
              &wait);<br>
              +               drm_syncobj_remove_wait(*syncobj,
              &wait);<br>
              +<br>
              +       if (ret)<br>
              +               drm_syncobj_put(*syncobj);<br>
              <br>
                      return ret;<br>
               }<br>
              @@ -531,6 +539,7 @@ static int
              drm_syncobj_export_sync_file(struct drm_file
              *file_private,<br>
                                                      int handle, int
              *p_fd)<br>
               {<br>
                      int ret;<br>
              +       struct drm_syncobj *syncobj;<br>
                      struct dma_fence *fence;<br>
                      struct sync_file *sync_file;<br>
                      int fd = get_unused_fd_flags(O_CLOEXEC);<br>
              @@ -538,13 +547,14 @@ static int
              drm_syncobj_export_sync_file(struct drm_file
              *file_private,<br>
                      if (fd < 0)<br>
                              return fd;<br>
              <br>
              -       ret = drm_syncobj_find_fence(file_private, handle,
              0, 0, &fence);<br>
              +       ret = drm_syncobj_find_fence(file_private, handle,
              0, 0, &syncobj, &fence);<br>
                      if (ret)<br>
                              goto err_put_fd;<br>
              <br>
                      sync_file = sync_file_create(fence);<br>
              <br>
                      dma_fence_put(fence);<br>
              +       drm_syncobj_put(syncobj);<br>
              <br>
                      if (!sync_file) {<br>
                              ret = -EINVAL;<br>
              @@ -682,7 +692,8 @@ drm_syncobj_fd_to_handle_ioctl(struct
              drm_device *dev, void *data,<br>
               static int drm_syncobj_transfer_to_timeline(struct
              drm_file *file_private,<br>
                                                          struct
              drm_syncobj_transfer *args)<br>
               {<br>
              -       struct drm_syncobj *timeline_syncobj = NULL;<br>
              +       struct drm_syncobj *timeline_syncobj;<br>
              +       struct drm_syncobj *src_syncobj;<br>
                      struct dma_fence *fence;<br>
                      struct dma_fence_chain *chain;<br>
                      int ret;<br>
              @@ -693,7 +704,7 @@ static int
              drm_syncobj_transfer_to_timeline(struct drm_file
              *file_private,<br>
                      }<br>
                      ret = drm_syncobj_find_fence(file_private,
              args->src_handle,<br>
                                                   args->src_point,
              args->flags,<br>
              -                                    &fence);<br>
              +                                    &src_syncobj,
              &fence);<br>
                      if (ret)<br>
                              goto err;<br>
                      chain = kzalloc(sizeof(struct dma_fence_chain),
              GFP_KERNEL);<br>
              @@ -704,6 +715,7 @@ static int
              drm_syncobj_transfer_to_timeline(struct drm_file
              *file_private,<br>
                      drm_syncobj_add_point(timeline_syncobj, chain,
              fence, args->dst_point);<br>
               err1:<br>
                      dma_fence_put(fence);<br>
              +       drm_syncobj_put(src_syncobj);<br>
               err:<br>
                      drm_syncobj_put(timeline_syncobj);<br>
              <br>
              @@ -714,7 +726,8 @@ static int<br>
               drm_syncobj_transfer_to_binary(struct drm_file
              *file_private,<br>
                                             struct drm_syncobj_transfer
              *args)<br>
               {<br>
              -       struct drm_syncobj *binary_syncobj = NULL;<br>
              +       struct drm_syncobj *binary_syncobj;<br>
              +       struct drm_syncobj *src_syncobj;<br>
                      struct dma_fence *fence;<br>
                      int ret;<br>
              <br>
              @@ -722,11 +735,13 @@
              drm_syncobj_transfer_to_binary(struct drm_file
              *file_private,<br>
                      if (!binary_syncobj)<br>
                              return -ENOENT;<br>
                      ret = drm_syncobj_find_fence(file_private,
              args->src_handle,<br>
              -                                    args->src_point,
              args->flags, &fence);<br>
              +                                    args->src_point,
              args->flags,<br>
              +                                    &src_syncobj,
              &fence);<br>
                      if (ret)<br>
                              goto err;<br>
                      drm_syncobj_replace_fence(binary_syncobj, fence);<br>
                      dma_fence_put(fence);<br>
              +       drm_syncobj_put(src_syncobj);<br>
               err:<br>
                      drm_syncobj_put(binary_syncobj);<br>
              <br>
              diff --git a/drivers/gpu/drm/v3d/v3d_gem.c
              b/drivers/gpu/drm/v3d/v3d_gem.c<br>
              index 27e0f87075d9..26bd3a2e39ca 100644<br>
              --- a/drivers/gpu/drm/v3d/v3d_gem.c<br>
              +++ b/drivers/gpu/drm/v3d/v3d_gem.c<br>
              @@ -431,6 +431,7 @@ v3d_job_init(struct v3d_dev *v3d,
              struct drm_file *file_priv,<br>
                           struct v3d_job *job, void (*free)(struct kref
              *ref),<br>
                           u32 in_sync)<br>
               {<br>
              +       struct drm_syncobj *in_syncobj = NULL;<br>
                      struct dma_fence *in_fence = NULL;<br>
                      int ret;<br>
              <br>
              @@ -443,10 +444,12 @@ v3d_job_init(struct v3d_dev *v3d,
              struct drm_file *file_priv,<br>
              <br>
                      xa_init_flags(&job->deps, XA_FLAGS_ALLOC);<br>
              <br>
              -       ret = drm_syncobj_find_fence(file_priv, in_sync,
              0, 0, &in_fence);<br>
              +       ret = drm_syncobj_find_fence(file_priv, in_sync,
              0, 0, &syncobj, &in_fence);<br>
                      if (ret == -EINVAL)<br>
                              goto fail;<br>
              <br>
              +       drm_syncobj_put(in_sync);<br>
              +<br>
                      ret = drm_gem_fence_array_add(&job->deps,
              in_fence);<br>
                      if (ret)<br>
                              goto fail;<br>
              diff --git a/include/drm/drm_syncobj.h
              b/include/drm/drm_syncobj.h<br>
              index 6cf7243a1dc5..08eca690f783 100644<br>
              --- a/include/drm/drm_syncobj.h<br>
              +++ b/include/drm/drm_syncobj.h<br>
              @@ -121,6 +121,7 @@ void drm_syncobj_replace_fence(struct
              drm_syncobj *syncobj,<br>
                                             struct dma_fence *fence);<br>
               int drm_syncobj_find_fence(struct drm_file *file_private,<br>
                                         u32 handle, u64 point, u64
              flags,<br>
              +                          struct drm_syncobj **syncobj,<br>
                                         struct dma_fence **fence);<br>
               void drm_syncobj_free(struct kref *kref);<br>
               int drm_syncobj_create(struct drm_syncobj **out_syncobj,
              uint32_t flags,<br>
              --<br>
              2.21.0.392.gf8f6787159e<br>
              <br>
            </div>
          </span></font> </blockquote>
      <p><br>
      </p>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Intel-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/intel-gfx">https://lists.freedesktop.org/mailman/listinfo/intel-gfx</a></pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>