<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 08.08.2018 um 12:55 schrieb Nayan
      Deshmukh:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAFd4ddzXc7DaF_1Lz1ffpTngeAkHUX=pXnng0OagVqo95LBgGw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <div dir="ltr">Hi Christian,<br>
        <div><br>
          <div class="gmail_quote">
            <div dir="ltr">On Wed, Aug 8, 2018 at 4:20 PM Christian
              König <<a
                href="mailto:ckoenig.leichtzumerken@gmail.com"
                moz-do-not-send="true">ckoenig.leichtzumerken@gmail.com</a>>
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">Ping,
              Nayan any comments on that or can I commit it?<br>
              <br>
              This is just a stripped down version of my original
              last_scheduled <br>
              improvement patch.<br>
              <br>
            </blockquote>
            <div>I had missed the mail yesterday. I was just looking at
              the code right now. The code looks fine but I wanted to
              run it once before giving it a Rb. <br>
              <br>
            </div>
            <div>I was wondering why you stripped it down. Was there
              some problem with the previous one?<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    No, not really. But this is a bug fix and bug fixes should be as
    simple as possible.<br>
    <br>
    Improvements should come in separate patches. Didn't thought
    initially that this is actually a fix.<br>
    <br>
    BTW: Another small fix is required, looks like we need the scheduler
    correctly set for debugging even earlier.<br>
    <br>
    Christian.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFd4ddzXc7DaF_1Lz1ffpTngeAkHUX=pXnng0OagVqo95LBgGw@mail.gmail.com">
      <div dir="ltr">
        <div>
          <div class="gmail_quote">
            <div><br>
            </div>
            <div>Cheers,<br>
            </div>
            <div>Nayan <br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              Christian.<br>
              <br>
              Am 07.08.2018 um 14:54 schrieb Christian König:<br>
              > Make sure we access last_scheduled only after
              checking that there are no<br>
              > more jobs on the entity.<br>
              ><br>
              > Signed-off-by: Christian König <<a
                href="mailto:christian.koenig@amd.com" target="_blank"
                moz-do-not-send="true">christian.koenig@amd.com</a>><br>
              > ---<br>
              >   drivers/gpu/drm/scheduler/gpu_scheduler.c | 21
              +++++++++++----------<br>
              >   1 file changed, 11 insertions(+), 10 deletions(-)<br>
              ><br>
              > diff --git
              a/drivers/gpu/drm/scheduler/gpu_scheduler.c
              b/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
              > index 8ee249886473..bd7883d1b964 100644<br>
              > --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
              > +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
              > @@ -568,19 +568,20 @@ void
              drm_sched_entity_push_job(struct drm_sched_job *sched_job,<br>
              >                              struct drm_sched_entity
              *entity)<br>
              >   {<br>
              >       struct drm_sched_rq *rq = entity->rq;<br>
              > -     bool first, reschedule, idle;<br>
              > +     bool first;<br>
              >   <br>
              > -     idle = entity->last_scheduled == NULL ||<br>
              > -           
               dma_fence_is_signaled(entity->last_scheduled);<br>
              >       first =
              spsc_queue_count(&entity->job_queue) == 0;<br>
              > -     reschedule = idle && first &&
              (entity->num_rq_list > 1);<br>
              > +     if (first && (entity->num_rq_list
              > 1)) {<br>
              > +             struct dma_fence *fence;<br>
              >   <br>
              > -     if (reschedule) {<br>
              > -             rq =
              drm_sched_entity_get_free_sched(entity);<br>
              > -             spin_lock(&entity->rq_lock);<br>
              > -           
               drm_sched_rq_remove_entity(entity->rq, entity);<br>
              > -             entity->rq = rq;<br>
              > -             spin_unlock(&entity->rq_lock);<br>
              > +             fence =
              READ_ONCE(entity->last_scheduled);<br>
              > +             if (fence == NULL ||
              dma_fence_is_signaled(fence)) {<br>
              > +                     rq =
              drm_sched_entity_get_free_sched(entity);<br>
              > +                   
               spin_lock(&entity->rq_lock);<br>
              > +                   
               drm_sched_rq_remove_entity(entity->rq, entity);<br>
              > +                     entity->rq = rq;<br>
              > +                   
               spin_unlock(&entity->rq_lock);<br>
              > +             }<br>
              >       }<br>
              >   <br>
              >       sched_job->sched = entity->rq->sched;<br>
              <br>
            </blockquote>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>