<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Am 03.03.20 um 15:34 schrieb He, Jacob:<br>
    </div>
    <blockquote type="cite" cite="mid:MN2PR12MB3376C82E9294503F14F928A79BE40@MN2PR12MB3376.namprd12.prod.outlook.com">
      
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Bookman Old Style";
        panose-1:2 5 6 4 5 5 5 2 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
        {page:WordSection1;}
--></style>
      <p style="font-family:Arial;font-size:10pt;color:#0078D7;margin:15pt;" align="Left">
        [AMD Official Use Only - Internal Distribution Only]<br>
      </p>
      <br>
      <div>
        <div class="WordSection1">
          <p class="MsoNormal"><i>It would be better if we could do that
              asynchronously with a register
              <br>
              write on the ring.<br>
              <br>
            </i></p>
          <p class="MsoNormal">Sorry, I don’t get your point. Could you
            please elaborate more?
          </p>
        </div>
      </div>
    </blockquote>
    <br>
    You pass the ring from amdgpu_vm_flush() to the *_update_spm_vmid()
    functions.<br>
    <br>
    And then instead of using WREG32() you call amdgpu_ring_emit_wreg()
    to make the write asynchronously on the ring buffer using a CP
    command.<br>
    <br>
    This way we avoid a bunch of trouble when one process drops the VMID
    reservation and another one grabs it.<br>
    <br>
    Regards,<br>
    Christian.<br>
    <br>
    <blockquote type="cite" cite="mid:MN2PR12MB3376C82E9294503F14F928A79BE40@MN2PR12MB3376.namprd12.prod.outlook.com">
      <div>
        <div class="WordSection1">
          <p class="MsoNormal"><o:p> </o:p></p>
          <p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Bookman Old
              Style",serif">Thanks<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Bookman Old
              Style",serif">Jacob<o:p></o:p></span></p>
          <p class="MsoNormal"><o:p> </o:p></p>
          <div style="mso-element:para-border-div;border:none;border-top:solid
            #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal" style="border:none;padding:0in"><b>From:
              </b><a href="mailto:ckoenig.leichtzumerken@gmail.com" moz-do-not-send="true">Christian König</a><br>
              <b>Sent: </b>Tuesday, March 3, 2020 10:16 PM<br>
              <b>To: </b><a href="mailto:Jacob.He@amd.com" moz-do-not-send="true">He, Jacob</a>; <a href="mailto:amd-gfx@lists.freedesktop.org" moz-do-not-send="true">
                amd-gfx@lists.freedesktop.org</a><br>
              <b>Subject: </b>Re: [PATCH] drm/amdgpu: Update SPM_VMID
              with the job's vmid when application reserves the vmid</p>
          </div>
          <p class="MsoNormal"><o:p> </o:p></p>
          <p class="MsoNormal" style="margin-bottom:12.0pt">Am 02.03.20
            um 06:35 schrieb Jacob He:<br>
            > SPM access the video memory according to SPM_VMID. It
            should be updated<br>
            > with the job's vmid right before the job is scheduled.
            SPM_VMID is a<br>
            > global resource<br>
            ><br>
            > Change-Id: Id3881908960398f87e7c95026a54ff83ff826700<br>
            > Signed-off-by: Jacob He <a class="moz-txt-link-rfc2396E" href="mailto:jacob.he@amd.com"><jacob.he@amd.com></a><br>
            > ---<br>
            >   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++++<br>
            >   1 file changed, 4 insertions(+)<br>
            ><br>
            > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
            b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            > index c00696f3017e..c761d3a0b6e8 100644<br>
            > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            > @@ -1080,8 +1080,12 @@ int amdgpu_vm_flush(struct
            amdgpu_ring *ring, struct amdgpu_job *job,<br>
            >        struct dma_fence *fence = NULL;<br>
            >        bool pasid_mapping_needed = false;<br>
            >        unsigned patch_offset = 0;<br>
            > +     bool update_spm_vmid_needed = (job->vm
            && (job->vm->reserved_vmid[vmhub] != NULL));<br>
            >        int r;<br>
            >   <br>
            > +     if (update_spm_vmid_needed &&
            adev->gfx.rlc.funcs->update_spm_vmid)<br>
            > +            
            adev->gfx.rlc.funcs->update_spm_vmid(adev,
            job->vmid);<br>
            > +<br>
            <br>
            It would be better if we could do that asynchronously with a
            register <br>
            write on the ring.<br>
            <br>
            The alternative is that we block for the VM to be idle in <br>
            amdgpu_vm_ioctl() before unreserving the VMID.<br>
            <br>
            In other words lock the reservation object of the root PD
            and call <br>
            amdgpu_vm_wait_idle() before calling
            amdgpu_vmid_free_reserved().<br>
            <br>
            Regards,<br>
            Christian.<br>
            <br>
            >        if (amdgpu_vmid_had_gpu_reset(adev, id)) {<br>
            >                gds_switch_needed = true;<br>
            >                vm_flush_needed = true;<o:p></o:p></p>
          <p class="MsoNormal"><o:p> </o:p></p>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>