From patchwork Thu Mar 31 12:00:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Feceoru, Gabriel" X-Patchwork-Id: 8712051 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 368E9C0553 for ; Thu, 31 Mar 2016 12:00:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43CA3201FA for ; Thu, 31 Mar 2016 12:00:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 499C2201D3 for ; Thu, 31 Mar 2016 12:00:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 021126E0CA; Thu, 31 Mar 2016 12:00:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 319F16E0CA for ; Thu, 31 Mar 2016 12:00:40 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 31 Mar 2016 05:00:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,422,1455004800"; d="scan'208";a="678550470" Received: from gfeceoru-ms-7924.rb.intel.com (HELO [10.237.104.199]) ([10.237.104.199]) by FMSMGA003.fm.intel.com with ESMTP; 31 Mar 2016 05:00:40 -0700 To: Chris Wilson , intel-gfx@lists.freedesktop.org References: <1459360634-25516-1-git-send-email-chris@chris-wilson.co.uk> <1459364165-16031-1-git-send-email-chris@chris-wilson.co.uk> From: Gabriel Feceoru Message-ID: <56FD1151.5050303@intel.com> Date: Thu, 31 Mar 2016 15:00:17 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1459364165-16031-1-git-send-email-chris@chris-wilson.co.uk> Subject: Re: [Intel-gfx] [PATCH v3] drm/i915: Protect fbdev across slow or failed initialisation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This almost fixes the problem , but with this: I got initially a page fault during init, but with this fix, the suspend test passes. Thank you, please consider this. Regards, Gabriel On 30.03.2016 21:56, Chris Wilson wrote: > If the initialisation fails, we may be left with a dangling pointer with > an incomplete fbdev structure. Here we want to disable internal calls > into fbdev. Similarly, the initialisation may be slow and we haven't yet > enabled the fbdev (e.g. quick suspend or last-close before the async init > completes). > > v3: To create a typo introduced when retyping > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93580 > Reported-by: "Li, Weinan Z" > Signed-off-by: Chris Wilson > --- > drivers/gpu/drm/i915/intel_fbdev.c | 48 ++++++++++++++++++++++++-------------- > 1 file changed, 30 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c > index 153ea7a3fcf6..5029f927fe0d 100644 > --- a/drivers/gpu/drm/i915/intel_fbdev.c > +++ b/drivers/gpu/drm/i915/intel_fbdev.c > @@ -114,6 +114,24 @@ static struct fb_ops intelfb_ops = { > .fb_debug_leave = drm_fb_helper_debug_leave, > }; > > +static struct intel_fbdev *intel_fbdev_get_if_active(struct drm_device *dev) > +{ > + struct drm_i915_private *dev_priv = to_i915(dev); > + struct fb_info *info; > + > + if (dev_priv->fbdev == NULL) > + return NULL; > + > + info = dev_priv->fbdev->helper.fbdev; > + if (info->screen_base == NULL) > + return NULL; > + > + if (info->state != FBINFO_STATE_RUNNING) > + return NULL; > + > + return dev_priv->fbdev; > +} > + > static int intelfb_alloc(struct drm_fb_helper *helper, > struct drm_fb_helper_surface_size *sizes) > { > @@ -766,6 +784,8 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous > return; > > info = ifbdev->helper.fbdev; > + if (info->screen_base == NULL) > + return; > > if (synchronous) { > /* Flush any pending work to turn the console on, and then > @@ -807,32 +827,24 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous > > void intel_fbdev_output_poll_changed(struct drm_device *dev) > { > - struct drm_i915_private *dev_priv = dev->dev_private; > + struct intel_fbdev *ifbdev = intel_fbdev_get_if_active(dev); > + > + if (ifbdev == NULL) > + return; > > - async_synchronize_full(); > - if (dev_priv->fbdev) > - drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper); > + drm_fb_helper_hotplug_event(&ifbdev->helper); > } > > void intel_fbdev_restore_mode(struct drm_device *dev) > { > - int ret; > - struct drm_i915_private *dev_priv = dev->dev_private; > - struct intel_fbdev *ifbdev = dev_priv->fbdev; > - struct drm_fb_helper *fb_helper; > + struct intel_fbdev *ifbdev = intel_fbdev_get_if_active(dev); > > - async_synchronize_full(); > - if (!ifbdev) > + if (ifbdev == NULL) > return; > > - fb_helper = &ifbdev->helper; > - > - ret = drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper); > - if (ret) { > - DRM_DEBUG("failed to restore crtc mode\n"); > - } else { > - mutex_lock(&fb_helper->dev->struct_mutex); > + if (drm_fb_helper_restore_fbdev_mode_unlocked(&ifbdev->helper) == 0) { > + mutex_lock(&dev->struct_mutex); > intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT); > - mutex_unlock(&fb_helper->dev->struct_mutex); > + mutex_unlock(&dev->struct_mutex); > } > } > diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c index 5029f92..a6d3c58 100644 --- a/drivers/gpu/drm/i915/intel_fbdev.c +++ b/drivers/gpu/drm/i915/intel_fbdev.c @@ -123,8 +123,9 @@ static struct intel_fbdev *intel_fbdev_get_if_active(struct drm_device *dev) return NULL; info = dev_priv->fbdev->helper.fbdev; - if (info->screen_base == NULL) + if (info == NULL || info->screen_base == NULL) return NULL; if (info->state != FBINFO_STATE_RUNNING) return NULL;