<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=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Cambria;
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Intel Clear";
        panose-1:2 11 6 4 2 2 3 2 2 4;}
@font-face
        {font-family:"Microsoft Yi Baiti";
        panose-1:3 0 5 0 0 0 0 0 0 0;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:宋体;}
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.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:宋体;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:宋体;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Intel Clear","sans-serif";
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Intel Clear","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
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="ZH-CN" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><a name="_MailEndCompose"><span lang="EN-US" style="font-family:"Calibri","sans-serif"">Hi Wilson,<o:p></o:p></span></a></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri","sans-serif"">We still need this patch</span><span lang="EN-US" style="font-family:"Calibri","sans-serif"">. Seems
</span><span lang="EN-US" style="font-family:"Calibri","sans-serif"">54632abe8ca3 ("drm/i915: Fix oops caused by fbdev initialization<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri","sans-serif"">failure") as well as 366e39b4d2c5 ("drm/i915: Tear down fbdev if<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri","sans-serif"">initialization fails") this 2 patches can’t cover this case. It’s access ifbdev->fb before the initialization<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri","sans-serif"">finished, but not initialization failed. If don’t have any other patches or code update relative, it may still have in 4.5.</span><span lang="EN-US" style="font-family:"Calibri","sans-serif""><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D">add info NULL check should be better, it is also initialized in the async queue<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>       info = ifbdev->helper.fbdev;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">> +     if (info == NULL)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">> +            return false;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>       if (!info->screen_base)<br>
<br>
</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:#1F497D">BRs,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:#1F497D">Weinan Li</span><span lang="EN-US" style="font-size:10.0pt;color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span lang="EN-US" style="font-size:11.0pt;font-family:"Cambria","serif";color:#1F497D"><o:p> </o:p></span></i></b></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Li, Weinan Z
<br>
<b>Sent:</b> Thursday, February 04, 2016 10:34 AM<br>
<b>To:</b> 'gustav.fagerlind@gmail.com'; Lukas Wunner<br>
<b>Cc:</b> Chris Wilson; <a href="mailto:intel-gfx@lists.freedesktop.org">intel-gfx@lists.freedesktop.org</a><br>
<b>Subject:</b> RE: [Intel-gfx] [PATCH] drm/i915: Protect fbdev across slow or failed initialisation<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D">Thanks for your quick response.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D">Yes it is not easily be reproduced in native. In  iVGT we startup several VMs  simultaneously, it can be reproduced in several cycles, upon
 1/10 fail rate.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D">Need to use GUI mode but not text mode to reproduce this issue.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:#1F497D">BRs,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:#1F497D">Weinan Li<o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span lang="EN-US" style="font-size:11.0pt;font-family:"Cambria","serif";color:#1F497D"><o:p> </o:p></span></i></b></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Intel Clear","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Gustav Fägerlind [</span><span lang="EN-US"><a href="mailto:gustav.fagerlind@gmail.com"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">mailto:gustav.fagerlind@gmail.com</span></a></span><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">]
<br>
<b>Sent:</b> Thursday, February 04, 2016 1:08 AM<br>
<b>To:</b> Lukas Wunner<br>
<b>Cc:</b> Chris Wilson; </span><span lang="EN-US"><a href="mailto:intel-gfx@lists.freedesktop.org"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">intel-gfx@lists.freedesktop.org</span></a></span><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">;
 Li, Weinan Z<br>
