<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><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:Consolas;
panose-1:2 11 6 9 2 2 4 3 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;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
p.xmsonormal, li.xmsonormal, div.xmsonormal
{mso-style-name:x_msonormal;
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
p.xmsochpdefault, li.xmsochpdefault, div.xmsochpdefault
{mso-style-name:x_msochpdefault;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
span.xmsohyperlink
{mso-style-name:x_msohyperlink;
color:#0563C1;
text-decoration:underline;}
span.xmsohyperlinkfollowed
{mso-style-name:x_msohyperlinkfollowed;
color:#954F72;
text-decoration:underline;}
span.xemailstyle17
{mso-style-name:x_emailstyle17;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle23
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle27
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext">Christian<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">What we want to do is like:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">Read reg value from RLC_SPM_MC_CNTL to tmp<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">Set bits:3:0 to VMID to tmp<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">Write tmp to RLC_SPM_MC_CNTL<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">I didn’t find any PM4 packet on GFX9/10 can achieve above goal ….
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="color:windowtext">_____________________________________<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;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<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><img width="80" height="80" style="width:.8333in;height:.8333in" id="_x0000_i1028" src="cid:image001.png@01D61731.562044C0" alt="sig-cloud-gpu"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="color:windowtext">From:</span></b><span style="color:windowtext"> Christian König <ckoenig.leichtzumerken@gmail.com>
<br>
<b>Sent:</b> Monday, April 20, 2020 4:03 PM<br>
<b>To:</b> Liu, Monk <Monk.Liu@amd.com>; He, Jacob <Jacob.He@amd.com>; Koenig, Christian <Christian.Koenig@amd.com><br>
<b>Cc:</b> amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: why we need to do infinite RLC_SPM register setting during VM flush<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">I would also prefer to update the SPM VMID register using PM4 packets instead of the current handling.<br>
<br>
Regards,<br>
Christian.<br>
<br>
Am 20.04.20 um 09:50 schrieb Liu, Monk:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">I just try to explain what I want to do here, no real patch formalized yet
<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal">_____________________________________<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;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><o:p></o:p></p>
<p class="MsoNormal"><img width="80" height="80" style="width:.8333in;height:.8333in" id="Picture_x0020_1" src="cid:image001.png@01D61731.562044C0" alt="sig-cloud-gpu"><o:p></o:p></p>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> He, Jacob <a href="mailto:Jacob.He@amd.com"><Jacob.He@amd.com></a>
<br>
<b>Sent:</b> Monday, April 20, 2020 3:45 PM<br>
<b>To:</b> Liu, Monk <a href="mailto:Monk.Liu@amd.com"><Monk.Liu@amd.com></a>; Koenig, Christian
<a href="mailto:Christian.Koenig@amd.com"><Christian.Koenig@amd.com></a><br>
<b>Cc:</b> <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: why we need to do infinite RLC_SPM register setting during VM flush<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p style="margin:15.0pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#0078D7">[AMD Official Use Only - Internal Distribution Only]</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">Do you miss a file which adds </span><span style="color:#201F1E;background:white">spm_updated</span><span style="font-size:12.0pt"> to vm structure?</span><o:p></o:p></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b>From:</b> Liu, Monk <<a href="mailto:Monk.Liu@amd.com">Monk.Liu@amd.com</a>><br>
<b>Sent:</b> Monday, April 20, 2020 3:32 PM<br>
<b>To:</b> He, Jacob <<a href="mailto:Jacob.He@amd.com">Jacob.He@amd.com</a>>; Koenig, Christian <<a href="mailto:Christian.Koenig@amd.com">Christian.Koenig@amd.com</a>><br>
<b>Cc:</b> <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a> <<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>><br>
<b>Subject:</b> why we need to do infinite RLC_SPM register setting during VM flush
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="xmsonormal">Hi Jaco & Christian<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">As titled , check below patch:<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">commit 10790a09ea584cc832353a5c2a481012e5e31a13<o:p></o:p></p>
<p class="xmsonormal">Author: Jacob He <<a href="mailto:jacob.he@amd.com">jacob.he@amd.com</a>><o:p></o:p></p>
<p class="xmsonormal">Date: Fri Feb 28 20:24:41 2020 +0800<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal"> drm/amdgpu: Update SPM_VMID with the job's vmid when application reserves the vmid<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal"> SPM access the video memory according to SPM_VMID. It should be updated<o:p></o:p></p>
<p class="xmsonormal"> with the job's vmid right before the job is scheduled. SPM_VMID is a<o:p></o:p></p>
<p class="xmsonormal"> global resource<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal"> Change-Id: Id3881908960398f87e7c95026a54ff83ff826700<o:p></o:p></p>
<p class="xmsonormal"> Signed-off-by: Jacob He <<a href="mailto:jacob.he@amd.com">jacob.he@amd.com</a>><o:p></o:p></p>
<p class="xmsonormal"> Reviewed-by: Christian König <<a href="mailto:christian.koenig@amd.com">christian.koenig@amd.com</a>><o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<o:p></o:p></p>
<p class="xmsonormal">index 6e6fc8c..ba2236a 100644<o:p></o:p></p>
<p class="xmsonormal">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<o:p></o:p></p>
<p class="xmsonormal">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<o:p></o:p></p>
<p class="xmsonormal">@@ -1056,8 +1056,12 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,<o:p></o:p></p>
<p class="xmsonormal"> struct dma_fence *fence = NULL;<o:p></o:p></p>
<p class="xmsonormal"> bool pasid_mapping_needed = false;<o:p></o:p></p>
<p class="xmsonormal"> unsigned patch_offset = 0;<o:p></o:p></p>
<p class="xmsonormal">+ bool update_spm_vmid_needed = (job->vm && (job->vm->reserved_vmid[vmhub] != NULL));<o:p></o:p></p>
<p class="xmsonormal"> int r;<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">+ if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid)<o:p></o:p></p>
<p class="xmsonormal">+ adev->gfx.rlc.funcs->update_spm_vmid(adev, job->vmid);<o:p></o:p></p>
<p class="xmsonormal">+<o:p></o:p></p>
<p class="xmsonormal"> if (amdgpu_vmid_had_gpu_reset(adev, id)) {<o:p></o:p></p>
<p class="xmsonormal"> gds_switch_needed = true;<o:p></o:p></p>
<p class="xmsonormal"> vm_flush_needed = true;<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">this update_spm_vmid() looks an completely overkill to me, we only need to do it once for its VM …<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">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 …<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">I want to change it to only do it once per VM, like:<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<o:p></o:p></p>
<p class="xmsonormal">index 6e6fc8c..ba2236a 100644<o:p></o:p></p>
<p class="xmsonormal">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<o:p></o:p></p>
<p class="xmsonormal">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<o:p></o:p></p>
<p class="xmsonormal">@@ -1056,8 +1056,12 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,<o:p></o:p></p>
<p class="xmsonormal"> struct dma_fence *fence = NULL;<o:p></o:p></p>
<p class="xmsonormal"> bool pasid_mapping_needed = false;<o:p></o:p></p>
<p class="xmsonormal"> unsigned patch_offset = 0;<o:p></o:p></p>
<p class="xmsonormal">+ bool update_spm_vmid_needed = (job->vm && (job->vm->reserved_vmid[vmhub] != NULL));<o:p></o:p></p>
<p class="xmsonormal"> int r;<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">+ if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid && !vm->spm_updated) {<o:p></o:p></p>
<p class="xmsonormal">+ adev->gfx.rlc.funcs->update_spm_vmid(adev, job->vmid);
<o:p></o:p></p>
<p class="xmsonormal">+ vm->spm_updated = true;<o:p></o:p></p>
<p class="xmsonormal">+ }<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal"> if (amdgpu_vmid_had_gpu_reset(adev, id)) {<o:p></o:p></p>
<p class="xmsonormal"> gds_switch_needed = true;<o:p></o:p></p>
<p class="xmsonormal"> vm_flush_needed = true;<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">what do you think ?<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">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 ….
<o:p></o:p></p>
<p class="xmsonormal">But I prefer the simple way first like I demonstrated above
<o:p></o:p></p>
<p class="xmsonormal">_____________________________________<o:p></o:p></p>
<p class="xmsonormal"><span style="font-size:12.0pt;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><o:p></o:p></p>
<p class="xmsonormal"><img border="0" width="80" height="80" style="width:.8333in;height:.8333in" id="x_Picture_x0020_1" src="cid:image001.png@01D61731.562044C0" alt="sig-cloud-gpu"><o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>amd-gfx mailing list<o:p></o:p></pre>
<pre><a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><o:p></o:p></pre>
<pre><a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CMonk.Liu%40amd.com%7Ccb0d0dc57ea341cb4ca508d7e5013a0c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637229665742015108&sdata=PYI3Nk8sIvdixuObit%2Bu5BkE139O3auEZixRwAbkBag%3D&reserved=0">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>