<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:x="urn:schemas-microsoft-com:office:excel" 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=iso-8859-7">
<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:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:942803006;
mso-list-type:hybrid;
mso-list-template-ids:-1574110382 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1
{mso-list-id:1540163180;
mso-list-type:hybrid;
mso-list-template-ids:1221723824 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></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="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<p class="msipheadera92f4c5c" align="Left" style="margin:0"><span style="font-size:11.0pt;font-family:Arial;color:#0078D7">[AMD Official Use Only - Internal Distribution Only]</span></p>
<br>
<div class="WordSection1">
<p class="MsoPlainText">Hi Paul<o:p></o:p></p>
<ol style="margin-top:0in" start="1" type="1">
<li class="MsoPlainText" style="mso-list:l1 level1 lfo2">The 50 ms is the whole full access time reduced, not one msleep(1),
<o:p></o:p></li></ol>
<p class="MsoPlainText" style="text-indent:.5in">During amdgpu driver init, it will hit msleep(1) several times which increased the total time of full access.
<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText" style="text-indent:.5in">I load amdgpu in the guest VM and collect VF’s full access time in the host, host dmesg was listed in the below:<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:.5in">In this time, the time reduced : <span style="color:black">
0.236847 s</span><span style="color:black"> - </span><span style="color:black">0.150411 s</span><span style="color:black"> =
</span><span style="color:black;background:yellow;mso-highlight:yellow">86.436 ms</span><span style="color:black"> .<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:.5in"><span style="color:black">(The reason why it is 80+ms is that I add some code to program one register by psp. )<o:p></o:p></span></p>
<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="562" style="width:421.5pt;margin-left:41.75pt;border-collapse:collapse;border:none">
<tbody>
<tr style="height:14.5pt">
<td width="150" valign="top" style="width:112.2pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black"><o:p> </o:p></span></p>
</td>
<td width="130" nowrap="" valign="bottom" style="width:97.8pt;border:solid windowtext 1.0pt;border-left:none;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">VF Start Full access<o:p></o:p></span></p>
</td>
<td width="126" nowrap="" valign="bottom" style="width:94.5pt;border:solid windowtext 1.0pt;border-left:none;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">VF exit full access<o:p></o:p></span></p>
</td>
<td width="156" nowrap="" valign="bottom" style="width:117.0pt;border:solid windowtext 1.0pt;border-left:none;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">VF full access time<o:p></o:p></span></p>
</td>
</tr>
<tr style="height:14.5pt">
<td width="150" valign="top" style="width:112.2pt;border:solid windowtext 1.0pt;border-top:none;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">msleep(1)<o:p></o:p></span></p>
</td>
<td width="130" nowrap="" valign="bottom" style="width:97.8pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">295.9031 s<o:p></o:p></span></p>
</td>
<td width="126" nowrap="" valign="bottom" style="width:94.5pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">296.0535 s<o:p></o:p></span></p>
</td>
<td width="156" nowrap="" valign="bottom" style="width:117.0pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">0.150411 s<o:p></o:p></span></p>
</td>
</tr>
<tr style="height:14.5pt">
<td width="150" valign="top" style="width:112.2pt;border:solid windowtext 1.0pt;border-top:none;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center">usleep_range(10, 100)<span style="color:black"><o:p></o:p></span></p>
</td>
<td width="130" nowrap="" valign="bottom" style="width:97.8pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">658.1791 s<o:p></o:p></span></p>
</td>
<td width="126" nowrap="" valign="bottom" style="width:94.5pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">658.4159 s<o:p></o:p></span></p>
</td>
<td width="156" nowrap="" valign="bottom" style="width:117.0pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:14.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><span style="color:black">0.236847 s<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoPlainText"><o:p> </o:p></p>
<ol style="margin-top:0in" start="2" type="1">
<li class="MsoPlainText" style="mso-list:l1 level1 lfo2">If I only change msleep(1) to usleep_range(10, 100), the polling time will reduced from 2 seconds to 0.2 seconds,<o:p></o:p></li></ol>
<p class="MsoPlainText" style="margin-left:.5in">So I change timeout from “timeout = 2000;” to “timeout = 20000;”<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><span style="background:yellow;mso-highlight:yellow">host dmesg with udelay_range(10, 100) in amdgpu</span>:<o:p></o:p></p>
<p class="MsoPlainText"><span style="background:aqua;mso-highlight:aqua">[ 295.903102] gim info libgv: [4:0:0][amdgv_sched_enter_full_access:877] VF0 entered full access mode.</span><o:p></o:p></p>
<p class="MsoPlainText">[ 295.906661] gim info libgv: [4:0:0][amdgv_ih_iv_ring_entry_process:254] PF_VF_MSGBUF_ACK received<o:p></o:p></p>
<p class="MsoPlainText">[ 296.052903] gim info libgv: [4:0:0][amdgv_ih_iv_ring_entry_process:192] VF_PF_MSGBUF_VALID received<o:p></o:p></p>
<p class="MsoPlainText">[ 296.052910] gim info libgv: [4:0:0][amdgv_ih_iv_ring_entry_process:205] Received Event: VF0, event = 0x2<o:p></o:p></p>
<p class="MsoPlainText">[ 296.052914] gim info libgv: [4:0:0][amdgv_sched_event_queue_push_ex:193] queue event REL_GPU_INIT(0xef01) for VF0 of block(0xf0)<o:p></o:p></p>
<p class="MsoPlainText">[ 296.052934] gim info libgv: [4:0:0][amdgv_sched_process_event:1582] process event REL_GPU_INIT (0xef01) for VF0 of block (0xf0)<o:p></o:p></p>
<p class="MsoPlainText">[ 296.052944] gim info libgv: [4:0:0][navi12_gpuiov_set_mmsch_vfgate:904] mmsch mb ints disabled schedid = 4<o:p></o:p></p>
<p class="MsoPlainText">[ 296.053334] gim info libgv: [4:0:0][navi12_psp_v11_set_mb_int:632] psp mailbox disabled for VF0<o:p></o:p></p>
<p class="MsoPlainText"><span style="background:aqua;mso-highlight:aqua">[ 296.053513] gim info libgv: [4:0:0][amdgv_sched_exit_full_access:976] VF0 exited full access.</span><o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><span style="background:yellow;mso-highlight:yellow">Host demsg with msleep(1) in amdgpu</span>:<o:p></o:p></p>
<p class="MsoPlainText"><span style="background:aqua;mso-highlight:aqua">[ 658.179053] gim info libgv: [4:0:0][amdgv_sched_enter_full_access:877] VF0 entered full access mode.</span><o:p></o:p></p>
<p class="MsoPlainText">[ 658.182648] gim info libgv: [4:0:0][amdgv_ih_iv_ring_entry_process:254] PF_VF_MSGBUF_ACK received<o:p></o:p></p>
<p class="MsoPlainText">[ 658.415227] gim info libgv: [4:0:0][amdgv_ih_iv_ring_entry_process:192] VF_PF_MSGBUF_VALID received<o:p></o:p></p>
<p class="MsoPlainText">[ 658.415237] gim info libgv: [4:0:0][amdgv_ih_iv_ring_entry_process:205] Received Event: VF0, event = 0x2<o:p></o:p></p>
<p class="MsoPlainText">[ 658.415241] gim info libgv: [4:0:0][amdgv_sched_event_queue_push_ex:193] queue event REL_GPU_INIT(0xef01) for VF0 of block(0xf0)<o:p></o:p></p>
<p class="MsoPlainText">[ 658.415299] gim info libgv: [4:0:0][amdgv_sched_process_event:1582] process event REL_GPU_INIT (0xef01) for VF0 of block (0xf0)<o:p></o:p></p>
<p class="MsoPlainText">[ 658.415311] gim info libgv: [4:0:0][navi12_gpuiov_set_mmsch_vfgate:904] mmsch mb ints disabled schedid = 4<o:p></o:p></p>
<p class="MsoPlainText">[ 658.415719] gim info libgv: [4:0:0][navi12_psp_v11_set_mb_int:632] psp mailbox disabled for VF0<o:p></o:p></p>
<p class="MsoPlainText"><span style="background:aqua;mso-highlight:aqua">[ 658.415900] gim info libgv: [4:0:0][amdgv_sched_exit_full_access:976] VF0 exited full access.</span><o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">----------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal">BW<o:p></o:p></p>
<p class="MsoNormal">Pengju Zhou<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Original Message-----<o:p></o:p></p>
<p class="MsoPlainText">From: Paul Menzel <<a href="mailto:pmenzel@molgen.mpg.de">pmenzel@molgen.mpg.de</a>>
<o:p></o:p></p>
<p class="MsoPlainText">Sent: Friday, December 25, 2020 6:44 AM<o:p></o:p></p>
<p class="MsoPlainText">To: Zhou, Peng Ju <<a href="mailto:PengJu.Zhou@amd.com">PengJu.Zhou@amd.com</a>><o:p></o:p></p>
<p class="MsoPlainText">Cc: <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>; Deucher, Alexander <<a href="mailto:Alexander.Deucher@amd.com">Alexander.Deucher@amd.com</a>>; Koenig, Christian <<a href="mailto:Christian.Koenig@amd.com">Christian.Koenig@amd.com</a>><o:p></o:p></p>
<p class="MsoPlainText">Subject: Re: [PATCH] drm/amdgpu: reduce the full access time by about 50ms<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Dear Peng Ju,<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Thank you for your patch.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Am 24.12.20 um 07:04 schrieb pengzhou:<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Could you please configure your name in git:<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"> git config --global user.name "Peng Zhou" # or Peng Ju Zhou<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Also, please mention PSP in some way in the git commit message summary.
<o:p></o:p></p>
<p class="MsoPlainText">Maybe:<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> drm/amdgpu: Reduce delay in PSP command submit by …<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> The function msleep(1) can be delay to 10+ ms sometimes, which
<o:p></o:p></p>
<p class="MsoPlainText">> contributes a big delay during the full access time.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Do you have the Linux log messages with timestamps, where the delay can be seen?<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> Changing msleep(1) to usleep_range(10, 100) and it can reduce about
<o:p></o:p></p>
<p class="MsoPlainText">> 50ms delay during full access time.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">(Please wrap lines after 75 characters.)<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">`usleep_range(10, 100)` is 100 ìs which is less then 1 ms (= 1.000 ìs).
<o:p></o:p></p>
<p class="MsoPlainText">What datasheet specifies the needed delays?<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> Signed-off-by: pengzhou <<a href="mailto:PengJu.Zhou@amd.com">PengJu.Zhou@amd.com</a>><o:p></o:p></p>
<p class="MsoPlainText">> Change-Id: I151a07c55068d5c429553ef0e6668f024c0c0f3d<o:p></o:p></p>
<p class="MsoPlainText">> ---<o:p></o:p></p>
<p class="MsoPlainText">> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-<o:p></o:p></p>
<p class="MsoPlainText">> 1 file changed, 1 insertion(+), 1 deletion(-)<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c <o:p>
</o:p></p>
<p class="MsoPlainText">> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<o:p></o:p></p>
<p class="MsoPlainText">> index 523d22db094b..ef69051681cf 100644<o:p></o:p></p>
<p class="MsoPlainText">> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<o:p></o:p></p>
<p class="MsoPlainText">> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<o:p></o:p></p>
<p class="MsoPlainText">> @@ -282,7 +282,7 @@ psp_cmd_submit_buf(struct psp_context *psp,<o:p></o:p></p>
<p class="MsoPlainText">> ras_intr = amdgpu_ras_intr_triggered();<o:p></o:p></p>
<p class="MsoPlainText">> if (ras_intr)<o:p></o:p></p>
<p class="MsoPlainText">> break;<o:p></o:p></p>
<p class="MsoPlainText">> - msleep(1);<o:p></o:p></p>
<p class="MsoPlainText">> + usleep_range(10, 100);<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">With `timeout = 2000`, this was a maximum of two seconds (or even 20 seconds judging from your commit message). With your change it seems the waiting time is reduced to 0.2 seconds.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">I do not understand, how you reach 50 ms in the commit message title?
<o:p></o:p></p>
<p class="MsoPlainText">Only if the msleep would take 50 ms, which is unlikely.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> amdgpu_asic_invalidate_hdp(psp->adev, NULL);<o:p></o:p></p>
<p class="MsoPlainText">> }<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">It’s great to see these kind of optimizations, as amdgpu takes 400 ms to load on my system.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">In a followup the logging should be improved too. Maybe, print a warning, should it take longer than five milliseconds.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">I tested that it still boots on my MSI B350M MORTAR (MS-7A37) with AMD Ryzen 3 2200G, but couldn’t determine if the patch improved the boot time in anyway due to absent logging.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Kind regards,<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Paul<o:p></o:p></p>
</div>
</body>
</html>