<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Yeah, that change is actually incorrect
      and should be reverted.<br>
      <br>
      What we really need to do is remove dropping sched_job->s_fence
      from amd_sched_process_job() into amd_sched_job_finish() directly
      before the call to free_job().<br>
      <br>
      Regards,<br>
      Christian.<br>
      <br>
      Am 13.10.2017 um 09:24 schrieb Liu, Monk:<br>
    </div>
    <blockquote type="cite"
cite="mid:BLUPR12MB044941343D6D1A35996C7B4284480@BLUPR12MB0449.namprd12.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;"
        dir="ltr">
        <div>commit d6c650c0a8f6f671e49553725e1db541376d95f2<br>
          Author: Nicolai Hähnle <a class="moz-txt-link-rfc2396E" href="mailto:nicolai.haehnle@amd.com"><nicolai.haehnle@amd.com></a><br>
          @@ -611,6 +611,10 @@ static int amd_sched_main(void *param)<br>
           <br>
                          fence = sched->ops->run_job(sched_job);<br>
                          amd_sched_fence_scheduled(s_fence);<br>
          +<br>
          +               /* amd_sched_process_job drops the job's
          reference of the fence. */<br>
          +               sched_job->s_fence = NULL;<br>
          +<br>
                          if (fence) {<br>
                                  s_fence->parent =
          dma_fence_get(fence);<br>
                                  r = dma_fence_add_callback(fence,
          &s_fence->cb,<br>
          <br>
        </div>
        <p>Hi Nicolai</p>
        <p><br>
        </p>
        <p>with this patch, you will break
          "amdgpu_sched_hw_job_reset()"routine:</p>
        <div style="color: #d4d4d4;background-color: #1e1e1e;font-family: 'Droid Sans Mono', 'Courier New', monospace, 'Droid Sans Fallback';font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;">
<div><span style="color: #569cd6;">void</span><span style="color: #d4d4d4;"> </span>
<span style="color: #dcdcaa;">amd_sched_hw_job_reset</span><span style="color: #d4d4d4;">(</span><span style="color: #569cd6;">struct</span><span style="color: #d4d4d4;"> amd_gpu_scheduler
</span><span style="color: #d4d4d4;">*</span><span style="color: #d4d4d4;">sched)</span></div>
<div><span style="color: #d4d4d4;">{</span></div>
<div><span style="color: #d4d4d4;">    </span><span style="color: #569cd6;">struct</span><span style="color: #d4d4d4;"> amd_sched_job
</span><span style="color: #d4d4d4;">*</span><span style="color: #d4d4d4;">s_job;</span></div>


<div><span style="color: #d4d4d4;">    </span><span style="color: #dcdcaa;">spin_lock</span><span style="color: #d4d4d4;">(</span><span style="color: #d4d4d4;">&</span><span style="color: #d4d4d4;">sched-></span><span style="color: #9cdcfe;">job_list_lock</span><span style="color: #d4d4d4;">);</span></div>
<div><span style="color: #d4d4d4;">    </span><span style="color: #dcdcaa;">list_for_each_entry_reverse</span><span style="color: #d4d4d4;">(s_job,
</span><span style="color: #d4d4d4;">&</span><span style="color: #d4d4d4;">sched-></span><span style="color: #9cdcfe;">ring_mirror_list</span><span style="color: #d4d4d4;">, node) {</span></div>
<div><span style="color: #d4d4d4;">        </span><span style="color: #c586c0;">if</span><span style="color: #d4d4d4;"> (s_job-></span><span style="color: #9cdcfe;">s_fence</span><span style="color: #d4d4d4;">-></span><span style="color: #9cdcfe;">parent</span><span style="color: #d4d4d4;">
</span><span style="color: #d4d4d4;">&&</span></div>
<div><span style="color: #d4d4d4;">         </span><span style="color: #dcdcaa;">fence_remove_callback</span><span style="color: #d4d4d4;">(s_job-></span><span style="color: #9cdcfe;">s_fence</span><span style="color: #d4d4d4;">-></span><span style="color: #9cdcfe;">parent</span><span style="color: #d4d4d4;">,</span></div>
<div><span style="color: #d4d4d4;">                     </span><span style="color: #d4d4d4;">&</span><span style="color: #d4d4d4;">s_job-></span><span style="color: #9cdcfe;">s_fence</span><span style="color: #d4d4d4;">-></span><span style="color: #9cdcfe;">cb</span><span style="color: #d4d4d4;">))
 {</span></div>
<div><span style="color: #d4d4d4;">            </span><span style="color: #dcdcaa;">fence_put</span><span style="color: #d4d4d4;">(s_job-></span><span style="color: #9cdcfe;">s_fence</span><span style="color: #d4d4d4;">-></span><span style="color: #9cdcfe;">parent</span><span style="color: #d4d4d4;">);</span></div>
<div><span style="color: #d4d4d4;">            s_job-></span><span style="color: #9cdcfe;">s_fence</span><span style="color: #d4d4d4;">-></span><span style="color: #9cdcfe;">parent</span><span style="color: #d4d4d4;">
</span><span style="color: #d4d4d4;">=</span><span style="color: #d4d4d4;"> </span>
<span style="color: #569cd6;">NULL</span><span style="color: #d4d4d4;">;</span></div>
<div><span style="color: #d4d4d4;">            </span><span style="color: #dcdcaa;">atomic_dec</span><span style="color: #d4d4d4;">(</span><span style="color: #d4d4d4;">&</span><span style="color: #d4d4d4;">sched-></span><span style="color: #9cdcfe;">hw_rq_count</span><span style="color: #d4d4d4;">);</span></div>
<div><span style="color: #d4d4d4;">        }</span></div>
<div><span style="color: #d4d4d4;">    }</span></div>
<div><span style="color: #d4d4d4;">    </span><span style="color: #dcdcaa;">spin_unlock</span><span style="color: #d4d4d4;">(</span><span style="color: #d4d4d4;">&</span><span style="color: #d4d4d4;">sched-></span><span style="color: #9cdcfe;">job_list_lock</span><span style="color: #d4d4d4;">);</span></div>
<div><span style="color: #d4d4d4;">}</span></div>
</div>
        <p><br>
        </p>
        <p>see that without sched_job->s_fence, you cannot remove the
          callback from its hw fence,</p>
        <p><br>
        </p>
        <p>any idea??</p>
        <p><br>
        </p>
        <p>BR Monk<br>
        </p>
        <p><br>
        </p>
        <p><br>
        </p>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>