<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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: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;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
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;}
span.EmailStyle19
{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 lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">>>> I would like to check why we need a special sequences for sriov on this pre_reset. If possible, make it the same as bare metal mode sounds better solution.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Because before VF FLR calling function would lead to register access through KIQ, which will not complete because KIQ/GFX already hang by that time<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">>>> I don't remember any register access by amdkfd_pre_reset call, please let me know if this assumption is wrong .<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please check “void pm_uninit(struct packet_manager *pm)” which is invoked inside of amdkfd_pre_reset() :
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It will call uninitialized() in kfd_kernel_queue.c file<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And then go to the path of “kq->mqd_mgr->destroy_mqd(…)”<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And finally it calls “static int <span style="background:yellow;mso-highlight:yellow">
kgd_hqd_destroy</span>(…)” in amdgpu_amdkfd_gfx_v10.c<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">539 {<o:p></o:p></p>
<p class="MsoNormal">540 struct amdgpu_device *adev = get_amdgpu_device(kgd);<o:p></o:p></p>
<p class="MsoNormal">541 enum hqd_dequeue_request_type type;<o:p></o:p></p>
<p class="MsoNormal">542 unsigned long end_jiffies;<o:p></o:p></p>
<p class="MsoNormal">543 uint32_t temp;<o:p></o:p></p>
<p class="MsoNormal">544 struct v10_compute_mqd *m = get_mqd(mqd);<o:p></o:p></p>
<p class="MsoNormal">545<o:p></o:p></p>
<p class="MsoNormal">546 #if 0<o:p></o:p></p>
<p class="MsoNormal">547 unsigned long flags;<o:p></o:p></p>
<p class="MsoNormal">548 int retry;<o:p></o:p></p>
<p class="MsoNormal">549 #endif<o:p></o:p></p>
<p class="MsoNormal">550<o:p></o:p></p>
<p class="MsoNormal">551 acquire_queue(kgd, pipe_id, queue_id); <span style="background:yellow;mso-highlight:yellow">
//this introduce register access via KIQ</span><o:p></o:p></p>
<p class="MsoNormal">552<o:p></o:p></p>
<p class="MsoNormal">553 if (m->cp_hqd_vmid == 0)<o:p></o:p></p>
<p class="MsoNormal">554 WREG32_FIELD15(GC, 0, RLC_CP_SCHEDULERS, scheduler1, 0);
<span style="background:yellow;mso-highlight:yellow">//this introduce register access via KIQ</span><o:p></o:p></p>
<p class="MsoNormal">555<o:p></o:p></p>
<p class="MsoNormal">556 switch (reset_type) {<o:p></o:p></p>
<p class="MsoNormal">557 case KFD_PREEMPT_TYPE_WAVEFRONT_DRAIN:<o:p></o:p></p>
<p class="MsoNormal">558 type = DRAIN_PIPE;<o:p></o:p></p>
<p class="MsoNormal">559 break;<o:p></o:p></p>
<p class="MsoNormal">560 case KFD_PREEMPT_TYPE_WAVEFRONT_RESET:<o:p></o:p></p>
<p class="MsoNormal">561 type = RESET_WAVES;<o:p></o:p></p>
<p class="MsoNormal">562 break;<o:p></o:p></p>
<p class="MsoNormal">563 default:<o:p></o:p></p>
<p class="MsoNormal">564 type = DRAIN_PIPE;<o:p></o:p></p>
<p class="MsoNormal">565 break;<o:p></o:p></p>
<p class="MsoNormal">566 }<o:p></o:p></p>
<p class="MsoNormal">624 WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_DEQUEUE_REQUEST), type);
<span style="background:yellow;mso-highlight:yellow">//this introduce register access via KIQ</span><o:p></o:p></p>
<p class="MsoNormal">625<o:p></o:p></p>
<p class="MsoNormal">626 end_jiffies = (utimeout * HZ / 1000) + jiffies;<o:p></o:p></p>
<p class="MsoNormal">627 while (true) {<o:p></o:p></p>
<p class="MsoNormal">628 temp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE));
<span style="background:yellow;mso-highlight:yellow">//this introduce register access via KIQ</span><o:p></o:p></p>
<p class="MsoNormal">629 if (!(temp & CP_HQD_ACTIVE__ACTIVE_MASK))<o:p></o:p></p>
<p class="MsoNormal">630 break;<o:p></o:p></p>
<p class="MsoNormal">631 if (time_after(jiffies, end_jiffies)) {<o:p></o:p></p>
<p class="MsoNormal">632 pr_err("cp queue preemption time out.\n");<o:p></o:p></p>
<p class="MsoNormal">633 release_queue(kgd);<o:p></o:p></p>
<p class="MsoNormal">634 return -ETIME;<o:p></o:p></p>
<p class="MsoNormal">635 }<o:p></o:p></p>
<p class="MsoNormal">636 usleep_range(500, 1000);<o:p></o:p></p>
<p class="MsoNormal">637 }<o:p></o:p></p>
<p class="MsoNormal">638<o:p></o:p></p>
<p class="MsoNormal">639 release_queue(kgd);<o:p></o:p></p>
<p class="MsoNormal">640 return 0;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If we use the sequence from bare-metal, all above <span style="background:yellow;mso-highlight:yellow">
highlighted</span> register access will not work because KIQ/GFX already died by that time which means the amdkfd_pre_reset() is actually not working as expected.<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;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<o:p></o:p></span></p>
<p class="MsoNormal"><img width="80" height="80" style="width:.8333in;height:.8333in" id="Picture_x0020_1" src="cid:image001.png@01D5B670.F8709DA0" 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> Liu, Shaoyun <Shaoyun.Liu@amd.com> <br>
<b>Sent:</b> Thursday, December 19, 2019 12:30 PM<br>
<b>To:</b> Liu, Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 2/2] drm/amdgpu: fix KIQ ring test fail in TDR of SRIOV<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I don't remember any register access by amdkfd_pre_reset call, please let me know if this assumption is wrong .
<br>
This function will use hiq to access CP, in case CP already hang, we might not able to get the response from hw and will got a timeout. I think kfd internal should handle this. Felix already have some comments on that.
<br>
I would like to check why we need a special sequences for sriov on this pre_reset. If possible, make it the same as bare metal mode sounds better solution.
<br>
<br>
Regards<br>
Shaoyun.liu<o:p></o:p></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="3" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> Liu, Monk <<a href="mailto:Monk.Liu@amd.com">Monk.Liu@amd.com</a>><br>
<b>Sent:</b> December 18, 2019 10:52:47 PM<br>
<b>To:</b> Liu, Shaoyun <<a href="mailto:Shaoyun.Liu@amd.com">Shaoyun.Liu@amd.com</a>>;
<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> RE: [PATCH 2/2] drm/amdgpu: fix KIQ ring test fail in TDR of SRIOV</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">Oh, by the way<br>
<br>
>>> Do we know the root cause why this function would ruin MEC ?<br>
<br>
Only we call this function right after VF FLR will ruin MEC and lead to following KIQ ring test fail , and on bare-metal it is called before gpu rest , so that's why on bare-metal we don't have this issue
<br>
<br>
But the reason we cannot call it before VF FLR on SRIOV case was already stated in this thread
<br>
<br>
Thanks<br>
_____________________________________<br>
Monk Liu|GPU Virtualization Team |AMD<br>
<br>
<br>
-----Original Message-----<br>
From: Liu, Monk <br>
Sent: Thursday, December 19, 2019 11:49 AM<br>
To: shaoyunl <<a href="mailto:shaoyun.liu@amd.com">shaoyun.liu@amd.com</a>>; <a href="mailto:amd-gfx@lists.freedesktop.org">
amd-gfx@lists.freedesktop.org</a><br>
Subject: RE: [PATCH 2/2] drm/amdgpu: fix KIQ ring test fail in TDR of SRIOV<br>
<br>
Hi Shaoyun<br>
<br>
>>> Do we know the root cause why this function would ruin MEC ? From the logic, I think this function should be called before FLR since we need to disable the user queue submission first.<br>
Right now I don't know which detail step lead to KIQ ring test fail, I totally agree with you that this func should be called before VF FLR, but we cannot do it and the reason is described in The comment:<br>
<br>
> if we do pre_reset() before VF FLR, it would go KIQ way to do register <br>
> access and stuck there, because KIQ probably won't work by that time <br>
> (e.g. you already made GFX hang)<br>
<br>
<br>
>>> I remembered the function should use hiq to communicate with HW , shouldn't use kiq to access HW registerm, has this been changed ?<br>
Tis function use WREG32/RREG32 to do register access, like all other functions in KMD, and WREG32/RREG32 will let KIQ to do the register access If we are under dynamic SRIOV mode (means we are SRIOV VF and isn't under full exclusive mode)<br>
<br>
You see that if you call this func before EVENT_5 (event 5 triggers VF FLR) then it will run under dynamic mode and KIQ will handle the register access, which is not an option Since ME/MEC probably already hang ( if we are testing quark on gfx/compute rings)<br>
<br>
Do you have a good suggestion ?<br>
<br>
thanks<br>
_____________________________________<br>
Monk Liu|GPU Virtualization Team |AMD<br>
<br>
<br>
-----Original Message-----<br>
From: amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org">amd-gfx-bounces@lists.freedesktop.org</a>> On Behalf Of shaoyunl<br>
Sent: Tuesday, December 17, 2019 11:38 PM<br>
To: <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
Subject: Re: [PATCH 2/2] drm/amdgpu: fix KIQ ring test fail in TDR of SRIOV<br>
<br>
I think amdkfd side depends on this call to stop the user queue, without this call, the user queue can submit to HW during the reset which could cause hang again ...<br>
Do we know the root cause why this function would ruin MEC ? From the logic, I think this function should be called before FLR since we need to disable the user queue submission first.<br>
I remembered the function should use hiq to communicate with HW , shouldn't use kiq to access HW registerm, has this been changed ?<br>
<br>
<br>
Regards<br>
shaoyun.liu<br>
<br>
<br>
On 2019-12-17 5:19 a.m., Monk Liu wrote:<br>
> issues:<br>
> MEC is ruined by the amdkfd_pre_reset after VF FLR done<br>
><br>
> fix:<br>
> amdkfd_pre_reset() would ruin MEC after hypervisor finished the VF <br>
> FLR, the correct sequence is do amdkfd_pre_reset before VF FLR but <br>
> there is a limitation to block this sequence:<br>
> if we do pre_reset() before VF FLR, it would go KIQ way to do register <br>
> access and stuck there, because KIQ probably won't work by that time <br>
> (e.g. you already made GFX hang)<br>
><br>
> so the best way right now is to simply remove it.<br>
><br>
> Signed-off-by: Monk Liu <<a href="mailto:Monk.Liu@amd.com">Monk.Liu@amd.com</a>><br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 --<br>
> 1 file changed, 2 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> index 605cef6..ae962b9 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> @@ -3672,8 +3672,6 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,<br>
> if (r)<br>
> return r;<br>
> <br>
> - amdgpu_amdkfd_pre_reset(adev);<br>
> -<br>
> /* Resume IP prior to SMC */<br>
> r = amdgpu_device_ip_reinit_early_sriov(adev);<br>
> if (r)<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<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%7Cee9c811452634fc2739808d7830718f6%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637121938885721447&sdata=FiqkgiUX8k5rD%2F%2FiJQU2cF1MGExO8yXEzYOoBtpdfYU%3D&reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cmonk.liu%40amd.com%7Cee9c811452634fc2739808d7830718f6%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637121938885721447&sdata=FiqkgiUX8k5rD%2F%2FiJQU2cF1MGExO8yXEzYOoBtpdfYU%3D&reserved=0</a><o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>