All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	stable@vger.kernel.org, "Goel, Akash" <akash.goel@intel.com>,
	Takashi Iwai <tiwai@suse.de>
Subject: Re: [Intel-gfx] [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
Date: Thu, 10 Dec 2015 18:36:04 +0200	[thread overview]
Message-ID: <20151210163604.GC4437@intel.com> (raw)
In-Reply-To: <1449245126-26158-1-git-send-email-chris@chris-wilson.co.uk>

On Fri, Dec 04, 2015 at 04:05:26PM +0000, Chris Wilson wrote:
> A long time ago (before 3.14) we relied on a permanent pinning of the
> ifbdev to lock the fb in place inside the GGTT. However, the
> introduction of stealing the BIOS framebuffer and reusing its address in
> the GGTT for the fbdev has muddied waters and we use an inherited fb.
> However, the inherited fb is only pinned whilst it is active and we no
> longer have an explicit pin for the info->system_base mmapping used by
> the fbdev. The result is that after some aperture pressure the fbdev may
> be evicted, but we continue to write the fbcon into the same GGTT
> address - overwriting anything else that may be put into that offset.
> The effect is most pronounced across suspend/resume as
> intel_fbdev_set_suspend() does a full clear over the whole scanout.
> 
> v2: Only unpin the intel_fb is we allocate it. If we inherit the fb from
> the BIOS, we do not own the pinned vma (except for the reference we add
> in this patch for our access via info->screen_base).
> 
> v3: Finish balancing the vma pinning for the normal !preallocated case.
> 
> v4: Try to simplify the pinning even further.
> v5: Leak the VMA (cleaned up by object-free) to avoid complicated error paths.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: "Goel, Akash" <akash.goel@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Cc: Lukas Wunner <lukas@wunner.de>
> Cc: stable@vger.kernel.org

This seems to have fixed my garbled text+fbcon dead after
suspend/hibernate issues. Well, only had the patch in for a day or so,
but so far so good.

Tested-by: Ville Syrj�l� <ville.syrjala@linux.intel.com>

Takashi, don't know if you already found this patch, but it's definitely
something you should try as well.

> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 7ccde58f8c98..bea75cafc623 100644
> --- a/drivers/gpu/drm/i915/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> @@ -163,13 +163,6 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
>  		goto out;
>  	}
>  
> -	/* Flush everything out, we'll be doing GTT only from now on */
> -	ret = intel_pin_and_fence_fb_obj(NULL, fb, NULL);
> -	if (ret) {
> -		DRM_ERROR("failed to pin obj: %d\n", ret);
> -		goto out;
> -	}
> -
>  	mutex_unlock(&dev->struct_mutex);
>  
>  	ifbdev->fb = to_intel_framebuffer(fb);
> @@ -225,6 +218,14 @@ static int intelfb_create(struct drm_fb_helper *helper,
>  
>  	mutex_lock(&dev->struct_mutex);
>  
> +	/* Pin the GGTT vma for our access via info->screen_base.
> +	 * This also validates that any existing fb inherited from the
> +	 * BIOS is suitable for own access.
> +	 */
> +	ret = intel_pin_and_fence_fb_obj(NULL, &ifbdev->fb->base, NULL);
> +	if (ret)
> +		goto out_unlock;
> +
>  	info = drm_fb_helper_alloc_fbi(helper);
>  	if (IS_ERR(info)) {
>  		DRM_ERROR("Failed to allocate fb_info\n");
> @@ -287,6 +288,7 @@ out_destroy_fbi:
>  	drm_fb_helper_release_fbi(helper);
>  out_unpin:
>  	i915_gem_object_ggtt_unpin(obj);
> +out_unlock:
>  	mutex_unlock(&dev->struct_mutex);
>  	return ret;
>  }
> @@ -524,6 +526,10 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
>  static void intel_fbdev_destroy(struct drm_device *dev,
>  				struct intel_fbdev *ifbdev)
>  {
> +	/* We rely on the object-free to release the VMA pinning for
> +	 * the info->screen_base mmaping. Leaking the VMA is simpler than
> +	 * trying to rectify all the possible error paths leading here.
> +	 */
>  
>  	drm_fb_helper_unregister_fbi(&ifbdev->helper);
>  	drm_fb_helper_release_fbi(&ifbdev->helper);
> -- 
> 2.6.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrj�l�
Intel OTC

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Takashi Iwai <tiwai@suse.de>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	intel-gfx@lists.freedesktop.org, "Goel,
	Akash" <akash.goel@intel.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
Date: Thu, 10 Dec 2015 18:36:04 +0200	[thread overview]
Message-ID: <20151210163604.GC4437@intel.com> (raw)
In-Reply-To: <1449245126-26158-1-git-send-email-chris@chris-wilson.co.uk>

On Fri, Dec 04, 2015 at 04:05:26PM +0000, Chris Wilson wrote:
> A long time ago (before 3.14) we relied on a permanent pinning of the
> ifbdev to lock the fb in place inside the GGTT. However, the
> introduction of stealing the BIOS framebuffer and reusing its address in
> the GGTT for the fbdev has muddied waters and we use an inherited fb.
> However, the inherited fb is only pinned whilst it is active and we no
> longer have an explicit pin for the info->system_base mmapping used by
> the fbdev. The result is that after some aperture pressure the fbdev may
> be evicted, but we continue to write the fbcon into the same GGTT
> address - overwriting anything else that may be put into that offset.
> The effect is most pronounced across suspend/resume as
> intel_fbdev_set_suspend() does a full clear over the whole scanout.
> 
> v2: Only unpin the intel_fb is we allocate it. If we inherit the fb from
> the BIOS, we do not own the pinned vma (except for the reference we add
> in this patch for our access via info->screen_base).
> 
> v3: Finish balancing the vma pinning for the normal !preallocated case.
> 
> v4: Try to simplify the pinning even further.
> v5: Leak the VMA (cleaned up by object-free) to avoid complicated error paths.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: "Goel, Akash" <akash.goel@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Cc: Lukas Wunner <lukas@wunner.de>
> Cc: stable@vger.kernel.org

This seems to have fixed my garbled text+fbcon dead after
suspend/hibernate issues. Well, only had the patch in for a day or so,
but so far so good.

Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Takashi, don't know if you already found this patch, but it's definitely
something you should try as well.

> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 7ccde58f8c98..bea75cafc623 100644
> --- a/drivers/gpu/drm/i915/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> @@ -163,13 +163,6 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
>  		goto out;
>  	}
>  
> -	/* Flush everything out, we'll be doing GTT only from now on */
> -	ret = intel_pin_and_fence_fb_obj(NULL, fb, NULL);
> -	if (ret) {
> -		DRM_ERROR("failed to pin obj: %d\n", ret);
> -		goto out;
> -	}
> -
>  	mutex_unlock(&dev->struct_mutex);
>  
>  	ifbdev->fb = to_intel_framebuffer(fb);
> @@ -225,6 +218,14 @@ static int intelfb_create(struct drm_fb_helper *helper,
>  
>  	mutex_lock(&dev->struct_mutex);
>  
> +	/* Pin the GGTT vma for our access via info->screen_base.
> +	 * This also validates that any existing fb inherited from the
> +	 * BIOS is suitable for own access.
> +	 */
> +	ret = intel_pin_and_fence_fb_obj(NULL, &ifbdev->fb->base, NULL);
> +	if (ret)
> +		goto out_unlock;
> +
>  	info = drm_fb_helper_alloc_fbi(helper);
>  	if (IS_ERR(info)) {
>  		DRM_ERROR("Failed to allocate fb_info\n");
> @@ -287,6 +288,7 @@ out_destroy_fbi:
>  	drm_fb_helper_release_fbi(helper);
>  out_unpin:
>  	i915_gem_object_ggtt_unpin(obj);
> +out_unlock:
>  	mutex_unlock(&dev->struct_mutex);
>  	return ret;
>  }
> @@ -524,6 +526,10 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
>  static void intel_fbdev_destroy(struct drm_device *dev,
>  				struct intel_fbdev *ifbdev)
>  {
> +	/* We rely on the object-free to release the VMA pinning for
> +	 * the info->screen_base mmaping. Leaking the VMA is simpler than
> +	 * trying to rectify all the possible error paths leading here.
> +	 */
>  
>  	drm_fb_helper_unregister_fbi(&ifbdev->helper);
>  	drm_fb_helper_release_fbi(&ifbdev->helper);
> -- 
> 2.6.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-12-10 16:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20 14:16 [PATCH v2 1/2] drm/i915: Set the map-and-fenceable flag for preallocated objects Chris Wilson
2015-11-20 14:16 ` [PATCH v2 2/2] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping Chris Wilson
2015-11-20 14:34   ` [PATCH v3] " Chris Wilson
2015-11-20 14:34     ` Chris Wilson
2015-11-20 16:15     ` Jesse Barnes
2015-11-20 16:29       ` [PATCH v4] " Chris Wilson
2015-11-20 16:35         ` Jesse Barnes
2015-11-20 16:35           ` Jesse Barnes
2015-11-20 16:46         ` [Intel-gfx] " kbuild test robot
2015-11-20 18:01         ` kbuild test robot
2015-11-24 16:46           ` Daniel Vetter
2015-12-01  9:01             ` Jani Nikula
2015-12-01  9:01               ` Jani Nikula
2015-11-24 21:20         ` Lukas Wunner
2015-12-04 16:05           ` [PATCH v5] " Chris Wilson
2015-12-06 20:33             ` Lukas Wunner
2015-12-16 10:52               ` Daniel Vetter
2015-12-17 11:34                 ` [Intel-gfx] " Ville Syrjälä
2015-12-17 11:34                   ` Ville Syrjälä
2015-12-10 16:36             ` Ville Syrjälä [this message]
2015-12-10 16:36               ` Ville Syrjälä
2015-12-10 16:41               ` [Intel-gfx] " Takashi Iwai
2015-12-10 16:41                 ` Takashi Iwai
2015-12-17 15:59                 ` [Intel-gfx] " Daniel Vetter
2015-12-17 15:59                   ` Daniel Vetter
2015-12-23 11:07                   ` Jani Nikula
2015-11-20 16:06 ` [PATCH v2 1/2] drm/i915: Set the map-and-fenceable flag for preallocated objects Jesse Barnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151210163604.GC4437@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=akash.goel@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.