<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>When you git email-send first time, there is a message-id, when
      you would send follow up patches, using --in-reply-to="message-id"
      in your comment line, then that will be in the same thread.</p>
    <p><br>
    </p>
    <p>Cheers,<br>
    </p>
    <p>Leo</p>
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 06/01/2017 09:40 AM, Xie, AlexBin
      wrote:<br>
    </div>
    <blockquote
cite="mid:MWHPR1201MB0045729996FF89B47DCD29A3F2F60@MWHPR1201MB0045.namprd12.prod.outlook.com"
      type="cite">
      <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,Arial,Helvetica,sans-serif;"
        dir="ltr">
        <p>Ok. I will add the v2 next time. I did not add the v2 in case
          this email list does not put the two patches under same
          thread...<br>
        </p>
        <br>
        <p>-Alex Bin<br>
        </p>
        <div style="color: rgb(0, 0, 0);">
          <div>
            <hr tabindex="-1" style="display:inline-block; width:98%">
            <div id="x_divRplyFwdMsg" dir="ltr"><font
                style="font-size:11pt" color="#000000" face="Calibri,
                sans-serif"><b>From:</b> Christian König
                <a class="moz-txt-link-rfc2396E" href="mailto:deathsimple@vodafone.de"><deathsimple@vodafone.de></a><br>
                <b>Sent:</b> Thursday, June 1, 2017 9:26 AM<br>
                <b>To:</b> Xie, AlexBin; <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
                <b>Subject:</b> Re: [PATCH] drm/amdgpu: Move compute vm
                bug logic to amdgpu_vm.c</font>
              <div> </div>
            </div>
          </div>
          <font size="2"><span style="font-size:10pt;">
              <div class="PlainText">Am 01.06.2017 um 01:08 schrieb Alex
                Xie:<br>
                >    In review, Christian would like to keep the
                logic<br>
                >    inside amdgpu_vm.c with a cost of slightly
                slower.<br>
                >    The loop is still optimized out with this patch.<br>
                ><br>
                > v2: remove the if statement. Now it is not slower.<br>
                ><br>
                > Signed-off-by: Alex Xie <a class="moz-txt-link-rfc2396E" href="mailto:AlexBin.Xie@amd.com"><AlexBin.Xie@amd.com></a><br>
                <br>
                When you create a v2 of a patch please note that in the
                subject line as <br>
                well.<br>
                <br>
                Either by using the "-v2" option with "git send-email"
                or by adding the <br>
                v2 manually on the subject line.<br>
                <br>
                I sometimes get mails twice because they are send to
                multiple lists I'm <br>
                registered on and that helps allot seeing that a patch
                changed and is <br>
                not just a duplicated mail.<br>
                <br>
                Anyway this version is Reviewed-by: Christian König <br>
                <a class="moz-txt-link-rfc2396E" href="mailto:christian.koeng@amd.com"><christian.koeng@amd.com></a> as well.<br>
                <br>
                Regards,<br>
                Christian.<br>
                <br>
                > ---<br>
                >   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2
                ++<br>
                >   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c   | 32
                -------------------------<br>
                >   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  5
                ----<br>
                >   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     | 38
                ++++++++++++++++++++++++++++--<br>
                >   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     |  1 +<br>
                >   5 files changed, 39 insertions(+), 39
                deletions(-)<br>
                ><br>
                > diff --git
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
                > index 89bc34a..2f1a4e9 100644<br>
                > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
                > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
                > @@ -2227,6 +2227,8 @@ int amdgpu_device_init(struct
                amdgpu_device *adev,<br>
                >   <br>
                >        adev->accel_working = true;<br>
                >   <br>
                > +     amdgpu_vm_check_compute_bug(adev);<br>
                > +<br>
                >        /* Initialize the buffer migration limit. */<br>
                >        if (amdgpu_moverate >= 0)<br>
                >                max_MBps = amdgpu_moverate;<br>
                > diff --git
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
                > index 7d95435..31aa51d 100644<br>
                > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
                > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
                > @@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct
                amdgpu_ring *ring)<br>
                >   }<br>
                >   <br>
                >   /**<br>
                > - * amdgpu_ring_check_compute_vm_bug - check
                whether this ring has compute vm bug<br>
                > - *<br>
                > - * @adev: amdgpu_device pointer<br>
                > - * @ring: amdgpu_ring structure holding ring
                information<br>
                > - */<br>
                > -static void
                amdgpu_ring_check_compute_vm_bug(struct amdgpu_device
                *adev,<br>
                > -                                     struct
                amdgpu_ring *ring)<br>
                > -{<br>
                > -     const struct amdgpu_ip_block *ip_block;<br>
                > -<br>
                > -     ring->has_compute_vm_bug = false;<br>
                > -<br>
                > -     if (ring->funcs->type !=
                AMDGPU_RING_TYPE_COMPUTE)<br>
                > -             /* only compute rings */<br>
                > -             return;<br>
                > -<br>
                > -     ip_block = amdgpu_get_ip_block(adev,
                AMD_IP_BLOCK_TYPE_GFX);<br>
                > -     if (!ip_block)<br>
                > -             return;<br>
                > -<br>
                > -     /* Compute ring has a VM bug for GFX version
                < 7.<br>
                > -           And compute ring has a VM bug for GFX 8
                MEC firmware version < 673.*/<br>
                > -     if (ip_block->version->major <= 7) {<br>
                > -             ring->has_compute_vm_bug = true;<br>
                > -     } else if (ip_block->version->major ==
                8)<br>
                > -             if (adev->gfx.mec_fw_version <
                673)<br>
                > -                     ring->has_compute_vm_bug =
                true;<br>
                > -}<br>
                > -<br>
                > -/**<br>
                >    * amdgpu_ring_init - init driver ring struct.<br>
                >    *<br>
                >    * @adev: amdgpu_device pointer<br>
                > @@ -288,8 +258,6 @@ int amdgpu_ring_init(struct
                amdgpu_device *adev, struct amdgpu_ring *ring,<br>
                >                DRM_ERROR("Failed to register
                debugfs file for rings !\n");<br>
                >        }<br>
                >   <br>
                > -     amdgpu_ring_check_compute_vm_bug(adev, ring);<br>
                > -<br>
                >        return 0;<br>
                >   }<br>
                >   <br>
                > diff --git
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
                > index 334307e..ad399c8 100644<br>
                > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
                > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
                > @@ -208,9 +208,4 @@ static inline void
                amdgpu_ring_clear_ring(struct amdgpu_ring *ring)<br>
                >   <br>
                >   }<br>
                >   <br>
                > -static inline bool
                amdgpu_ring_has_compute_vm_bug(struct amdgpu_ring *ring)<br>
                > -{<br>
                > -     return ring->has_compute_vm_bug;<br>
                > -}<br>
                > -<br>
                >   #endif<br>
                > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
                > index d4d05a8..6e32748 100644<br>
                > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
                > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
                > @@ -656,6 +656,41 @@ static int
                amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device
                *adev,<br>
                >        return r;<br>
                >   }<br>
                >   <br>
                > +/**<br>
                > + * amdgpu_vm_check_compute_bug - check whether
                asic has compute vm bug<br>
                > + *<br>
                > + * @adev: amdgpu_device pointer<br>
                > + */<br>
                > +void amdgpu_vm_check_compute_bug(struct
                amdgpu_device *adev)<br>
                > +{<br>
                > +     const struct amdgpu_ip_block *ip_block;<br>
                > +     bool has_compute_vm_bug;<br>
                > +     struct amdgpu_ring *ring;<br>
                > +     int i;<br>
                > +<br>
                > +     has_compute_vm_bug = false;<br>
                > +<br>
                > +     ip_block = amdgpu_get_ip_block(adev,
                AMD_IP_BLOCK_TYPE_GFX);<br>
                > +     if (ip_block) {<br>
                > +             /* Compute has a VM bug for GFX
                version < 7.<br>
                > +                Compute has a VM bug for GFX 8 MEC
                firmware version < 673.*/<br>
                > +             if (ip_block->version->major
                <= 7)<br>
                > +                     has_compute_vm_bug = true;<br>
                > +             else if
                (ip_block->version->major == 8)<br>
                > +                     if
                (adev->gfx.mec_fw_version < 673)<br>
                > +                             has_compute_vm_bug =
                true;<br>
                > +     }<br>
                > +<br>
                > +     for (i = 0; i < adev->num_rings; i++) {<br>
                > +             ring = adev->rings[i];<br>
                > +             if (ring->funcs->type ==
                AMDGPU_RING_TYPE_COMPUTE)<br>
                > +                     /* only compute rings */<br>
                > +                     ring->has_compute_vm_bug =
                has_compute_vm_bug;<br>
                > +             else<br>
                > +                     ring->has_compute_vm_bug =
                false;<br>
                > +     }<br>
                > +}<br>
                > +<br>
                >   bool amdgpu_vm_need_pipeline_sync(struct
                amdgpu_ring *ring,<br>
                >                                  struct amdgpu_job
                *job)<br>
                >   {<br>
                > @@ -664,8 +699,7 @@ bool
                amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,<br>
                >        struct amdgpu_vm_id_manager *id_mgr =
                &adev->vm_manager.id_mgr[vmhub];<br>
                >        struct amdgpu_vm_id *id;<br>
                >        bool gds_switch_needed;<br>
                > -     bool vm_flush_needed = job->vm_needs_flush
                ||<br>
                > -             amdgpu_ring_has_compute_vm_bug(ring);<br>
                > +     bool vm_flush_needed = job->vm_needs_flush
                || ring->has_compute_vm_bug;<br>
                >   <br>
                >        if (job->vm_id == 0)<br>
                >                return false;<br>
                > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
                > index 8309bc7..f5dba9c 100644<br>
                > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
                > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
                > @@ -245,5 +245,6 @@ void
                amdgpu_vm_adjust_size(struct amdgpu_device *adev,
                uint64_t vm_size);<br>
                >   int amdgpu_vm_ioctl(struct drm_device *dev, void
                *data, struct drm_file *filp);<br>
                >   bool amdgpu_vm_need_pipeline_sync(struct
                amdgpu_ring *ring,<br>
                >                                  struct amdgpu_job
                *job);<br>
                > +void amdgpu_vm_check_compute_bug(struct
                amdgpu_device *adev);<br>
                >   <br>
                >   #endif<br>
                <br>
                <br>
              </div>
            </span></font></div>
      </div>
      <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>