<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">The problem is that step 3 is still
      ongoing when step 4 happens, this is because same_ring is true and
      so we don't bother to wait for the last_flush.<br>
      <br>
      Alternatively we could drop same_ring and just check if last_flush
      is either signaled or emitted on the same ring as the job we
      currently search an id for. Thinking about it, this might be the
      better approach.<br>
      <br>
      Christian.<br>
      <br>
      Am 08.07.2016 um 15:11 schrieb Zhou, David(ChunMing):<br>
    </div>
    <blockquote
cite="mid:SN1PR12MB0637029E37C3343D20BDE551B43C0@SN1PR12MB0637.namprd12.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <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>What will the situation result in?<br>
        Before step3, the step2 must have completed. step4 is expected
        from step3.<br>
        <br>
        Regards,<br>
        David Zhou<br>
        <br>
        Sent from my Huawei Mobile<br>
        <br>
        -------- 原始邮件 --------<br>
        主题:[PATCH 1/3] drm/amdgpu: use one client id per ring again<br>
        发件人:Christian K鰊ig <br>
        收件人:<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
        抄送:<br>
        <br>
      </div>
      <font size="2"><span style="font-size:10pt;">
          <div class="PlainText">From: Christian König
            <a class="moz-txt-link-rfc2396E" href="mailto:christian.koenig@amd.com"><christian.koenig@amd.com></a><br>
            <br>
            Otherwise we can run into the following situation:<br>
            <br>
            1. Process A grabs ID 1 for ring 0.<br>
            2. Process B grabs ID 1 for ring 0.<br>
            3. Process A grabs ID 1 for ring 1.<br>
            4. Process A tries to reuse ID1 for ring 0 but things he
            doesn't need to flush.<br>
            <br>
            Signed-off-by: Christian König
            <a class="moz-txt-link-rfc2396E" href="mailto:christian.koenig@amd.com"><christian.koenig@amd.com></a><br>
            Cc: <a class="moz-txt-link-abbreviated" href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a><br>
            ---<br>
             drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 ++++---<br>
             1 file changed, 4 insertions(+), 3 deletions(-)<br>
            <br>
            diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
            b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            index f8615a4..7ac79d2 100644<br>
            --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            @@ -256,7 +256,7 @@ int amdgpu_vm_grab_id(struct amdgpu_vm
            *vm, struct amdgpu_ring *ring,<br>
                             if (amdgpu_vm_is_gpu_reset(adev, id))<br>
                                     continue;<br>
             <br>
            -               if (atomic64_read(&id->owner) !=
            vm->client_id)<br>
            +               if (atomic64_read(&id->owner) !=
            (vm->client_id + i))<br>
                                     continue;<br>
             <br>
                             if (job->vm_pd_addr !=
            id->pd_gpu_addr)<br>
            @@ -310,7 +310,7 @@ int amdgpu_vm_grab_id(struct amdgpu_vm
            *vm, struct amdgpu_ring *ring,<br>
                     id->pd_gpu_addr = job->vm_pd_addr;<br>
                     id->current_gpu_reset_count =
            atomic_read(&adev->gpu_reset_counter);<br>
                     list_move_tail(&id->list,
            &adev->vm_manager.ids_lru);<br>
            -       atomic64_set(&id->owner, vm->client_id);<br>
            +       atomic64_set(&id->owner, vm->client_id +
            ring->idx);<br>
                     vm->ids[ring->idx] = id;<br>
             <br>
                     job->vm_id = id - adev->vm_manager.ids;<br>
            @@ -1496,7 +1496,8 @@ int amdgpu_vm_init(struct
            amdgpu_device *adev, struct amdgpu_vm *vm)<br>
                     for (i = 0; i < AMDGPU_MAX_RINGS; ++i)<br>
                             vm->ids[i] = NULL;<br>
                     vm->va = RB_ROOT;<br>
            -       vm->client_id =
            atomic64_inc_return(&adev->vm_manager.client_counter);<br>
            +       vm->client_id =
            atomic64_add_return(AMDGPU_MAX_RINGS,<br>
            +                                          
            &adev->vm_manager.client_counter);<br>
                     spin_lock_init(&vm->status_lock);<br>
                     INIT_LIST_HEAD(&vm->invalidated);<br>
                     INIT_LIST_HEAD(&vm->cleared);<br>
            -- <br>
            2.5.0<br>
            <br>
            _______________________________________________<br>
            amd-gfx mailing list<br>
            <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
            <a moz-do-not-send="true"
              href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
          </div>
        </span></font>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>