<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Hi Michel,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
The problem with -ERESTARTSYS is the same half-baked atomic state with modifications we made in the interrupted atomic check, is reused in the next retry and fails the atomic check. What we expect in the next retry is with the original atomic state. I am going
 to dig deeper and see if at DRM side we can go back to use to the original atomic state in the retry.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Regards</div>
<div id="Signature">
<div>
<div></div>
<div></div>
<div></div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px; margin-top:0; margin-bottom:0"></p>
<p style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:9pt; font-family:Arial,sans-serif; color:black"><u><b>Stylon Wang</b></u></span></p>
<p style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:9pt; font-family:Arial,sans-serif; color:black">MTS Software Development Eng.  |<b>  AMD</b><br>
Display Solution Team</span></p>
<p style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:9pt; font-family:Arial,sans-serif; color:black"><b style="color:rgb(32,31,30); font-family:Calibri,sans-serif; font-size:14.6667px; background-color:rgb(255,255,255)"><span style="margin:0px; font-size:9pt; font-family:Arial,sans-serif; color:black">O</span></b><span style="margin:0px; font-size:9pt; font-family:Arial,sans-serif; color:black; background-color:rgb(255,255,255)"> +(886)
 2-3789-3667 ext. 23667  <b>C</b> +(886) 921-897-142</span><br>
</span></p>
<p style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255)">
<b><span style="margin:0px; font-size:9pt; color:rgb(242,101,34); letter-spacing:-1.4pt">----------------------------------------------------------------------------------------------------------------------------------</span></b><b><span style="margin:0px; font-size:9pt; color:rgb(242,101,34)"></span></b></p>
<p style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:9pt; font-family:Arial,sans-serif; color:black"><span tabindex="0" style="margin:0px; padding:1px 0px; border-width:0px 0px 1px; border-bottom-style:dashed">6F, 3, YuanCyu St (NanKang Software Park) Taipei, Taiwan</span></span></p>
<p style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:9pt; font-family:Arial,sans-serif; color:black"><a href="https://www.facebook.com/AMD" target="_blank" rel="noopener noreferrer" style="margin:0px"><span style="margin:0px">Facebook</span></a> |  <a href="https://twitter.com/AMD" target="_blank" rel="noopener noreferrer" style="margin:0px"><span style="margin:0px">Twitter</span></a> |  <a href="http://www.amd.com/" target="_blank" rel="noopener noreferrer" style="margin:0px"><span style="margin:0px">amd.com</span></a></span><span style="margin:0px; font-size:10pt; font-family:Arial,sans-serif; color:black"> </span></p>
<p style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255)">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-top:0; margin-bottom:0"></p>
</div>
</div>
</div>
</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> Michel Dänzer <michel@daenzer.net><br>
<b>Sent:</b> October 26, 2021 11:51 PM<br>
<b>To:</b> Wang, Chao-kai (Stylon) <Stylon.Wang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Wentland, Harry <Harry.Wentland@amd.com>; Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; contact@emersion.fr <contact@emersion.fr>; Kazlauskas, Nicholas <Nicholas.Kazlauskas@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amd/display: Fix error handling on waiting for completion</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 2021-10-26 13:07, Stylon Wang wrote:<br>
> [Why]<br>
> In GNOME Settings->Display the switching from mirror mode to single display<br>
> occasionally causes wait_for_completion_interruptible_timeout() to return<br>
> -ERESTARTSYS and fails atomic check.<br>
> <br>
> [How]<br>
> Replace the call with wait_for_completion_timeout() since the waiting for<br>
> hw_done and flip_done completion doesn't need to worry about interruption<br>
> from signal.<br>
> <br>
> Signed-off-by: Stylon Wang <stylon.wang@amd.com><br>
> ---<br>
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--<br>
>  1 file changed, 2 insertions(+), 2 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> index 4cd64529b180..b8f4ff323de1 100644<br>
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> @@ -9844,10 +9844,10 @@ static int do_aquire_global_lock(struct drm_device *dev,<br>
>                 * Make sure all pending HW programming completed and<br>
>                 * page flips done<br>
>                 */<br>
> -             ret = wait_for_completion_interruptible_timeout(&commit->hw_done, 10*HZ);<br>
> +             ret = wait_for_completion_timeout(&commit->hw_done, 10*HZ);<br>
>  <br>
>                if (ret > 0)<br>
> -                     ret = wait_for_completion_interruptible_timeout(<br>
> +                     ret = wait_for_completion_timeout(<br>
>                                        &commit->flip_done, 10*HZ);<br>
>  <br>
>                if (ret == 0)<br>
> <br>
<br>
The *_interruptible_* variant is needed so that the display manager process can be killed while it's waiting here, which could take up to 10 seconds (per the timeout).<br>
<br>
What's the problem with -ERESTARTSYS? Either the ioctl should be restarted automatically, or if it bounces back to user space, that needs to be able to retry the ioctl while it returns -1 and errno == EINTR. drmIoctl handles this transparently.<br>
<br>
<br>
-- <br>
Earthling Michel Dänzer            |                  <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fredhat.com%2F&amp;data=04%7C01%7Cstylon.wang%40amd.com%7C251ee7aba8574015713a08d998986a5f%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637708602663589383%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=LcSFyj%2FJ9VYbNfxJQRjpiRAcurbzTbD5yUVysxzpmXs%3D&amp;reserved=0">
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fredhat.com%2F&amp;data=04%7C01%7Cstylon.wang%40amd.com%7C251ee7aba8574015713a08d998986a5f%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637708602663589383%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=LcSFyj%2FJ9VYbNfxJQRjpiRAcurbzTbD5yUVysxzpmXs%3D&amp;reserved=0</a><br>
Libre software enthusiast          |         Mesa and Xwayland developer<br>
</div>
</span></font></div>
</div>
</body>
</html>