<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<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 style="color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 12pt;">
Do you miss a file which adds <span style="display: inline !important; background-color: rgb(255, 255, 255); color: rgb(32, 31, 30); font-family: "Calibri",sans-serif; font-size: 11pt">spm_updated</span> to vm structure?</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Liu, Monk <Monk.Liu@amd.com><br>
<b>Sent:</b> Monday, April 20, 2020 3:32 PM<br>
<b>To:</b> He, Jacob <Jacob.He@amd.com>; Koenig, Christian <Christian.Koenig@amd.com><br>
<b>Cc:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Subject:</b> why we need to do infinite RLC_SPM register setting during VM flush</font>
<div> </div>
</div>
<style>
<!--
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:\7B49\7EBF}
@font-face
{font-family:Calibri}
@font-face
{}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
{color:#0563C1;
text-decoration:underline}
a:visited, span.x_MsoHyperlinkFollowed
{color:#954F72;
text-decoration:underline}
span.x_EmailStyle17
{font-family:"Calibri",sans-serif;
color:windowtext}
.x_MsoChpDefault
{font-family:"Calibri",sans-serif}
@page WordSection1
{margin:1.0in 1.25in 1.0in 1.25in}
div.x_WordSection1
{}
-->
</style>
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi Jaco & Christian</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">As titled , check below patch:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">commit 10790a09ea584cc832353a5c2a481012e5e31a13</p>
<p class="x_MsoNormal">Author: Jacob He <jacob.he@amd.com></p>
<p class="x_MsoNormal">Date: Fri Feb 28 20:24:41 2020 +0800</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> drm/amdgpu: Update SPM_VMID with the job's vmid when application reserves the vmid</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> SPM access the video memory according to SPM_VMID. It should be updated</p>
<p class="x_MsoNormal"> with the job's vmid right before the job is scheduled. SPM_VMID is a</p>
<p class="x_MsoNormal"> global resource</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> Change-Id: Id3881908960398f87e7c95026a54ff83ff826700</p>
<p class="x_MsoNormal"> Signed-off-by: Jacob He <jacob.he@amd.com></p>
<p class="x_MsoNormal"> Reviewed-by: Christian König <christian.koenig@amd.com></p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c</p>
<p class="x_MsoNormal">index 6e6fc8c..ba2236a 100644</p>
<p class="x_MsoNormal">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c</p>
<p class="x_MsoNormal">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c</p>
<p class="x_MsoNormal">@@ -1056,8 +1056,12 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,</p>
<p class="x_MsoNormal"> struct dma_fence *fence = NULL;</p>
<p class="x_MsoNormal"> bool pasid_mapping_needed = false;</p>
<p class="x_MsoNormal"> unsigned patch_offset = 0;</p>
<p class="x_MsoNormal">+ bool update_spm_vmid_needed = (job->vm && (job->vm->reserved_vmid[vmhub] != NULL));</p>
<p class="x_MsoNormal"> int r;</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">+ if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid)</p>
<p class="x_MsoNormal">+ adev->gfx.rlc.funcs->update_spm_vmid(adev, job->vmid);</p>
<p class="x_MsoNormal">+</p>
<p class="x_MsoNormal"> if (amdgpu_vmid_had_gpu_reset(adev, id)) {</p>
<p class="x_MsoNormal"> gds_switch_needed = true;</p>
<p class="x_MsoNormal"> vm_flush_needed = true;</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">this update_spm_vmid() looks an completely overkill to me, we only need to do it once for its VM …</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">in SRIOV the register reading/writing for update_spm_vmid() is now carried by KIQ thus there is too much burden on KIQ for such unnecessary jobs …</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">I want to change it to only do it once per VM, like:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c</p>
<p class="x_MsoNormal">index 6e6fc8c..ba2236a 100644</p>
<p class="x_MsoNormal">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c</p>
<p class="x_MsoNormal">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c</p>
<p class="x_MsoNormal">@@ -1056,8 +1056,12 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,</p>
<p class="x_MsoNormal"> struct dma_fence *fence = NULL;</p>
<p class="x_MsoNormal"> bool pasid_mapping_needed = false;</p>
<p class="x_MsoNormal"> unsigned patch_offset = 0;</p>
<p class="x_MsoNormal">+ bool update_spm_vmid_needed = (job->vm && (job->vm->reserved_vmid[vmhub] != NULL));</p>
<p class="x_MsoNormal"> int r;</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">+ if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid && !vm->spm_updated) {</p>
<p class="x_MsoNormal">+ adev->gfx.rlc.funcs->update_spm_vmid(adev, job->vmid);
</p>
<p class="x_MsoNormal">+ vm->spm_updated = true;</p>
<p class="x_MsoNormal">+ }</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> if (amdgpu_vmid_had_gpu_reset(adev, id)) {</p>
<p class="x_MsoNormal"> gds_switch_needed = true;</p>
<p class="x_MsoNormal"> vm_flush_needed = true;</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">what do you think ?</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">P.S.: the best way is to let GFX ring itself to do the update_spm_vmid() instead of let CPU doing it, e.g.: we put more PM4 command in VM-FLUSH packets ….
</p>
<p class="x_MsoNormal">But I prefer the simple way first like I demonstrated above
</p>
<p class="x_MsoNormal">_____________________________________</p>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black; background:white">Monk Liu|GPU Virtualization Team |</span><span style="font-size:12.0pt; color:#C82613; border:none windowtext 1.0pt; padding:0in; background:white">AMD</span></p>
<p class="x_MsoNormal"><img width="80" height="80" id="x_Picture_x0020_1" alt="sig-cloud-gpu" style="width:.8333in; height:.8333in" data-outlook-trace="F:1|T:1" src="cid:image001.png@01D61728.EAC3A7B0"></p>
<p class="x_MsoNormal"> </p>
</div>
</div>
</div>
</body>
</html>