<div dir="ltr"><div><div><div>Cool, thank you.<br></div>I dont believe I can easily reproduce it, it has only happend few times (and i reboot my lappy >2 times per day).<br></div><br>//<br></div>Gustav<br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-03 14:25 GMT+01:00 Lukas Wunner <span dir="ltr"><<a href="mailto:lukas@wunner.de" target="_blank">lukas@wunner.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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" rel="noreferrer" 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"><font color="#888888">> --<br>
> 2.7.0<br>
><br>
> _______________________________________________<br>
> Intel-gfx mailing list<br>
> <a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
</font></span></blockquote></div><br></div>