All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drm/i915: Set the map-and-fenceable flag for preallocated objects
@ 2015-11-20 14:16 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 16:06 ` [PATCH v2 1/2] drm/i915: Set the map-and-fenceable flag for preallocated objects Jesse Barnes
  0 siblings, 2 replies; 27+ messages in thread
From: Chris Wilson @ 2015-11-20 14:16 UTC (permalink / raw)
  To: intel-gfx; +Cc: Chris Wilson, Goel, Akash, Daniel Vetter, Jesse Barnes, stable

As we mark the preallocated objects as bound, we should also flag them
correctly as being map-and-fenceable (if appropriate!) so that later
users do not get confused and try and rebind the pinned vma in order to
get a map-and-fenceable binding.

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: stable@vger.kernel.org
---
 drivers/gpu/drm/i915/i915_drv.h        |  1 +
 drivers/gpu/drm/i915/i915_gem.c        | 43 +++++++++++++++++++---------------
 drivers/gpu/drm/i915/i915_gem_gtt.c    |  1 +
 drivers/gpu/drm/i915/i915_gem_stolen.c |  1 +
 4 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f2b65433ed7d..24143e5273b6 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2844,6 +2844,7 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
 
 int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
 		  u32 flags);
+void __i915_vma_set_map_and_fenceable(struct i915_vma *vma);
 int __must_check i915_vma_unbind(struct i915_vma *vma);
 /*
  * BEWARE: Do not use the function below unless you can _absolutely_
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 3ad198a41c4a..e6a8a52c8a6b 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4092,6 +4092,29 @@ i915_vma_misplaced(struct i915_vma *vma, uint32_t alignment, uint64_t flags)
 	return false;
 }
 
+void __i915_vma_set_map_and_fenceable(struct i915_vma *vma)
+{
+	struct drm_i915_gem_object *obj = vma->obj;
+	bool mappable, fenceable;
+	u32 fence_size, fence_alignment;
+
+	fence_size = i915_gem_get_gtt_size(obj->base.dev,
+					   obj->base.size,
+					   obj->tiling_mode);
+	fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
+						     obj->base.size,
+						     obj->tiling_mode,
+						     true);
+
+	fenceable = (vma->node.size == fence_size &&
+		     (vma->node.start & (fence_alignment - 1)) == 0);
+
+	mappable = (vma->node.start + fence_size <=
+		    to_i915(obj->base.dev)->gtt.mappable_end);
+
+	obj->map_and_fenceable = mappable && fenceable;
+}
+
 static int
 i915_gem_object_do_pin(struct drm_i915_gem_object *obj,
 		       struct i915_address_space *vm,
@@ -4159,25 +4182,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,
 
 	if (ggtt_view && ggtt_view->type == I915_GGTT_VIEW_NORMAL &&
 	    (bound ^ vma->bound) & GLOBAL_BIND) {
-		bool mappable, fenceable;
-		u32 fence_size, fence_alignment;
-
-		fence_size = i915_gem_get_gtt_size(obj->base.dev,
-						   obj->base.size,
-						   obj->tiling_mode);
-		fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
-							     obj->base.size,
-							     obj->tiling_mode,
-							     true);
-
-		fenceable = (vma->node.size == fence_size &&
-			     (vma->node.start & (fence_alignment - 1)) == 0);
-
-		mappable = (vma->node.start + fence_size <=
-			    dev_priv->gtt.mappable_end);
-
-		obj->map_and_fenceable = mappable && fenceable;
-
+		__i915_vma_set_map_and_fenceable(vma);
 		WARN_ON(flags & PIN_MAPPABLE && !obj->map_and_fenceable);
 	}
 
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index a09f8f0510d5..74b26b2d0889 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2704,6 +2704,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,
 			return ret;
 		}
 		vma->bound |= GLOBAL_BIND;
+		__i915_vma_set_map_and_fenceable(vma);
 		list_add_tail(&vma->mm_list, &ggtt_vm->inactive_list);
 	}
 
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index 598ed2facf85..3476877fc0d6 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -688,6 +688,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
 		}
 
 		vma->bound |= GLOBAL_BIND;
+		__i915_vma_set_map_and_fenceable(vma);
 		list_add_tail(&vma->mm_list, &ggtt->inactive_list);
 	}
 
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 2/2] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  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 ` Chris Wilson
  2015-11-20 14:34     ` Chris Wilson
  2015-11-20 16:06 ` [PATCH v2 1/2] drm/i915: Set the map-and-fenceable flag for preallocated objects Jesse Barnes
  1 sibling, 1 reply; 27+ messages in thread
From: Chris Wilson @ 2015-11-20 14:16 UTC (permalink / raw)
  To: intel-gfx; +Cc: Chris Wilson, Goel, Akash, Daniel Vetter, Jesse Barnes, stable

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).

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: stable@vger.kernel.org
---
 drivers/gpu/drm/i915/intel_fbdev.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 7ccde58f8c98..e1a39302cd2b 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -196,6 +196,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
 	struct drm_i915_gem_object *obj;
 	int size, ret;
 	bool prealloc = false;