<b>Subject:</b> Re: [Intel-gfx] [PATCH] drm/i915: Protect fbdev across slow or failed initialisation<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Cool, thank you.<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US">I dont believe I can easily reproduce it, it has only happend few times (and i reboot my lappy >2 times per day).<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US"><br>
//<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US">Gustav<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">2016-02-03 14:25 GMT+01:00 Lukas Wunner <<a href="mailto:lukas@wunner.de" target="_blank">lukas@wunner.de</a>>:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Hi,<br>
<br>
On Wed, Feb 03, 2016 at 09:17:37AM +0000, Chris Wilson wrote:<br>
> If the initialisation fails, we may be left with a dangling pointer with<br>
> an incomplete fbdev structure.<br>
<br>
This shouldn't happen with 4.5, the fbdev is now clobbered if initialization<br>
fails, the existing "if (dev_priv->fbdev)" checks should thus be sufficient.<br>
See 54632abe8ca3 ("drm/i915: Fix oops caused by fbdev initialization<br>
failure") as well as 366e39b4d2c5 ("drm/i915: Tear down fbdev if<br>
initialization fails").<br>
<br>
Gustav Fagerlind and Li Weinan both reported this for 4.3. It would be<br>
interesting to know if it can be reproduced at all with 4.5-rc2.<br>
<br>
Best regards,<br>
<br>
Lukas<br>
<br>
> Here we want to disable internal calls<br>
> into fbdev. Similarly, the initialisation may be slow and we haven't yet<br>
> enabled the fbdev (e.g. quick suspend or last-close before the async init<br>
> completes).<br>
><br>
> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=93580" target="_blank">
https://bugs.freedesktop.org/show_bug.cgi?id=93580</a><br>
> Reported-by: "Li, Weinan Z" <<a href="mailto:weinan.z.li@intel.com">weinan.z.li@intel.com</a>><br>
> Signed-off-by: Chris Wilson <<a href="mailto:chris@chris-wilson.co.uk">chris@chris-wilson.co.uk</a>><br>
> ---<br>
>  drivers/gpu/drm/i915/intel_fbdev.c | 41 ++++++++++++++++++++++++--------------<br>
>  1 file changed, 26 insertions(+), 15 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c<br>
> index 09840f4380f9..6218bc5370a1 100644<br>
> --- a/drivers/gpu/drm/i915/intel_fbdev.c<br>
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c<br>
> @@ -114,6 +114,20 @@ static struct fb_ops intelfb_ops = {<br>
>       .fb_debug_leave = drm_fb_helper_debug_leave,<br>
>  };<br>
><br>
> +static bool intel_fbdev_active(struct intel_fbdev *ifbdev)<br>
> +{<br>
> +     struct fb_info *info;<br>
> +<br>
> +     if (ifbdev == NULL)<br>
> +             return false;<br>
> +<br>
> +     info = ifbdev->helper.fbdev;<br>
> +     if (!info->screen_base)<br>
> +             return false;<br>
> +<br>
> +     return info->state == FBINFO_STATE_RUNNING;<br>
> +}<br>
> +<br>
>  static int intelfb_alloc(struct drm_fb_helper *helper,<br>
>                        struct drm_fb_helper_surface_size *sizes)<br>
>  {<br>
> @@ -753,6 +767,8 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous<br>
>               return;<br>
><br>
>       info = ifbdev->helper.fbdev;<br>
> +     if (!info->screen_base)<br>
> +             return;<br>
><br>
>       if (synchronous) {<br>
>               /* Flush any pending work to turn the console on, and then<br>
> @@ -794,29 +810,24 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous<br>
><br>
>  void intel_fbdev_output_poll_changed(struct drm_device *dev)<br>
>  {<br>
> -     struct drm_i915_private *dev_priv = dev->dev_private;<br>
> -     if (dev_priv->fbdev)<br>
> +     struct drm_i915_private *dev_priv = to_i915(dev);<br>
> +<br>
> +     if (intel_fbdev_active(dev_priv->fbdev))<br>
>               drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper);<br>
>  }<br>
><br>
>  void intel_fbdev_restore_mode(struct drm_device *dev)<br>
>  {<br>
> -     int ret;<br>
> -     struct drm_i915_private *dev_priv = dev->dev_private;<br>
> -     struct intel_fbdev *ifbdev = dev_priv->fbdev;<br>
> -     struct drm_fb_helper *fb_helper;<br>
> +     struct intel_fbdev *ifbdev = to_i915(dev)->fbdev;<br>
><br>
> -     if (!ifbdev)<br>
> +     if (!intel_fbdev_active(ifbdev))<br>
>               return;<br>
><br>
> -     fb_helper = &ifbdev->helper;<br>
> -<br>
> -     ret = drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper);<br>
> -     if (ret) {<br>
> -             DRM_DEBUG("failed to restore crtc mode\n");<br>
> -     } else {<br>
> -             mutex_lock(&fb_helper->dev->struct_mutex);<br>
> +     if (drm_fb_helper_restore_fbdev_mode_unlocked(&ifbdev->helper) == 0) {<br>
> +             mutex_lock(&dev->struct_mutex);<br>
>               intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);<br>
> -             mutex_unlock(&fb_helper->dev->struct_mutex);<br>
> +             mutex_unlock(&dev->struct_mutex);<br>
> +     } else {<br>
> +             DRM_DEBUG("failed to restore crtc mode\n");<br>
>       }<br>
>  }<br>
<span class="hoenzb"><span style="color:#888888">> --</span></span><span style="color:#888888"><br>
<span class="hoenzb">> 2.7.0</span><br>
<span class="hoenzb">></span><br>
<span class="hoenzb">> _______________________________________________</span><br>
<span class="hoenzb">> Intel-gfx mailing list</span><br>
<span class="hoenzb">> </span></span><a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><span style="color:#888888"><br>
<span class="hoenzb">> </span></span><a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>