<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>please ignore those patches and we will give a formal patch serial later when confirm good working
<br>
</p>
<p><br>
</p>
<p>BR Monk<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>发件人:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Felix Kuehling <felix.kuehling@amd.com><br>
<b>发送时间:</b> 2017年1月25日 3:04:48<br>
<b>收件人:</b> amd-gfx@lists.freedesktop.org<br>
<b>主题:</b> Re: [PATCH] drm/amdgpu: Refine the handshake between guest and server by mailbox</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On 17-01-24 10:05 AM, Xue, Ken wrote:<br>
>> From: Christian König [<a href="mailto:deathsimple@vodafone.de">mailto:deathsimple@vodafone.de</a>]<br>
>> Sent: Tuesday, January 24, 2017 10:09 PM<br>
>> To: Xue, Ken; amd-gfx mailing list<br>
>> Cc: dl.SRDC_SW_GPUVirtualization<br>
>> Subject: Re: [PATCH] drm/amdgpu: Refine the handshake between guest and<br>
>> server by mailbox<br>
>><br>
>> Am 24.01.2017 um 13:55 schrieb Xue, Ken:<br>
>>> Add check for bit RCV_MSG_VALID of MAILBOX_CONTROL before reading<br>
>>> message and after ACK server.<br>
>>><br>
>>> Change-Id: I717a77fd90dfbdfce4dc56e978338ffc5db24fca<br>
>>> Signed-off-by: Ken Xue <Ken.Xue@amd.com><br>
>>> ---<br>
>>>   drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 20 ++++++++++++++++++++<br>
>>>   1 file changed, 20 insertions(+)<br>
>>><br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c<br>
>>> b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c<br>
>>> index d2622b6..b2c46db 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c<br>
>>> @@ -318,10 +318,25 @@ void xgpu_vi_init_golden_registers(struct<br>
>> amdgpu_device *adev)<br>
>>>   static void xgpu_vi_mailbox_send_ack(struct amdgpu_device *adev)<br>
>>>   {<br>
>>>      u32 reg;<br>
>>> +   int timeout = VI_MAILBOX_TIMEDOUT;<br>
>>> +   u32 mask = REG_FIELD_MASK(MAILBOX_CONTROL, RCV_MSG_VALID);<br>
>>><br>
>>>      reg = RREG32(mmMAILBOX_CONTROL);<br>
>>>      reg = REG_SET_FIELD(reg, MAILBOX_CONTROL, RCV_MSG_ACK, 1);<br>
>>>      WREG32(mmMAILBOX_CONTROL, reg);<br>
>>> +<br>
>>> +   /*Wait for RCV_MSG_VALID to be 0*/<br>
>>> +   reg = RREG32(mmMAILBOX_CONTROL);<br>
>>> +   while (reg & mask) {<br>
>>> +           if (timeout <= 0) {<br>
>>> +                   pr_err("RCV_MSG_VALID is not cleared\n");<br>
>>> +                   break;<br>
>>> +           }<br>
>>> +           msleep(1);<br>
>> Are you sure that you want to use msleep() here instead of mdelay() ?<br>
>><br>
>> msleep() is horrible inaccurate, e.g. depending on the definition of HZ you can<br>
>> sleep for 10ms instead of 1ms IIRC.<br>
>><br>
>> mdelay() is a busy wait, so the CPU can't do anything else useful while waiting<br>
>> but I don't think that this will hurt us here.<br>
> Thanks for your suggestion.<br>
> Currently, msleep may be a correct choice.<br>
> 1)accuracy is not necessary here<br>
> 2)the VI_MAILBOX_TIMEDOUT is 5000. if there is an issue from server side, driver may be delayed 5 seconds<br>
> 3)I followed the same style like other codes in the same file.<br>
<br>
If msleep sleeps for 10ms instead of 1ms, then your loop may end up<br>
waiting for 50s instead of 5s.<br>
<br>
If you want the total timeout to be more predictable, it may be better<br>
to compare jiffies rather than count loop iterations.<br>
<br>
Regards,<br>
  Felix<br>
<br>
><br>
><br>
> Regards,<br>
> Ken<br>
> _______________________________________________<br>
> amd-gfx mailing list<br>
> amd-gfx@lists.freedesktop.org<br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font>
</body>
</html>