+	bool fb_pinned = false;
 
 	if (intel_fb &&
 	    (sizes->fb_width > intel_fb->base.width ||
@@ -213,6 +214,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
 		if (ret)
 			return ret;
 		intel_fb = ifbdev->fb;
+		fb_pinned = true;
 	} else {
 		DRM_DEBUG_KMS("re-using BIOS fb\n");
 		prealloc = true;
@@ -225,6 +227,16 @@ static int intelfb_create(struct drm_fb_helper *helper,
 
 	mutex_lock(&dev->struct_mutex);
 
+	/* The fb constructor will have already pinned us (or inherited a
+	 * GGTT region from the BIOS) suitable for a scanout, so
+	 * this should just be a no-op and increment the pin count for the
+	 * fbdev mmapping. It does have a useful side-effect of validating
+	 * the pin for fbdev's use via a GGTT mmapping.
+	 */
+	ret = i915_gem_obj_ggtt_pin(obj, 0, PIN_MAPPABLE);
+	if (ret)
+		goto out_unlock;
+
 	info = drm_fb_helper_alloc_fbi(helper);
 	if (IS_ERR(info)) {
 		DRM_ERROR("Failed to allocate fb_info\n");
@@ -286,7 +298,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
 out_destroy_fbi:
 	drm_fb_helper_release_fbi(helper);
 out_unpin:
+	/* Once for info->screen_base mmaping... */
 	i915_gem_object_ggtt_unpin(obj);
+out_unlock:
+	if (fb_pinned)
+		/* ...and once for the intel_fb */
+		i915_gem_object_ggtt_unpin(obj);
 	mutex_unlock(&dev->struct_mutex);
 	return ret;
 }
@@ -524,6 +541,8 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
 static void intel_fbdev_destroy(struct drm_device *dev,
 				struct intel_fbdev *ifbdev)
 {
+	/* Release the pinning for the info->screen_base mmaping. */
+	i915_gem_object_ggtt_unpin(ifbdev->fb->obj);
 
 	drm_fb_helper_unregister_fbi(&ifbdev->helper);
 	drm_fb_helper_release_fbi(&ifbdev->helper);
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  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     ` Chris Wilson
  0 siblings, 0 replies; 27+ messages in thread
From: Chris Wilson @ 2015-11-20 14:34 UTC (permalink / raw)
  To: intel-gfx; +Cc: Chris Wilson, Goel, Akash, Daniel Vetter, Jesse Barnes, stable

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.

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: stable@vger.kernel.org
---
 drivers/gpu/drm/i915/intel_fbdev.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 7ccde58f8c98..7a415fe31299 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -225,6 +225,16 @@ static int intelfb_create(struct drm_fb_helper *helper,
 
 	mutex_lock(&dev->struct_mutex);
 
+	/* The fb constructor will have already pinned us (or inherited a
+	 * GGTT region from the BIOS) suitable for a scanout, so
+	 * this should just be a no-op and increment the pin count for the
+	 * fbdev mmapping. It does have a useful side-effect of validating
+	 * the pin for fbdev's use via a GGTT mmapping.
+	 */
+	ret = i915_gem_obj_ggtt_pin(obj, 0, PIN_MAPPABLE);
+	if (ret)
+		goto out_unlock;
+
 	info = drm_fb_helper_alloc_fbi(helper);
 	if (IS_ERR(info)) {
 		DRM_ERROR("Failed to allocate fb_info\n");
@@ -279,6 +289,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
 		      fb->width, fb->height,
 		      i915_gem_obj_ggtt_offset(obj), obj);
 
+	/* We pin the vma for our access through info->screen_base, so
+	 * we can drop the pin we took if we created the intel_fb.
+	 */
+	if (!prealloc)
+		i915_gem_object_ggtt_unpin(obj);
+
 	mutex_unlock(&dev->struct_mutex);
 	vga_switcheroo_client_fb_set(dev->pdev, info);
 	return 0;
@@ -286,7 +302,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
 out_destroy_fbi:
 	drm_fb_helper_release_fbi(helper);
 out_unpin:
+	/* Once for info->screen_base mmaping... */
 	i915_gem_object_ggtt_unpin(obj);
+out_unlock:
+	if (!prealloc)
+		/* ...and once for the intel_fb */
+		i915_gem_object_ggtt_unpin(obj);
 	mutex_unlock(&dev->struct_mutex);
 	return ret;
 }
@@ -524,6 +545,8 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
 static void intel_fbdev_destroy(struct drm_device *dev,
 				struct intel_fbdev *ifbdev)
 {
+	/* Release the pinning for the info->screen_base mmaping. */
+	i915_gem_object_ggtt_unpin(ifbdev->fb->obj);
 
 	drm_fb_helper_unregister_fbi(&ifbdev->helper);
 	drm_fb_helper_release_fbi(&ifbdev->helper);
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
@ 2015-11-20 14:34     ` Chris Wilson
  0 siblings, 0 replies; 27+ messages in thread
From: Chris Wilson @ 2015-11-20 14:34 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter, Goel, Akash, stable

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.

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: stable@vger.kernel.org
---
 drivers/gpu/drm/i915/intel_fbdev.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 7ccde58f8c98..7a415fe31299 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -225,6 +225,16 @@ static int intelfb_create(struct drm_fb_helper *helper,
 
 	mutex_lock(&dev->struct_mutex);
 
+	/* The fb constructor will have already pinned us (or inherited a
+	 * GGTT region from the BIOS) suitable for a scanout, so
+	 * this should just be a no-op and increment the pin count for the
+	 * fbdev mmapping. It does have a useful side-effect of validating
+	 * the pin for fbdev's use via a GGTT mmapping.
+	 */
+	ret = i915_gem_obj_ggtt_pin(obj, 0, PIN_MAPPABLE);
+	if (ret)
+		goto out_unlock;
+
 	info = drm_fb_helper_alloc_fbi(helper);
 	if (IS_ERR(info)) {
 		DRM_ERROR("Failed to allocate fb_info\n");
@@ -279,6 +289,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
 		      fb->width, fb->height,
 		      i915_gem_obj_ggtt_offset(obj), obj);
 
+	/* We pin the vma for our access through info->screen_base, so
+	 * we can drop the pin we took if we created the intel_fb.
+	 */
+	if (!prealloc)
+		i915_gem_object_ggtt_unpin(obj);
+
 	mutex_unlock(&dev->struct_mutex);
 	vga_switcheroo_client_fb_set(dev->pdev, info);
 	return 0;
@@ -286,7 +302,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
 out_destroy_fbi:
 	drm_fb_helper_release_fbi(helper);
 out_unpin:
+	/* Once for info->screen_base mmaping... */
 	i915_gem_object_ggtt_unpin(obj);
+out_unlock:
+	if (!prealloc)
+		/* ...and once for the intel_fb */
+		i915_gem_object_ggtt_unpin(obj);
 	mutex_unlock(&dev->struct_mutex);
 	return ret;
 }
@@ -524,6 +545,8 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
 static void intel_fbdev_destroy(struct drm_device *dev,
 				struct intel_fbdev *ifbdev)
 {
+	/* Release the pinning for the info->screen_base mmaping. */
+	i915_gem_object_ggtt_unpin(ifbdev->fb->obj);
 
 	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

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 1/2] drm/i915: Set the map-and-fenceable flag for preallocated objects
  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 16:06 ` Jesse Barnes
  1 sibling, 0 replies; 27+ messages in thread
From: Jesse Barnes @ 2015-11-20 16:06 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx; +Cc: Goel, Akash, Daniel Vetter, stable

On 11/20/2015 06:16 AM, Chris Wilson wrote:
> As we mark the preallocated objects as bound, we should also flag them
> correctly as being map-and-fenceable (if appropriate!) so that later
> users do not get confused and try and rebind the pinned vma in order to
> get a map-and-fenceable binding.
> 
> 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: stable@vger.kernel.org
> ---
>  drivers/gpu/drm/i915/i915_drv.h        |  1 +
>  drivers/gpu/drm/i915/i915_gem.c        | 43 +++++++++++++++++++---------------
>  drivers/gpu/drm/i915/i915_gem_gtt.c    |  1 +
>  drivers/gpu/drm/i915/i915_gem_stolen.c |  1 +
>  4 files changed, 27 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index f2b65433ed7d..24143e5273b6 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2844,6 +2844,7 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
>  
>  int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
>  		  u32 flags);
> +void __i915_vma_set_map_and_fenceable(struct i915_vma *vma);
>  int __must_check i915_vma_unbind(struct i915_vma *vma);
>  /*
>   * BEWARE: Do not use the function below unless you can _absolutely_
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 3ad198a41c4a..e6a8a52c8a6b 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4092,6 +4092,29 @@ i915_vma_misplaced(struct i915_vma *vma, uint32_t alignment, uint64_t flags)
>  	return false;
>  }
>  
> +void __i915_vma_set_map_and_fenceable(struct i915_vma *vma)
> +{
> +	struct drm_i915_gem_object *obj = vma->obj;
> +	bool mappable, fenceable;
> +	u32 fence_size, fence_alignment;
> +
> +	fence_size = i915_gem_get_gtt_size(obj->base.dev,
> +					   obj->base.size,
> +					   obj->tiling_mode);
> +	fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
> +						     obj->base.size,
> +						     obj->tiling_mode,
> +						     true);
> +
> +	fenceable = (vma->node.size == fence_size &&
> +		     (vma->node.start & (fence_alignment - 1)) == 0);
> +
> +	mappable = (vma->node.start + fence_size <=
> +		    to_i915(obj->base.dev)->gtt.mappable_end);
> +
> +	obj->map_and_fenceable = mappable && fenceable;
> +}
> +
>  static int
>  i915_gem_object_do_pin(struct drm_i915_gem_object *obj,
>  		       struct i915_address_space *vm,
> @@ -4159,25 +4182,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,
>  
>  	if (ggtt_view && ggtt_view->type == I915_GGTT_VIEW_NORMAL &&
>  	    (bound ^ vma->bound) & GLOBAL_BIND) {
> -		bool mappable, fenceable;
> -		u32 fence_size, fence_alignment;
> -
> -		fence_size = i915_gem_get_gtt_size(obj->base.dev,
> -						   obj->base.size,
> -						   obj->tiling_mode);
> -		fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
> -							     obj->base.size,
> -							     obj->tiling_mode,
> -							     true);
> -
> -		fenceable = (vma->node.size == fence_size &&
> -			     (vma->node.start & (fence_alignment - 1)) == 0);
> -
> -		mappable = (vma->node.start + fence_size <=
> -			    dev_priv->gtt.mappable_end);
> -
> -		obj->map_and_fenceable = mappable && fenceable;
> -
> +		__i915_vma_set_map_and_fenceable(vma);
>  		WARN_ON(flags & PIN_MAPPABLE && !obj->map_and_fenceable);
>  	}
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index a09f8f0510d5..74b26b2d0889 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -2704,6 +2704,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,
>  			return ret;
>  		}
>  		vma->bound |= GLOBAL_BIND;
> +		__i915_vma_set_map_and_fenceable(vma);
>  		list_add_tail(&vma->mm_list, &ggtt_vm->inactive_list);
>  	}
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index 598ed2facf85..3476877fc0d6 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -688,6 +688,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
>  		}
>  
>  		vma->bound |= GLOBAL_BIND;
> +		__i915_vma_set_map_and_fenceable(vma);
>  		list_add_tail(&vma->mm_list, &ggtt->inactive_list);
>  	}
>  
> 

Looks important.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-20 14:34     ` Chris Wilson
  (?)
@ 2015-11-20 16:15     ` Jesse Barnes
  2015-11-20 16:29       ` [PATCH v4] " Chris Wilson
  -1 siblings, 1 reply; 27+ messages in thread
From: Jesse Barnes @ 2015-11-20 16:15 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx; +Cc: Goel, Akash, Daniel Vetter, stable

On 11/20/2015 06:34 AM, 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.
> 
> 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: stable@vger.kernel.org
> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 7ccde58f8c98..7a415fe31299 100644
> --- a/drivers/gpu/drm/i915/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> @@ -225,6 +225,16 @@ static int intelfb_create(struct drm_fb_helper *helper,
>  
>  	mutex_lock(&dev->struct_mutex);
>  
> +	/* The fb constructor will have already pinned us (or inherited a
> +	 * GGTT region from the BIOS) suitable for a scanout, so
> +	 * this should just be a no-op and increment the pin count for the
> +	 * fbdev mmapping. It does have a useful side-effect of validating
> +	 * the pin for fbdev's use via a GGTT mmapping.
> +	 */
> +	ret = i915_gem_obj_ggtt_pin(obj, 0, PIN_MAPPABLE);
> +	if (ret)
> +		goto out_unlock;
> +
>  	info = drm_fb_helper_alloc_fbi(helper);
>  	if (IS_ERR(info)) {
>  		DRM_ERROR("Failed to allocate fb_info\n");
> @@ -279,6 +289,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
>  		      fb->width, fb->height,
>  		      i915_gem_obj_ggtt_offset(obj), obj);
>  
> +	/* We pin the vma for our access through info->screen_base, so
> +	 * we can drop the pin we took if we created the intel_fb.
> +	 */
> +	if (!prealloc)
> +		i915_gem_object_ggtt_unpin(obj);
> +
>  	mutex_unlock(&dev->struct_mutex);
>  	vga_switcheroo_client_fb_set(dev->pdev, info);
>  	return 0;
> @@ -286,7 +302,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
>  out_destroy_fbi:
>  	drm_fb_helper_release_fbi(helper);
>  out_unpin:
> +	/* Once for info->screen_base mmaping... */
>  	i915_gem_object_ggtt_unpin(obj);
> +out_unlock:
> +	if (!prealloc)
> +		/* ...and once for the intel_fb */
> +		i915_gem_object_ggtt_unpin(obj);
>  	mutex_unlock(&dev->struct_mutex);
>  	return ret;
>  }
> @@ -524,6 +545,8 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
>  static void intel_fbdev_destroy(struct drm_device *dev,
>  				struct intel_fbdev *ifbdev)
>  {
> +	/* Release the pinning for the info->screen_base mmaping. */
> +	i915_gem_object_ggtt_unpin(ifbdev->fb->obj);
>  
>  	drm_fb_helper_unregister_fbi(&ifbdev->helper);
>  	drm_fb_helper_release_fbi(&ifbdev->helper);
> 

Now you're making me look at the pin/unpin handling...  Could probably
make the prealloc vs non-prealloc cases a bit clearer, but it looks
correct.  In the prealloc case we need the additional pin, since
create_stolen_for_preallocated just pins the pages and doesn't up the
pin count, right?  But in the non-prealloc case we'll have done a
regular fb alloc, which does a pin & fence, so we can drop the extra pin
count.  And I think the page unpin is already taken care of?  ISTR bugs
there when we first landed the initial plane allocation stuff.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-20 16:15     ` Jesse Barnes
@ 2015-11-20 16:29       ` Chris Wilson
  2015-11-20 16:35           ` Jesse Barnes
                           ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Chris Wilson @ 2015-11-20 16:29 UTC (permalink / raw)
  To: intel-gfx; +Cc: Chris Wilson, Goel, Akash, Daniel Vetter, Jesse Barnes, stable

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.

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: stable@vger.kernel.org
---
 drivers/gpu/drm/i915/intel_fbdev.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 7ccde58f8c98..79f02e72da8a 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,8 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
 static void intel_fbdev_destroy(struct drm_device *dev,
 				struct intel_fbdev *ifbdev)
 {
+	/* Release the pinning for the info->screen_base mmaping. */
+	i915_gem_object_ggtt_unpin(ifbdev->fb->obj);
 
 	drm_fb_helper_unregister_fbi(&ifbdev->helper);
 	drm_fb_helper_release_fbi(&ifbdev->helper);
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-20 16:29       ` [PATCH v4] " Chris Wilson
@ 2015-11-20 16:35           ` Jesse Barnes
  2015-11-20 16:46         ` [Intel-gfx] " kbuild test robot
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 27+ messages in thread
From: Jesse Barnes @ 2015-11-20 16:35 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx; +Cc: Goel, Akash, Daniel Vetter, stable

On 11/20/2015 08:29 AM, 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.
> 
> 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: stable@vger.kernel.org
> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 7ccde58f8c98..79f02e72da8a 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,8 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
>  static void intel_fbdev_destroy(struct drm_device *dev,
>  				struct intel_fbdev *ifbdev)
>  {
> +	/* Release the pinning for the info->screen_base mmaping. */
> +	i915_gem_object_ggtt_unpin(ifbdev->fb->obj);
>  
>  	drm_fb_helper_unregister_fbi(&ifbdev->helper);
>  	drm_fb_helper_release_fbi(&ifbdev->helper);
> 

Ah even better.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
@ 2015-11-20 16:35           ` Jesse Barnes
  0 siblings, 0 replies; 27+ messages in thread
From: Jesse Barnes @ 2015-11-20 16:35 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx; +Cc: Daniel Vetter, Goel, Akash, stable

On 11/20/2015 08:29 AM, 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.
> 
> 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: stable@vger.kernel.org
> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 7ccde58f8c98..79f02e72da8a 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,8 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
>  static void intel_fbdev_destroy(struct drm_device *dev,
>  				struct intel_fbdev *ifbdev)
>  {
> +	/* Release the pinning for the info->screen_base mmaping. */
> +	i915_gem_object_ggtt_unpin(ifbdev->fb->obj);
>  
>  	drm_fb_helper_unregister_fbi(&ifbdev->helper);
>  	drm_fb_helper_release_fbi(&ifbdev->helper);
> 

Ah even better.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-20 16:29       ` [PATCH v4] " Chris Wilson
  2015-11-20 16:35           ` Jesse Barnes
@ 2015-11-20 16:46         ` kbuild test robot
  2015-11-20 18:01         ` kbuild test robot
  2015-11-24 21:20         ` Lukas Wunner
  3 siblings, 0 replies; 27+ messages in thread
From: kbuild test robot @ 2015-11-20 16:46 UTC (permalink / raw)
  To: Chris Wilson; +Cc: kbuild-all, intel-gfx, Daniel Vetter, Goel, Akash, stable

[-- Attachment #1: Type: text/plain, Size: 1677 bytes --]

Hi Chris,

[auto build test ERROR on drm-intel/for-linux-next]
[cannot apply to v4.4-rc1 next-20151120]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Pin-the-ifbdev-for-the-info-system_base-GGTT-mmapping/20151121-003300
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-x011-11191819 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/gpu/drm/i915/intel_fbdev.c: In function 'intelfb_create':
>> drivers/gpu/drm/i915/intel_fbdev.c:225:41: error: incompatible type for argument 2 of 'intel_pin_and_fence_fb_obj'
     ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
                                            ^
   In file included from drivers/gpu/drm/i915/intel_fbdev.c:44:0:
   drivers/gpu/drm/i915/intel_drv.h:1098:5: note: expected 'struct drm_framebuffer *' but argument is of type 'struct drm_framebuffer'
    int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
        ^

vim +/intel_pin_and_fence_fb_obj +225 drivers/gpu/drm/i915/intel_fbdev.c

   219		mutex_lock(&dev->struct_mutex);
   220	
   221		/* Pin the GGTT vma for our access via info->screen_base.
   222		 * This also validates that any existing fb inherited from the
   223		 * BIOS is suitable for own access.
   224		 */
 > 225		ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
   226		if (ret)
   227			goto out_unlock;
   228	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 25325 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-20 16:29       ` [PATCH v4] " Chris Wilson
  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-11-24 21:20         ` Lukas Wunner
  3 siblings, 1 reply; 27+ messages in thread
From: kbuild test robot @ 2015-11-20 18:01 UTC (permalink / raw)
  To: Chris Wilson; +Cc: kbuild-all, intel-gfx, Daniel Vetter, Goel, Akash, stable

Hi Chris,

[auto build test WARNING on drm-intel/for-linux-next]
[cannot apply to v4.4-rc1 next-20151120]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Pin-the-ifbdev-for-the-info-system_base-GGTT-mmapping/20151121-003300
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/i915/intel_fbdev.c:225:58: sparse: incorrect type in argument 2 (different base types)
   drivers/gpu/drm/i915/intel_fbdev.c:225:58:    expected struct drm_framebuffer *fb
   drivers/gpu/drm/i915/intel_fbdev.c:225:58:    got struct drm_framebuffer base
   drivers/gpu/drm/i915/intel_fbdev.c: In function 'intelfb_create':
   drivers/gpu/drm/i915/intel_fbdev.c:225:41: error: incompatible type for argument 2 of 'intel_pin_and_fence_fb_obj'
     ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
                                            ^
   In file included from drivers/gpu/drm/i915/intel_fbdev.c:44:0:
   drivers/gpu/drm/i915/intel_drv.h:1098:5: note: expected 'struct drm_framebuffer *' but argument is of type 'struct drm_framebuffer'
    int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
        ^

vim +225 drivers/gpu/drm/i915/intel_fbdev.c

   209		} else {
   210			DRM_DEBUG_KMS("re-using BIOS fb\n");
   211			prealloc = true;
   212			sizes->fb_width = intel_fb->base.width;
   213			sizes->fb_height = intel_fb->base.height;
   214		}
   215	
   216		obj = intel_fb->obj;
   217		size = obj->base.size;
   218	
   219		mutex_lock(&dev->struct_mutex);
   220	
   221		/* Pin the GGTT vma for our access via info->screen_base.
   222		 * This also validates that any existing fb inherited from the
   223		 * BIOS is suitable for own access.
   224		 */
 > 225		ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
   226		if (ret)
   227			goto out_unlock;
   228	
   229		info = drm_fb_helper_alloc_fbi(helper);
   230		if (IS_ERR(info)) {
   231			DRM_ERROR("Failed to allocate fb_info\n");
   232			ret = PTR_ERR(info);
   233			goto out_unpin;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-20 18:01         ` kbuild test robot
@ 2015-11-24 16:46           ` Daniel Vetter
  2015-12-01  9:01               ` Jani Nikula
  0 siblings, 1 reply; 27+ messages in thread
From: Daniel Vetter @ 2015-11-24 16:46 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Chris Wilson, kbuild-all, intel-gfx, Daniel Vetter, Goel, Akash, stable

On Sat, Nov 21, 2015 at 02:01:55AM +0800, kbuild test robot wrote:
> Hi Chris,
> 
> [auto build test WARNING on drm-intel/for-linux-next]
> [cannot apply to v4.4-rc1 next-20151120]
> 
> url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Pin-the-ifbdev-for-the-info-system_base-GGTT-mmapping/20151121-003300
> base:   git://anongit.freedesktop.org/drm-intel for-linux-next
> reproduce:
>         # apt-get install sparse
>         make ARCH=x86_64 allmodconfig
>         make C=1 CF=-D__CHECK_ENDIAN__
> 
> 
> sparse warnings: (new ones prefixed by >>)
> 
> >> drivers/gpu/drm/i915/intel_fbdev.c:225:58: sparse: incorrect type in argument 2 (different base types)
>    drivers/gpu/drm/i915/intel_fbdev.c:225:58:    expected struct drm_framebuffer *fb
>    drivers/gpu/drm/i915/intel_fbdev.c:225:58:    got struct drm_framebuffer base
>    drivers/gpu/drm/i915/intel_fbdev.c: In function 'intelfb_create':
>    drivers/gpu/drm/i915/intel_fbdev.c:225:41: error: incompatible type for argument 2 of 'intel_pin_and_fence_fb_obj'
>      ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
>                                             ^
>    In file included from drivers/gpu/drm/i915/intel_fbdev.c:44:0:
>    drivers/gpu/drm/i915/intel_drv.h:1098:5: note: expected 'struct drm_framebuffer *' but argument is of type 'struct drm_framebuffer'
>     int intel_pin_and_fence_fb_obj(struct drm_plane *plane,

With the missing & ack for -fixes on both patches from my side.
-Daniel

>         ^
> 
> vim +225 drivers/gpu/drm/i915/intel_fbdev.c
> 
>    209		} else {
>    210			DRM_DEBUG_KMS("re-using BIOS fb\n");
>    211			prealloc = true;
>    212			sizes->fb_width = intel_fb->base.width;
>    213			sizes->fb_height = intel_fb->base.height;
>    214		}
>    215	
>    216		obj = intel_fb->obj;
>    217		size = obj->base.size;
>    218	
>    219		mutex_lock(&dev->struct_mutex);
>    220	
>    221		/* Pin the GGTT vma for our access via info->screen_base.
>    222		 * This also validates that any existing fb inherited from the
>    223		 * BIOS is suitable for own access.
>    224		 */
>  > 225		ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
>    226		if (ret)
>    227			goto out_unlock;
>    228	
>    229		info = drm_fb_helper_alloc_fbi(helper);
>    230		if (IS_ERR(info)) {
>    231			DRM_ERROR("Failed to allocate fb_info\n");
>    232			ret = PTR_ERR(info);
>    233			goto out_unpin;
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-20 16:29       ` [PATCH v4] " Chris Wilson
                           ` (2 preceding siblings ...)
  2015-11-20 18:01         ` kbuild test robot
@ 2015-11-24 21:20         ` Lukas Wunner
  2015-12-04 16:05           ` [PATCH v5] " Chris Wilson
  3 siblings, 1 reply; 27+ messages in thread
From: Lukas Wunner @ 2015-11-24 21:20 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx, Daniel Vetter, Goel, Akash, stable

Hi Chris,

On Fri, Nov 20, 2015 at 04:29:52PM +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.
> 
> 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: stable@vger.kernel.org
> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 7ccde58f8c98..79f02e72da8a 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,8 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
>  static void intel_fbdev_destroy(struct drm_device *dev,
>  				struct intel_fbdev *ifbdev)
>  {
> +	/* Release the pinning for the info->screen_base mmaping. */
> +	i915_gem_object_ggtt_unpin(ifbdev->fb->obj);

If the call to intelfb_alloc() failed, ifbdev->fb will be NULL and
intelfb_create() will return a non-zero value. Further up in the call
stack, intel_fbdev_initial_config() will then clobber the fbdev by
calling intel_fbdev_destroy(). This will oops because you dereference
ifbdev->fb here. So you need to add:
	if (ifbdev->fb)

If intel_pin_and_fence_fb_obj() failed, intelfb_create() will likewise
return a non-zero value and the fbdev gets clobbered. This will WARN
because you're calling i915_gem_object_ggtt_unpin() even though the
pin_count is 0.

Best regards,

Lukas

>  
>  	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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-24 16:46           ` Daniel Vetter
@ 2015-12-01  9:01               ` Jani Nikula
  0 siblings, 0 replies; 27+ messages in thread
From: Jani Nikula @ 2015-12-01  9:01 UTC (permalink / raw)
  To: Daniel Vetter, kbuild test robot
  Cc: Daniel Vetter, intel-gfx, stable, Goel, Akash, kbuild-all

On Tue, 24 Nov 2015, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Sat, Nov 21, 2015 at 02:01:55AM +0800, kbuild test robot wrote:
>> Hi Chris,
>> 
>> [auto build test WARNING on drm-intel/for-linux-next]
>> [cannot apply to v4.4-rc1 next-20151120]
>> 
>> url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Pin-the-ifbdev-for-the-info-system_base-GGTT-mmapping/20151121-003300
>> base:   git://anongit.freedesktop.org/drm-intel for-linux-next
>> reproduce:
>>         # apt-get install sparse
>>         make ARCH=x86_64 allmodconfig
>>         make C=1 CF=-D__CHECK_ENDIAN__
>> 
>> 
>> sparse warnings: (new ones prefixed by >>)
>> 
>> >> drivers/gpu/drm/i915/intel_fbdev.c:225:58: sparse: incorrect type in argument 2 (different base types)
>>    drivers/gpu/drm/i915/intel_fbdev.c:225:58:    expected struct drm_framebuffer *fb
>>    drivers/gpu/drm/i915/intel_fbdev.c:225:58:    got struct drm_framebuffer base
>>    drivers/gpu/drm/i915/intel_fbdev.c: In function 'intelfb_create':
>>    drivers/gpu/drm/i915/intel_fbdev.c:225:41: error: incompatible type for argument 2 of 'intel_pin_and_fence_fb_obj'
>>      ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
>>                                             ^
>>    In file included from drivers/gpu/drm/i915/intel_fbdev.c:44:0:
>>    drivers/gpu/drm/i915/intel_drv.h:1098:5: note: expected 'struct drm_framebuffer *' but argument is of type 'struct drm_framebuffer'
>>     int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
>
> With the missing & ack for -fixes on both patches from my side.

Somehow the fact that this didn't even compile to begin with makes me
less than enthusiastic about queuing this to -fixes, let alone -stable.

BR,
Jani.



> -Daniel
>
>>         ^
>> 
>> vim +225 drivers/gpu/drm/i915/intel_fbdev.c
>> 
>>    209		} else {
>>    210			DRM_DEBUG_KMS("re-using BIOS fb\n");
>>    211			prealloc = true;
>>    212			sizes->fb_width = intel_fb->base.width;
>>    213			sizes->fb_height = intel_fb->base.height;
>>    214		}
>>    215	
>>    216		obj = intel_fb->obj;
>>    217		size = obj->base.size;
>>    218	
>>    219		mutex_lock(&dev->struct_mutex);
>>    220	
>>    221		/* Pin the GGTT vma for our access via info->screen_base.
>>    222		 * This also validates that any existing fb inherited from the
>>    223		 * BIOS is suitable for own access.
>>    224		 */
>>  > 225		ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
>>    226		if (ret)
>>    227			goto out_unlock;
>>    228	
>>    229		info = drm_fb_helper_alloc_fbi(helper);
>>    230		if (IS_ERR(info)) {
>>    231			DRM_ERROR("Failed to allocate fb_info\n");
>>    232			ret = PTR_ERR(info);
>>    233			goto out_unpin;
>> 
>> ---
>> 0-DAY kernel test infrastructure                Open Source Technology Center
>> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v4] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
@ 2015-12-01  9:01               ` Jani Nikula
  0 siblings, 0 replies; 27+ messages in thread
From: Jani Nikula @ 2015-12-01  9:01 UTC (permalink / raw)
  To: Daniel Vetter, kbuild test robot
  Cc: Daniel Vetter, intel-gfx, stable, Goel, Akash, kbuild-all

On Tue, 24 Nov 2015, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Sat, Nov 21, 2015 at 02:01:55AM +0800, kbuild test robot wrote:
>> Hi Chris,
>> 
>> [auto build test WARNING on drm-intel/for-linux-next]
>> [cannot apply to v4.4-rc1 next-20151120]
>> 
>> url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Pin-the-ifbdev-for-the-info-system_base-GGTT-mmapping/20151121-003300
>> base:   git://anongit.freedesktop.org/drm-intel for-linux-next
>> reproduce:
>>         # apt-get install sparse
>>         make ARCH=x86_64 allmodconfig
>>         make C=1 CF=-D__CHECK_ENDIAN__
>> 
>> 
>> sparse warnings: (new ones prefixed by >>)
>> 
>> >> drivers/gpu/drm/i915/intel_fbdev.c:225:58: sparse: incorrect type in argument 2 (different base types)
>>    drivers/gpu/drm/i915/intel_fbdev.c:225:58:    expected struct drm_framebuffer *fb
>>    drivers/gpu/drm/i915/intel_fbdev.c:225:58:    got struct drm_framebuffer base
>>    drivers/gpu/drm/i915/intel_fbdev.c: In function 'intelfb_create':
>>    drivers/gpu/drm/i915/intel_fbdev.c:225:41: error: incompatible type for argument 2 of 'intel_pin_and_fence_fb_obj'
>>      ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
>>                                             ^
>>    In file included from drivers/gpu/drm/i915/intel_fbdev.c:44:0:
>>    drivers/gpu/drm/i915/intel_drv.h:1098:5: note: expected 'struct drm_framebuffer *' but argument is of type 'struct drm_framebuffer'
>>     int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
>
> With the missing & ack for -fixes on both patches from my side.

Somehow the fact that this didn't even compile to begin with makes me
less than enthusiastic about queuing this to -fixes, let alone -stable.

BR,
Jani.



> -Daniel
>
>>         ^
>> 
>> vim +225 drivers/gpu/drm/i915/intel_fbdev.c
>> 
>>    209		} else {
>>    210			DRM_DEBUG_KMS("re-using BIOS fb\n");
>>    211			prealloc = true;
>>    212			sizes->fb_width = intel_fb->base.width;
>>    213			sizes->fb_height = intel_fb->base.height;
>>    214		}
>>    215	
>>    216		obj = intel_fb->obj;
>>    217		size = obj->base.size;
>>    218	
>>    219		mutex_lock(&dev->struct_mutex);
>>    220	
>>    221		/* Pin the GGTT vma for our access via info->screen_base.
>>    222		 * This also validates that any existing fb inherited from the
>>    223		 * BIOS is suitable for own access.
>>    224		 */
>>  > 225		ret = intel_pin_and_fence_fb_obj(NULL, ifbdev->fb->base, NULL);
>>    226		if (ret)
>>    227			goto out_unlock;
>>    228	
>>    229		info = drm_fb_helper_alloc_fbi(helper);
>>    230		if (IS_ERR(info)) {
>>    231			DRM_ERROR("Failed to allocate fb_info\n");
>>    232			ret = PTR_ERR(info);
>>    233			goto out_unpin;
>> 
>> ---
>> 0-DAY kernel test infrastructure                Open Source Technology Center
>> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-11-24 21:20         ` Lukas Wunner
@ 2015-12-04 16:05           ` Chris Wilson
  2015-12-06 20:33             ` Lukas Wunner
  2015-12-10 16:36               ` Ville Syrjälä
  0 siblings, 2 replies; 27+ messages in thread
From: Chris Wilson @ 2015-12-04 16:05 UTC (permalink / raw)
  To: intel-gfx
  Cc: Chris Wilson, Goel, Akash, Daniel Vetter, Jesse Barnes,
	Lukas Wunner, stable

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
---
 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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  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-10 16:36               ` Ville Syrjälä
  1 sibling, 1 reply; 27+ messages in thread
From: Lukas Wunner @ 2015-12-06 20:33 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx, Goel, Akash, Daniel Vetter, Jesse Barnes, stable

Hi Chris,

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.

It's beautiful how little code is needed to fix this. The only remaining
thing I noticed now while looking over the error paths is that these
lines in intelfb_alloc() become obsolete with your patch:

 out:
 	mutex_unlock(&dev->struct_mutex);
-	if (!IS_ERR_OR_NULL(fb))
-		drm_framebuffer_unreference(fb);
 	return ret;
 }

Because at each of the remaining "goto out" in the function,
fb can be only either an ERR_PTR or NULL.

Also, further up in the function, the declaration of fb can then be
changed thus:

-	struct drm_framebuffer *fb = NULL;
+	struct drm_framebuffer *fb;

Kind regards,

Lukas

> 
> 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
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-12-04 16:05           ` [PATCH v5] " Chris Wilson
@ 2015-12-10 16:36               ` Ville Syrjälä
  2015-12-10 16:36               ` Ville Syrjälä
  1 sibling, 0 replies; 27+ messages in thread
From: Ville Syrjälä @ 2015-12-10 16:36 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx, Daniel Vetter, stable, Goel, Akash, Takashi Iwai

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
@ 2015-12-10 16:36               ` Ville Syrjälä
  0 siblings, 0 replies; 27+ messages in thread
From: Ville Syrjälä @ 2015-12-10 16:36 UTC (permalink / raw)
  To: Chris Wilson; +Cc: Takashi Iwai, Daniel Vetter, intel-gfx, Goel, Akash, stable

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-12-10 16:36               ` Ville Syrjälä
@ 2015-12-10 16:41                 ` Takashi Iwai
  -1 siblings, 0 replies; 27+ messages in thread
From: Takashi Iwai @ 2015-12-10 16:41 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Chris Wilson, intel-gfx, Daniel Vetter, stable, Goel, Akash,
	Takashi Iwai

On Thu, 10 Dec 2015 17:36:04 +0100,
Ville Syrjälä wrote:
> 
> 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.

Great, I'll give this a try.  Thanks!


Takashi

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
@ 2015-12-10 16:41                 ` Takashi Iwai
  0 siblings, 0 replies; 27+ messages in thread
From: Takashi Iwai @ 2015-12-10 16:41 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Takashi Iwai, Daniel Vetter, intel-gfx, stable, Goel, Akash

On Thu, 10 Dec 2015 17:36:04 +0100,
Ville Syrjälä wrote:
> 
> 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.

Great, I'll give this a try.  Thanks!


Takashi
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-12-06 20:33             ` Lukas Wunner
@ 2015-12-16 10:52               ` Daniel Vetter
  2015-12-17 11:34                   ` Ville Syrjälä
  0 siblings, 1 reply; 27+ messages in thread
From: Daniel Vetter @ 2015-12-16 10:52 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: Chris Wilson, intel-gfx, Goel, Akash, Daniel Vetter,
	Jesse Barnes, stable

On Sun, Dec 06, 2015 at 09:33:20PM +0100, Lukas Wunner wrote:
> Hi Chris,
> 
> 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.
> 
> It's beautiful how little code is needed to fix this. The only remaining
> thing I noticed now while looking over the error paths is that these
> lines in intelfb_alloc() become obsolete with your patch:
> 
>  out:
>  	mutex_unlock(&dev->struct_mutex);
> -	if (!IS_ERR_OR_NULL(fb))
> -		drm_framebuffer_unreference(fb);
>  	return ret;
>  }
> 
> Because at each of the remaining "goto out" in the function,
> fb can be only either an ERR_PTR or NULL.
> 
> Also, further up in the function, the declaration of fb can then be
> changed thus:
> 
> -	struct drm_framebuffer *fb = NULL;
> +	struct drm_framebuffer *fb;
> 
> Kind regards,

Yeah there's room for follow-up polish, but this seems good enough at
least for -fixes.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Lukas, feel like supplying a patch to apply the polish you've spotted on
top?

Thanks, Daniel

> 
> Lukas
> 
> > 
> > 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
> > ---
> >  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
> > 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-12-16 10:52               ` Daniel Vetter
@ 2015-12-17 11:34                   ` Ville Syrjälä
  0 siblings, 0 replies; 27+ messages in thread
From: Ville Syrjälä @ 2015-12-17 11:34 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Lukas Wunner, Daniel Vetter, intel-gfx, stable, Goel, Akash

On Wed, Dec 16, 2015 at 11:52:17AM +0100, Daniel Vetter wrote:
> On Sun, Dec 06, 2015 at 09:33:20PM +0100, Lukas Wunner wrote:
> > Hi Chris,
> > 
> > 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.
> > 
> > It's beautiful how little code is needed to fix this. The only remaining
> > thing I noticed now while looking over the error paths is that these
> > lines in intelfb_alloc() become obsolete with your patch:
> > 
> >  out:
> >  	mutex_unlock(&dev->struct_mutex);
> > -	if (!IS_ERR_OR_NULL(fb))
> > -		drm_framebuffer_unreference(fb);
> >  	return ret;
> >  }
> > 
> > Because at each of the remaining "goto out" in the function,
> > fb can be only either an ERR_PTR or NULL.
> > 
> > Also, further up in the function, the declaration of fb can then be
> > changed thus:
> > 
> > -	struct drm_framebuffer *fb = NULL;
> > +	struct drm_framebuffer *fb;
> > 
> > Kind regards,
> 
> Yeah there's room for follow-up polish, but this seems good enough at
> least for -fixes.

I just tested when we started to fail things, and for me it only happens
with 4.4-rc releases (tested with [1]). 4.3.3 OTOH still had the fbcon fb
pinned while X was running.

[1] airlied/drm-fixes 4655a12b81ed ("drm: Don't overwrite UNVERFIED mode status to OK")

> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> Lukas, feel like supplying a patch to apply the polish you've spotted on
> top?
> 
> Thanks, Daniel
> 
> > 
> > Lukas
> > 
> > > 
> > > 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
> > > ---
> > >  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
> > > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrj�l�
Intel OTC

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
@ 2015-12-17 11:34                   ` Ville Syrjälä
  0 siblings, 0 replies; 27+ messages in thread
From: Ville Syrjälä @ 2015-12-17 11:34 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, intel-gfx, Goel, Akash, stable

On Wed, Dec 16, 2015 at 11:52:17AM +0100, Daniel Vetter wrote:
> On Sun, Dec 06, 2015 at 09:33:20PM +0100, Lukas Wunner wrote:
> > Hi Chris,
> > 
> > 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.
> > 
> > It's beautiful how little code is needed to fix this. The only remaining
> > thing I noticed now while looking over the error paths is that these
> > lines in intelfb_alloc() become obsolete with your patch:
> > 
> >  out:
> >  	mutex_unlock(&dev->struct_mutex);
> > -	if (!IS_ERR_OR_NULL(fb))
> > -		drm_framebuffer_unreference(fb);
> >  	return ret;
> >  }
> > 
> > Because at each of the remaining "goto out" in the function,
> > fb can be only either an ERR_PTR or NULL.
> > 
> > Also, further up in the function, the declaration of fb can then be
> > changed thus:
> > 
> > -	struct drm_framebuffer *fb = NULL;
> > +	struct drm_framebuffer *fb;
> > 
> > Kind regards,
> 
> Yeah there's room for follow-up polish, but this seems good enough at
> least for -fixes.

I just tested when we started to fail things, and for me it only happens
with 4.4-rc releases (tested with [1]). 4.3.3 OTOH still had the fbcon fb
pinned while X was running.

[1] airlied/drm-fixes 4655a12b81ed ("drm: Don't overwrite UNVERFIED mode status to OK")

> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> Lukas, feel like supplying a patch to apply the polish you've spotted on
> top?
> 
> Thanks, Daniel
> 
> > 
> > Lukas
> > 
> > > 
> > > 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
> > > ---
> > >  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
> > > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-12-10 16:41                 ` Takashi Iwai
@ 2015-12-17 15:59                   ` Daniel Vetter
  -1 siblings, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2015-12-17 15:59 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Ville Syrjälä,
	Chris Wilson, intel-gfx, Daniel Vetter, stable, Goel, Akash,
	Jani Nikula

On Thu, Dec 10, 2015 at 05:41:30PM +0100, Takashi Iwai wrote:
> On Thu, 10 Dec 2015 17:36:04 +0100,
> Ville Syrj�l� wrote:
> > 
> > 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.
> 
> Great, I'll give this a try.  Thanks!

Pulled both patches into dinq. Jani, can you please cherry-pick?

Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
@ 2015-12-17 15:59                   ` Daniel Vetter
  0 siblings, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2015-12-17 15:59 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Ville Syrjälä,
	Chris Wilson, intel-gfx, Daniel Vetter, stable, Goel, Akash,
	Jani Nikula

On Thu, Dec 10, 2015 at 05:41:30PM +0100, Takashi Iwai wrote:
> On Thu, 10 Dec 2015 17:36:04 +0100,
> Ville Syrjälä wrote:
> > 
> > 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.
> 
> Great, I'll give this a try.  Thanks!

Pulled both patches into dinq. Jani, can you please cherry-pick?

Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Intel-gfx] [PATCH v5] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping
  2015-12-17 15:59                   ` Daniel Vetter
  (?)
@ 2015-12-23 11:07                   ` Jani Nikula
  -1 siblings, 0 replies; 27+ messages in thread
From: Jani Nikula @ 2015-12-23 11:07 UTC (permalink / raw)
  To: Daniel Vetter, Takashi Iwai
  Cc: Ville Syrjälä,
	Chris Wilson, intel-gfx, Daniel Vetter, stable, Goel, Akash

On Thu, 17 Dec 2015, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Dec 10, 2015 at 05:41:30PM +0100, Takashi Iwai wrote:
>> On Thu, 10 Dec 2015 17:36:04 +0100,
>> Ville Syrjälä wrote:
>> > 
>> > 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.
>> 
>> Great, I'll give this a try.  Thanks!
>
> Pulled both patches into dinq. Jani, can you please cherry-pick?

Picked the first, but I don't have the time to fix the conflicts on the
second one.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2015-12-23 11:08 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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             ` [Intel-gfx] " Ville Syrjälä
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

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.