All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer
@ 2019-08-23 16:20 Chris Wilson
  2019-08-23 16:38 ` Chris Wilson
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Chris Wilson @ 2019-08-23 16:20 UTC (permalink / raw)
  To: intel-gfx

obj->pin_global was original used as a means to keep the shrinker off
the active scanout, but we use the vma->pin_count itself for that and
the obj->frontbuffer to delay shrinking active framebuffers. The other
role that obj->pin_global gained was for spotting display objects inside
GEM and working harder to keep those coherent; for which we can again
simply inspect obj->frontbuffer directly.

Coming up next, we will want to manipulate the pin_global counter
outside of the principle locks, so would need to make pin_global atomic.
However, since obj->frontbuffer is already managed atomically, it makes
sense to use that the primary key for display objects instead of having
pin_global.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 .../gpu/drm/i915/display/intel_frontbuffer.c  | 13 +++++--
 drivers/gpu/drm/i915/gem/i915_gem_domain.c    | 34 ++++++-------------
 drivers/gpu/drm/i915/gem/i915_gem_object.h    |  3 +-
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |  2 --
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c  | 15 +++-----
 drivers/gpu/drm/i915/i915_debugfs.c           | 12 ++-----
 6 files changed, 29 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
index 719379774fa5..43047b676b7b 100644
--- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c
+++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
@@ -220,11 +220,18 @@ static void frontbuffer_release(struct kref *ref)
 {
 	struct intel_frontbuffer *front =
 		container_of(ref, typeof(*front), ref);
+	struct drm_i915_gem_object *obj = front->obj;
+	struct i915_vma *vma;
 
-	front->obj->frontbuffer = NULL;
-	spin_unlock(&to_i915(front->obj->base.dev)->fb_tracking.lock);
+	spin_lock(&obj->vma.lock);
+	for_each_ggtt_vma(vma, obj)
+		vma->display_alignment = I915_GTT_PAGE_SIZE;
+	spin_unlock(&obj->vma.lock);
 
-	i915_gem_object_put(front->obj);
+	obj->frontbuffer = NULL;
+	spin_unlock(&to_i915(obj->base.dev)->fb_tracking.lock);
+
+	i915_gem_object_put(obj);
 	kfree(front);
 }
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
index 9c58e8fac1d9..0341b3da930a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
@@ -27,7 +27,7 @@ static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)
 
 void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj)
 {
-	if (!READ_ONCE(obj->pin_global))
+	if (!READ_ONCE(obj->frontbuffer))
 		return;
 
 	i915_gem_object_lock(obj);
@@ -422,12 +422,8 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 
 	assert_object_held(obj);
 
-	/* Mark the global pin early so that we account for the
-	 * display coherency whilst setting up the cache domains.
-	 */
-	obj->pin_global++;
-
-	/* The display engine is not coherent with the LLC cache on gen6.  As
+	/*
+	 * The display engine is not coherent with the LLC cache on gen6.  As
 	 * a result, we make sure that the pinning that is about to occur is
 	 * done with uncached PTEs. This is lowest common denominator for all
 	 * chipsets.
@@ -439,12 +435,11 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 	ret = i915_gem_object_set_cache_level(obj,
 					      HAS_WT(to_i915(obj->base.dev)) ?
 					      I915_CACHE_WT : I915_CACHE_NONE);
-	if (ret) {
-		vma = ERR_PTR(ret);
-		goto err_unpin_global;
-	}
+	if (ret)
+		return ERR_PTR(ret);
 
-	/* As the user may map the buffer once pinned in the display plane
+	/*
+	 * As the user may map the buffer once pinned in the display plane
 	 * (e.g. libkms for the bootup splash), we have to ensure that we
 	 * always use map_and_fenceable for all scanout buffers. However,
 	 * it may simply be too big to fit into mappable, in which case
@@ -461,22 +456,19 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 	if (IS_ERR(vma))
 		vma = i915_gem_object_ggtt_pin(obj, view, 0, alignment, flags);
 	if (IS_ERR(vma))
-		goto err_unpin_global;
+		return vma;
 
 	vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
 
 	__i915_gem_object_flush_for_display(obj);
 
-	/* It should now be out of any other write domains, and we can update
+	/*
+	 * It should now be out of any other write domains, and we can update
 	 * the domain values for our changes.
 	 */
 	obj->read_domains |= I915_GEM_DOMAIN_GTT;
 
 	return vma;
-
-err_unpin_global:
-	obj->pin_global--;
-	return vma;
 }
 
 static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
@@ -514,12 +506,6 @@ i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
 
 	assert_object_held(obj);
 
-	if (WARN_ON(obj->pin_global == 0))
-		return;
-
-	if (--obj->pin_global == 0)
-		vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
-
 	/* Bump the LRU to try and avoid premature eviction whilst flipping  */
 	i915_gem_object_bump_inactive_ggtt(obj);
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index 5efb9936e05b..d6005cad9d5c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -406,7 +406,8 @@ static inline bool cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
 	if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
 		return true;
 
-	return obj->pin_global; /* currently in use by HW, keep flushed */
+	/* Currently in use by HW (display engine)? Keep flushed. */
+	return READ_ONCE(obj->frontbuffer);
 }
 
 static inline void __start_cpu_write(struct drm_i915_gem_object *obj)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index ede0eb4218a8..13b9dc0e1a89 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -152,8 +152,6 @@ struct drm_i915_gem_object {
 
 	/** Count of VMA actually bound by this object */
 	atomic_t bind_count;
-	/** Count of how many global VMA are currently pinned for use by HW */
-	unsigned int pin_global;
 
 	struct {
 		struct mutex lock; /* protects the pages and their use */
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
index edd21d14e64f..4e55cfc2b0dc 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
@@ -61,7 +61,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
 	if (!i915_gem_object_is_shrinkable(obj))
 		return false;
 
-	/* Only report true if by unbinding the object and putting its pages
+	/*
+	 * Only report true if by unbinding the object and putting its pages
 	 * we can actually make forward progress towards freeing physical
 	 * pages.
 	 *
@@ -72,16 +73,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
 	if (atomic_read(&obj->mm.pages_pin_count) > atomic_read(&obj->bind_count))
 		return false;
 
-	/* If any vma are "permanently" pinned, it will prevent us from
-	 * reclaiming the obj->mm.pages. We only allow scanout objects to claim
-	 * a permanent pin, along with a few others like the context objects.
-	 * To simplify the scan, and to avoid walking the list of vma under the
-	 * object, we just check the count of its permanently pinned.
-	 */
-	if (READ_ONCE(obj->pin_global))
-		return false;
-
-	/* We can only return physical pages to the system if we can either
+	/*
+	 * We can only return physical pages to the system if we can either
 	 * discard the contents (because the user has marked them as being
 	 * purgeable) or if we can move their contents out to swap.
 	 */
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index e103fcba6435..b90371844689 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -77,11 +77,6 @@ static int i915_capabilities(struct seq_file *m, void *data)
 	return 0;
 }
 
-static char get_pin_flag(struct drm_i915_gem_object *obj)
-{
-	return obj->pin_global ? 'p' : ' ';
-}
-
 static char get_tiling_flag(struct drm_i915_gem_object *obj)
 {
 	switch (i915_gem_object_get_tiling(obj)) {
@@ -140,9 +135,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
 	struct i915_vma *vma;
 	int pin_count = 0;
 
-	seq_printf(m, "%pK: %c%c%c%c %8zdKiB %02x %02x %s%s%s",
+	seq_printf(m, "%pK: %c%c%c %8zdKiB %02x %02x %s%s%s",
 		   &obj->base,
-		   get_pin_flag(obj),
 		   get_tiling_flag(obj),
 		   get_global_flag(obj),
 		   get_pin_mapped_flag(obj),
@@ -221,8 +215,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
 	seq_printf(m, " (pinned x %d)", pin_count);
 	if (obj->stolen)
 		seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
-	if (obj->pin_global)
-		seq_printf(m, " (global)");
+	if (READ_ONCE(obj->frontbuffer))
+		seq_printf(m, " (front)");
 
 	engine = i915_gem_object_last_write_engine(obj);
 	if (engine)
-- 
2.23.0

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

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

* Re: [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer
  2019-08-23 16:20 [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer Chris Wilson
@ 2019-08-23 16:38 ` Chris Wilson
  2019-08-23 16:39 ` Chris Wilson
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2019-08-23 16:38 UTC (permalink / raw)
  To: intel-gfx

Quoting Chris Wilson (2019-08-23 17:20:41)
> @@ -220,11 +220,18 @@ static void frontbuffer_release(struct kref *ref)
>  {
>         struct intel_frontbuffer *front =
>                 container_of(ref, typeof(*front), ref);
> +       struct drm_i915_gem_object *obj = front->obj;
> +       struct i915_vma *vma;
>  
> -       front->obj->frontbuffer = NULL;
> -       spin_unlock(&to_i915(front->obj->base.dev)->fb_tracking.lock);
> +       spin_lock(&obj->vma.lock);
> +       for_each_ggtt_vma(vma, obj)
> +               vma->display_alignment = I915_GTT_PAGE_SIZE;

Should be I915_GTT_MIN_ALIGNMENT instead.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer
  2019-08-23 16:20 [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer Chris Wilson
  2019-08-23 16:38 ` Chris Wilson
@ 2019-08-23 16:39 ` Chris Wilson
  2019-08-23 16:48 ` Ville Syrjälä
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2019-08-23 16:39 UTC (permalink / raw)
  To: intel-gfx

obj->pin_global was original used as a means to keep the shrinker off
the active scanout, but we use the vma->pin_count itself for that and
the obj->frontbuffer to delay shrinking active framebuffers. The other
role that obj->pin_global gained was for spotting display objects inside
GEM and working harder to keep those coherent; for which we can again
simply inspect obj->frontbuffer directly.

Coming up next, we will want to manipulate the pin_global counter
outside of the principle locks, so would need to make pin_global atomic.
However, since obj->frontbuffer is already managed atomically, it makes
sense to use that the primary key for display objects instead of having
pin_global.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 .../gpu/drm/i915/display/intel_frontbuffer.c  | 13 +++++--
 drivers/gpu/drm/i915/gem/i915_gem_domain.c    | 34 ++++++-------------
 drivers/gpu/drm/i915/gem/i915_gem_object.h    |  3 +-
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |  2 --
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c  | 15 +++-----
 drivers/gpu/drm/i915/i915_debugfs.c           | 12 ++-----
 6 files changed, 29 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
index 719379774fa5..fc40dc1fdbcc 100644
--- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c
+++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
@@ -220,11 +220,18 @@ static void frontbuffer_release(struct kref *ref)
 {
 	struct intel_frontbuffer *front =
 		container_of(ref, typeof(*front), ref);
+	struct drm_i915_gem_object *obj = front->obj;
+	struct i915_vma *vma;
 
-	front->obj->frontbuffer = NULL;
-	spin_unlock(&to_i915(front->obj->base.dev)->fb_tracking.lock);
+	spin_lock(&obj->vma.lock);
+	for_each_ggtt_vma(vma, obj)
+		vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
+	spin_unlock(&obj->vma.lock);
 
-	i915_gem_object_put(front->obj);
+	obj->frontbuffer = NULL;
+	spin_unlock(&to_i915(obj->base.dev)->fb_tracking.lock);
+
+	i915_gem_object_put(obj);
 	kfree(front);
 }
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
index 9c58e8fac1d9..0341b3da930a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
@@ -27,7 +27,7 @@ static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)
 
 void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj)
 {
-	if (!READ_ONCE(obj->pin_global))
+	if (!READ_ONCE(obj->frontbuffer))
 		return;
 
 	i915_gem_object_lock(obj);
@@ -422,12 +422,8 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 
 	assert_object_held(obj);
 
-	/* Mark the global pin early so that we account for the
-	 * display coherency whilst setting up the cache domains.
-	 */
-	obj->pin_global++;
-
-	/* The display engine is not coherent with the LLC cache on gen6.  As
+	/*
+	 * The display engine is not coherent with the LLC cache on gen6.  As
 	 * a result, we make sure that the pinning that is about to occur is
 	 * done with uncached PTEs. This is lowest common denominator for all
 	 * chipsets.
@@ -439,12 +435,11 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 	ret = i915_gem_object_set_cache_level(obj,
 					      HAS_WT(to_i915(obj->base.dev)) ?
 					      I915_CACHE_WT : I915_CACHE_NONE);
-	if (ret) {
-		vma = ERR_PTR(ret);
-		goto err_unpin_global;
-	}
+	if (ret)
+		return ERR_PTR(ret);
 
-	/* As the user may map the buffer once pinned in the display plane
+	/*
+	 * As the user may map the buffer once pinned in the display plane
 	 * (e.g. libkms for the bootup splash), we have to ensure that we
 	 * always use map_and_fenceable for all scanout buffers. However,
 	 * it may simply be too big to fit into mappable, in which case
@@ -461,22 +456,19 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 	if (IS_ERR(vma))
 		vma = i915_gem_object_ggtt_pin(obj, view, 0, alignment, flags);
 	if (IS_ERR(vma))
-		goto err_unpin_global;
+		return vma;
 
 	vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
 
 	__i915_gem_object_flush_for_display(obj);
 
-	/* It should now be out of any other write domains, and we can update
+	/*
+	 * It should now be out of any other write domains, and we can update
 	 * the domain values for our changes.
 	 */
 	obj->read_domains |= I915_GEM_DOMAIN_GTT;
 
 	return vma;
-
-err_unpin_global:
-	obj->pin_global--;
-	return vma;
 }
 
 static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
@@ -514,12 +506,6 @@ i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
 
 	assert_object_held(obj);
 
-	if (WARN_ON(obj->pin_global == 0))
-		return;
-
-	if (--obj->pin_global == 0)
-		vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
-
 	/* Bump the LRU to try and avoid premature eviction whilst flipping  */
 	i915_gem_object_bump_inactive_ggtt(obj);
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index 5efb9936e05b..d6005cad9d5c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -406,7 +406,8 @@ static inline bool cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
 	if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
 		return true;
 
-	return obj->pin_global; /* currently in use by HW, keep flushed */
+	/* Currently in use by HW (display engine)? Keep flushed. */
+	return READ_ONCE(obj->frontbuffer);
 }
 
 static inline void __start_cpu_write(struct drm_i915_gem_object *obj)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index ede0eb4218a8..13b9dc0e1a89 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -152,8 +152,6 @@ struct drm_i915_gem_object {
 
 	/** Count of VMA actually bound by this object */
 	atomic_t bind_count;
-	/** Count of how many global VMA are currently pinned for use by HW */
-	unsigned int pin_global;
 
 	struct {
 		struct mutex lock; /* protects the pages and their use */
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
index edd21d14e64f..4e55cfc2b0dc 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
@@ -61,7 +61,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
 	if (!i915_gem_object_is_shrinkable(obj))
 		return false;
 
-	/* Only report true if by unbinding the object and putting its pages
+	/*
+	 * Only report true if by unbinding the object and putting its pages
 	 * we can actually make forward progress towards freeing physical
 	 * pages.
 	 *
@@ -72,16 +73,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
 	if (atomic_read(&obj->mm.pages_pin_count) > atomic_read(&obj->bind_count))
 		return false;
 
-	/* If any vma are "permanently" pinned, it will prevent us from
-	 * reclaiming the obj->mm.pages. We only allow scanout objects to claim
-	 * a permanent pin, along with a few others like the context objects.
-	 * To simplify the scan, and to avoid walking the list of vma under the
-	 * object, we just check the count of its permanently pinned.
-	 */
-	if (READ_ONCE(obj->pin_global))
-		return false;
-
-	/* We can only return physical pages to the system if we can either
+	/*
+	 * We can only return physical pages to the system if we can either
 	 * discard the contents (because the user has marked them as being
 	 * purgeable) or if we can move their contents out to swap.
 	 */
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index e103fcba6435..b90371844689 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -77,11 +77,6 @@ static int i915_capabilities(struct seq_file *m, void *data)
 	return 0;
 }
 
-static char get_pin_flag(struct drm_i915_gem_object *obj)
-{
-	return obj->pin_global ? 'p' : ' ';
-}
-
 static char get_tiling_flag(struct drm_i915_gem_object *obj)
 {
 	switch (i915_gem_object_get_tiling(obj)) {
@@ -140,9 +135,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
 	struct i915_vma *vma;
 	int pin_count = 0;
 
-	seq_printf(m, "%pK: %c%c%c%c %8zdKiB %02x %02x %s%s%s",
+	seq_printf(m, "%pK: %c%c%c %8zdKiB %02x %02x %s%s%s",
 		   &obj->base,
-		   get_pin_flag(obj),
 		   get_tiling_flag(obj),
 		   get_global_flag(obj),
 		   get_pin_mapped_flag(obj),
@@ -221,8 +215,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
 	seq_printf(m, " (pinned x %d)", pin_count);
 	if (obj->stolen)
 		seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
-	if (obj->pin_global)
-		seq_printf(m, " (global)");
+	if (READ_ONCE(obj->frontbuffer))
+		seq_printf(m, " (front)");
 
 	engine = i915_gem_object_last_write_engine(obj);
 	if (engine)
-- 
2.23.0

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

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

* Re: [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer
  2019-08-23 16:20 [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer Chris Wilson
  2019-08-23 16:38 ` Chris Wilson
  2019-08-23 16:39 ` Chris Wilson
@ 2019-08-23 16:48 ` Ville Syrjälä
  2019-08-23 17:03   ` Chris Wilson
  2019-08-23 17:11 ` Chris Wilson
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: Ville Syrjälä @ 2019-08-23 16:48 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Fri, Aug 23, 2019 at 05:20:41PM +0100, Chris Wilson wrote:
> obj->pin_global was original used as a means to keep the shrinker off
> the active scanout, but we use the vma->pin_count itself for that and
> the obj->frontbuffer to delay shrinking active framebuffers. The other
> role that obj->pin_global gained was for spotting display objects inside
> GEM and working harder to keep those coherent; for which we can again
> simply inspect obj->frontbuffer directly.
> 
> Coming up next, we will want to manipulate the pin_global counter
> outside of the principle locks, so would need to make pin_global atomic.
> However, since obj->frontbuffer is already managed atomically, it makes
> sense to use that the primary key for display objects instead of having
> pin_global.

The difference being that pin_global was only incremented while active
scanout was happening, but obj->frontbuffer simply indicates that the
obj is attached to at least one framebuffer regardless of whether it's
ever scanned out or not.

> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
>  .../gpu/drm/i915/display/intel_frontbuffer.c  | 13 +++++--
>  drivers/gpu/drm/i915/gem/i915_gem_domain.c    | 34 ++++++-------------
>  drivers/gpu/drm/i915/gem/i915_gem_object.h    |  3 +-
>  .../gpu/drm/i915/gem/i915_gem_object_types.h  |  2 --
>  drivers/gpu/drm/i915/gem/i915_gem_shrinker.c  | 15 +++-----
>  drivers/gpu/drm/i915/i915_debugfs.c           | 12 ++-----
>  6 files changed, 29 insertions(+), 50 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> index 719379774fa5..43047b676b7b 100644
> --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> @@ -220,11 +220,18 @@ static void frontbuffer_release(struct kref *ref)
>  {
>  	struct intel_frontbuffer *front =
>  		container_of(ref, typeof(*front), ref);
> +	struct drm_i915_gem_object *obj = front->obj;
> +	struct i915_vma *vma;
>  
> -	front->obj->frontbuffer = NULL;
> -	spin_unlock(&to_i915(front->obj->base.dev)->fb_tracking.lock);
> +	spin_lock(&obj->vma.lock);
> +	for_each_ggtt_vma(vma, obj)
> +		vma->display_alignment = I915_GTT_PAGE_SIZE;
> +	spin_unlock(&obj->vma.lock);
>  
> -	i915_gem_object_put(front->obj);
> +	obj->frontbuffer = NULL;
> +	spin_unlock(&to_i915(obj->base.dev)->fb_tracking.lock);
> +
> +	i915_gem_object_put(obj);
>  	kfree(front);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> index 9c58e8fac1d9..0341b3da930a 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> @@ -27,7 +27,7 @@ static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)
>  
>  void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj)
>  {
> -	if (!READ_ONCE(obj->pin_global))
> +	if (!READ_ONCE(obj->frontbuffer))
>  		return;

So we maybe get a few more flushes now?

>  
>  	i915_gem_object_lock(obj);
> @@ -422,12 +422,8 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
>  
>  	assert_object_held(obj);
>  
> -	/* Mark the global pin early so that we account for the
> -	 * display coherency whilst setting up the cache domains.
> -	 */
> -	obj->pin_global++;
> -
> -	/* The display engine is not coherent with the LLC cache on gen6.  As
> +	/*
> +	 * The display engine is not coherent with the LLC cache on gen6.  As
>  	 * a result, we make sure that the pinning that is about to occur is
>  	 * done with uncached PTEs. This is lowest common denominator for all
>  	 * chipsets.
> @@ -439,12 +435,11 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
>  	ret = i915_gem_object_set_cache_level(obj,
>  					      HAS_WT(to_i915(obj->base.dev)) ?
>  					      I915_CACHE_WT : I915_CACHE_NONE);
> -	if (ret) {
> -		vma = ERR_PTR(ret);
> -		goto err_unpin_global;
> -	}
> +	if (ret)
> +		return ERR_PTR(ret);
>  
> -	/* As the user may map the buffer once pinned in the display plane
> +	/*
> +	 * As the user may map the buffer once pinned in the display plane
>  	 * (e.g. libkms for the bootup splash), we have to ensure that we
>  	 * always use map_and_fenceable for all scanout buffers. However,
>  	 * it may simply be too big to fit into mappable, in which case
> @@ -461,22 +456,19 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
>  	if (IS_ERR(vma))
>  		vma = i915_gem_object_ggtt_pin(obj, view, 0, alignment, flags);
>  	if (IS_ERR(vma))
> -		goto err_unpin_global;
> +		return vma;
>  
>  	vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
>  
>  	__i915_gem_object_flush_for_display(obj);
>  
> -	/* It should now be out of any other write domains, and we can update
> +	/*
> +	 * It should now be out of any other write domains, and we can update
>  	 * the domain values for our changes.
>  	 */
>  	obj->read_domains |= I915_GEM_DOMAIN_GTT;
>  
>  	return vma;
> -
> -err_unpin_global:
> -	obj->pin_global--;
> -	return vma;
>  }
>  
>  static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
> @@ -514,12 +506,6 @@ i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
>  
>  	assert_object_held(obj);
>  
> -	if (WARN_ON(obj->pin_global == 0))
> -		return;
> -
> -	if (--obj->pin_global == 0)
> -		vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
> -
>  	/* Bump the LRU to try and avoid premature eviction whilst flipping  */
>  	i915_gem_object_bump_inactive_ggtt(obj);
>  
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> index 5efb9936e05b..d6005cad9d5c 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> @@ -406,7 +406,8 @@ static inline bool cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
>  	if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
>  		return true;
>  
> -	return obj->pin_global; /* currently in use by HW, keep flushed */
> +	/* Currently in use by HW (display engine)? Keep flushed. */
> +	return READ_ONCE(obj->frontbuffer);
>  }
>  
>  static inline void __start_cpu_write(struct drm_i915_gem_object *obj)
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> index ede0eb4218a8..13b9dc0e1a89 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> @@ -152,8 +152,6 @@ struct drm_i915_gem_object {
>  
>  	/** Count of VMA actually bound by this object */
>  	atomic_t bind_count;
> -	/** Count of how many global VMA are currently pinned for use by HW */
> -	unsigned int pin_global;
>  
>  	struct {
>  		struct mutex lock; /* protects the pages and their use */
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> index edd21d14e64f..4e55cfc2b0dc 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> @@ -61,7 +61,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
>  	if (!i915_gem_object_is_shrinkable(obj))
>  		return false;
>  
> -	/* Only report true if by unbinding the object and putting its pages
> +	/*
> +	 * Only report true if by unbinding the object and putting its pages
>  	 * we can actually make forward progress towards freeing physical
>  	 * pages.
>  	 *
> @@ -72,16 +73,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
>  	if (atomic_read(&obj->mm.pages_pin_count) > atomic_read(&obj->bind_count))
>  		return false;
>  
> -	/* If any vma are "permanently" pinned, it will prevent us from
> -	 * reclaiming the obj->mm.pages. We only allow scanout objects to claim
> -	 * a permanent pin, along with a few others like the context objects.
> -	 * To simplify the scan, and to avoid walking the list of vma under the
> -	 * object, we just check the count of its permanently pinned.
> -	 */
> -	if (READ_ONCE(obj->pin_global))
> -		return false;

Are we giving the shrinker false hope here when it comes to the actual
frontbuffer?

> -
> -	/* We can only return physical pages to the system if we can either
> +	/*
> +	 * We can only return physical pages to the system if we can either
>  	 * discard the contents (because the user has marked them as being
>  	 * purgeable) or if we can move their contents out to swap.
>  	 */
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index e103fcba6435..b90371844689 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -77,11 +77,6 @@ static int i915_capabilities(struct seq_file *m, void *data)
>  	return 0;
>  }
>  
> -static char get_pin_flag(struct drm_i915_gem_object *obj)
> -{
> -	return obj->pin_global ? 'p' : ' ';
> -}
> -
>  static char get_tiling_flag(struct drm_i915_gem_object *obj)
>  {
>  	switch (i915_gem_object_get_tiling(obj)) {
> @@ -140,9 +135,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
>  	struct i915_vma *vma;
>  	int pin_count = 0;
>  
> -	seq_printf(m, "%pK: %c%c%c%c %8zdKiB %02x %02x %s%s%s",
> +	seq_printf(m, "%pK: %c%c%c %8zdKiB %02x %02x %s%s%s",
>  		   &obj->base,
> -		   get_pin_flag(obj),
>  		   get_tiling_flag(obj),
>  		   get_global_flag(obj),
>  		   get_pin_mapped_flag(obj),
> @@ -221,8 +215,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
>  	seq_printf(m, " (pinned x %d)", pin_count);
>  	if (obj->stolen)
>  		seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
> -	if (obj->pin_global)
> -		seq_printf(m, " (global)");
> +	if (READ_ONCE(obj->frontbuffer))
> +		seq_printf(m, " (front)");

A bit confusing to say it's "front" when in fact it can be any random backbuffer.
Maybe should be just "fb" or something?

>  
>  	engine = i915_gem_object_last_write_engine(obj);
>  	if (engine)
> -- 
> 2.23.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

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

* Re: [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer
  2019-08-23 16:48 ` Ville Syrjälä
@ 2019-08-23 17:03   ` Chris Wilson
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2019-08-23 17:03 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

Quoting Ville Syrjälä (2019-08-23 17:48:49)
> On Fri, Aug 23, 2019 at 05:20:41PM +0100, Chris Wilson wrote:
> > obj->pin_global was original used as a means to keep the shrinker off
> > the active scanout, but we use the vma->pin_count itself for that and
> > the obj->frontbuffer to delay shrinking active framebuffers. The other
> > role that obj->pin_global gained was for spotting display objects inside
> > GEM and working harder to keep those coherent; for which we can again
> > simply inspect obj->frontbuffer directly.
> > 
> > Coming up next, we will want to manipulate the pin_global counter
> > outside of the principle locks, so would need to make pin_global atomic.
> > However, since obj->frontbuffer is already managed atomically, it makes
> > sense to use that the primary key for display objects instead of having
> > pin_global.
> 
> The difference being that pin_global was only incremented while active
> scanout was happening, but obj->frontbuffer simply indicates that the
> obj is attached to at least one framebuffer regardless of whether it's
> ever scanned out or not.

cpu_write_needs_clflush() is the main culprit there,
 i915_gem_pwrite_ioctl
 i915_gem_set_domain_ioctl(CPU, CPU)
which I hope we truly do not have to worry about are being heavily used
on framebuffer objects.

flush_if_display() is only used on framebuffer objects
 intel_user_framebuffer_dirty (DIRTYFB_IOCTL)
 i915_gem_sw_finish_ioctl (which should not be used!)
and then they only actually do anything if the CPU cache is dirty from
either of the above ioctls or set-cache-level, or after rendering with
EXEC_OBJECT_WRITE into an LLC object.

> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> > ---
> >  .../gpu/drm/i915/display/intel_frontbuffer.c  | 13 +++++--
> >  drivers/gpu/drm/i915/gem/i915_gem_domain.c    | 34 ++++++-------------
> >  drivers/gpu/drm/i915/gem/i915_gem_object.h    |  3 +-
> >  .../gpu/drm/i915/gem/i915_gem_object_types.h  |  2 --
> >  drivers/gpu/drm/i915/gem/i915_gem_shrinker.c  | 15 +++-----
> >  drivers/gpu/drm/i915/i915_debugfs.c           | 12 ++-----
> >  6 files changed, 29 insertions(+), 50 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> > index 719379774fa5..43047b676b7b 100644
> > --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> > +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> > @@ -220,11 +220,18 @@ static void frontbuffer_release(struct kref *ref)
> >  {
> >       struct intel_frontbuffer *front =
> >               container_of(ref, typeof(*front), ref);
> > +     struct drm_i915_gem_object *obj = front->obj;
> > +     struct i915_vma *vma;
> >  
> > -     front->obj->frontbuffer = NULL;
> > -     spin_unlock(&to_i915(front->obj->base.dev)->fb_tracking.lock);
> > +     spin_lock(&obj->vma.lock);
> > +     for_each_ggtt_vma(vma, obj)
> > +             vma->display_alignment = I915_GTT_PAGE_SIZE;
> > +     spin_unlock(&obj->vma.lock);
> >  
> > -     i915_gem_object_put(front->obj);
> > +     obj->frontbuffer = NULL;
> > +     spin_unlock(&to_i915(obj->base.dev)->fb_tracking.lock);
> > +
> > +     i915_gem_object_put(obj);
> >       kfree(front);
> >  }
> >  
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> > index 9c58e8fac1d9..0341b3da930a 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> > @@ -27,7 +27,7 @@ static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)
> >  
> >  void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj)
> >  {
> > -     if (!READ_ONCE(obj->pin_global))
> > +     if (!READ_ONCE(obj->frontbuffer))
> >               return;
> 
> So we maybe get a few more flushes now?

Looking at the call paths, a few, but realistically only on paths that
would already be flushing their framebuffer objects.

> >       i915_gem_object_lock(obj);
> > @@ -422,12 +422,8 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
> >  
> >       assert_object_held(obj);
> >  
> > -     /* Mark the global pin early so that we account for the
> > -      * display coherency whilst setting up the cache domains.
> > -      */
> > -     obj->pin_global++;
> > -
> > -     /* The display engine is not coherent with the LLC cache on gen6.  As
> > +     /*
> > +      * The display engine is not coherent with the LLC cache on gen6.  As
> >        * a result, we make sure that the pinning that is about to occur is
> >        * done with uncached PTEs. This is lowest common denominator for all
> >        * chipsets.
> > @@ -439,12 +435,11 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
> >       ret = i915_gem_object_set_cache_level(obj,
> >                                             HAS_WT(to_i915(obj->base.dev)) ?
> >                                             I915_CACHE_WT : I915_CACHE_NONE);
> > -     if (ret) {
> > -             vma = ERR_PTR(ret);
> > -             goto err_unpin_global;
> > -     }
> > +     if (ret)
> > +             return ERR_PTR(ret);
> >  
> > -     /* As the user may map the buffer once pinned in the display plane
> > +     /*
> > +      * As the user may map the buffer once pinned in the display plane
> >        * (e.g. libkms for the bootup splash), we have to ensure that we
> >        * always use map_and_fenceable for all scanout buffers. However,
> >        * it may simply be too big to fit into mappable, in which case
> > @@ -461,22 +456,19 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
> >       if (IS_ERR(vma))
> >               vma = i915_gem_object_ggtt_pin(obj, view, 0, alignment, flags);
> >       if (IS_ERR(vma))
> > -             goto err_unpin_global;
> > +             return vma;
> >  
> >       vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
> >  
> >       __i915_gem_object_flush_for_display(obj);
> >  
> > -     /* It should now be out of any other write domains, and we can update
> > +     /*
> > +      * It should now be out of any other write domains, and we can update
> >        * the domain values for our changes.
> >        */
> >       obj->read_domains |= I915_GEM_DOMAIN_GTT;
> >  
> >       return vma;
> > -
> > -err_unpin_global:
> > -     obj->pin_global--;
> > -     return vma;
> >  }
> >  
> >  static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
> > @@ -514,12 +506,6 @@ i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
> >  
> >       assert_object_held(obj);
> >  
> > -     if (WARN_ON(obj->pin_global == 0))
> > -             return;
> > -
> > -     if (--obj->pin_global == 0)
> > -             vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
> > -
> >       /* Bump the LRU to try and avoid premature eviction whilst flipping  */
> >       i915_gem_object_bump_inactive_ggtt(obj);
> >  
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> > index 5efb9936e05b..d6005cad9d5c 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> > @@ -406,7 +406,8 @@ static inline bool cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
> >       if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
> >               return true;
> >  
> > -     return obj->pin_global; /* currently in use by HW, keep flushed */
> > +     /* Currently in use by HW (display engine)? Keep flushed. */
> > +     return READ_ONCE(obj->frontbuffer);
> >  }
> >  
> >  static inline void __start_cpu_write(struct drm_i915_gem_object *obj)
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> > index ede0eb4218a8..13b9dc0e1a89 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> > @@ -152,8 +152,6 @@ struct drm_i915_gem_object {
> >  
> >       /** Count of VMA actually bound by this object */
> >       atomic_t bind_count;
> > -     /** Count of how many global VMA are currently pinned for use by HW */
> > -     unsigned int pin_global;
> >  
> >       struct {
> >               struct mutex lock; /* protects the pages and their use */
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> > index edd21d14e64f..4e55cfc2b0dc 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> > @@ -61,7 +61,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
> >       if (!i915_gem_object_is_shrinkable(obj))
> >               return false;
> >  
> > -     /* Only report true if by unbinding the object and putting its pages
> > +     /*
> > +      * Only report true if by unbinding the object and putting its pages
> >        * we can actually make forward progress towards freeing physical
> >        * pages.
> >        *
> > @@ -72,16 +73,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
> >       if (atomic_read(&obj->mm.pages_pin_count) > atomic_read(&obj->bind_count))
> >               return false;
> >  
> > -     /* If any vma are "permanently" pinned, it will prevent us from
> > -      * reclaiming the obj->mm.pages. We only allow scanout objects to claim
> > -      * a permanent pin, along with a few others like the context objects.
> > -      * To simplify the scan, and to avoid walking the list of vma under the
> > -      * object, we just check the count of its permanently pinned.
> > -      */
> > -     if (READ_ONCE(obj->pin_global))
> > -             return false;
> 
> Are we giving the shrinker false hope here when it comes to the actual
> frontbuffer?

Only under duress, as we have

if (!(shrink & I915_SHRINK_ACTIVE) &&
      i915_gem_object_is_framebuffer(obj))
	continue;

and so don't try any framebuffers until kswapd or oom.

> > -     /* We can only return physical pages to the system if we can either
> > +     /*
> > +      * We can only return physical pages to the system if we can either
> >        * discard the contents (because the user has marked them as being
> >        * purgeable) or if we can move their contents out to swap.
> >        */
> > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> > index e103fcba6435..b90371844689 100644
> > --- a/drivers/gpu/drm/i915/i915_debugfs.c
> > +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> > @@ -77,11 +77,6 @@ static int i915_capabilities(struct seq_file *m, void *data)
> >       return 0;
> >  }
> >  
> > -static char get_pin_flag(struct drm_i915_gem_object *obj)
> > -{
> > -     return obj->pin_global ? 'p' : ' ';
> > -}
> > -
> >  static char get_tiling_flag(struct drm_i915_gem_object *obj)
> >  {
> >       switch (i915_gem_object_get_tiling(obj)) {
> > @@ -140,9 +135,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
> >       struct i915_vma *vma;
> >       int pin_count = 0;
> >  
> > -     seq_printf(m, "%pK: %c%c%c%c %8zdKiB %02x %02x %s%s%s",
> > +     seq_printf(m, "%pK: %c%c%c %8zdKiB %02x %02x %s%s%s",
> >                  &obj->base,
> > -                get_pin_flag(obj),
> >                  get_tiling_flag(obj),
> >                  get_global_flag(obj),
> >                  get_pin_mapped_flag(obj),
> > @@ -221,8 +215,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
> >       seq_printf(m, " (pinned x %d)", pin_count);
> >       if (obj->stolen)
> >               seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
> > -     if (obj->pin_global)
> > -             seq_printf(m, " (global)");
> > +     if (READ_ONCE(obj->frontbuffer))
> > +             seq_printf(m, " (front)");
> 
> A bit confusing to say it's "front" when in fact it can be any random backbuffer.
> Maybe should be just "fb" or something?

Having just spotted we already have i915_gem_object_is_framebuffer(), fb
is consistent.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer
  2019-08-23 16:20 [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer Chris Wilson
                   ` (2 preceding siblings ...)
  2019-08-23 16:48 ` Ville Syrjälä
@ 2019-08-23 17:11 ` Chris Wilson
  2019-09-02 11:50   ` Ville Syrjälä
  2019-08-23 20:12 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3) Patchwork
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: Chris Wilson @ 2019-08-23 17:11 UTC (permalink / raw)
  To: intel-gfx

obj->pin_global was original used as a means to keep the shrinker off
the active scanout, but we use the vma->pin_count itself for that and
the obj->frontbuffer to delay shrinking active framebuffers. The other
role that obj->pin_global gained was for spotting display objects inside
GEM and working harder to keep those coherent; for which we can again
simply inspect obj->frontbuffer directly.

Coming up next, we will want to manipulate the pin_global counter
outside of the principle locks, so would need to make pin_global atomic.
However, since obj->frontbuffer is already managed atomically, it makes
sense to use that the primary key for display objects instead of having
pin_global.

Ville pointed out the principle difference is that obj->frontbuffer is
set for as long as an intel_frambuffer is attached to an object, but
obj->pin_global was only raised for as long as the object was active. In
practice, this means that we consider the object as being on the scanout
for longer than is strictly required, causing us to be more proactive in
flushing -- though it should be true that we would have flushed
eventually when the back became the front, except that on the flip path
that flush is aync but when hit from another ioctl it will be
synchronous.

v2: i915_gem_object_is_framebuffer()

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 .../gpu/drm/i915/display/intel_frontbuffer.c  | 13 +++++--
 drivers/gpu/drm/i915/gem/i915_gem_domain.c    | 34 ++++++-------------
 drivers/gpu/drm/i915/gem/i915_gem_object.h    |  3 +-
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |  2 --
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c  | 15 +++-----
 drivers/gpu/drm/i915/i915_debugfs.c           | 12 ++-----
 6 files changed, 29 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
index 719379774fa5..fc40dc1fdbcc 100644
--- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c
+++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
@@ -220,11 +220,18 @@ static void frontbuffer_release(struct kref *ref)
 {
 	struct intel_frontbuffer *front =
 		container_of(ref, typeof(*front), ref);
+	struct drm_i915_gem_object *obj = front->obj;
+	struct i915_vma *vma;
 
-	front->obj->frontbuffer = NULL;
-	spin_unlock(&to_i915(front->obj->base.dev)->fb_tracking.lock);
+	spin_lock(&obj->vma.lock);
+	for_each_ggtt_vma(vma, obj)
+		vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
+	spin_unlock(&obj->vma.lock);
 
-	i915_gem_object_put(front->obj);
+	obj->frontbuffer = NULL;
+	spin_unlock(&to_i915(obj->base.dev)->fb_tracking.lock);
+
+	i915_gem_object_put(obj);
 	kfree(front);
 }
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
index 9c58e8fac1d9..6af740a5e3db 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
@@ -27,7 +27,7 @@ static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)
 
 void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj)
 {
-	if (!READ_ONCE(obj->pin_global))
+	if (!i915_gem_object_is_framebuffer(obj))
 		return;
 
 	i915_gem_object_lock(obj);
@@ -422,12 +422,8 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 
 	assert_object_held(obj);
 
-	/* Mark the global pin early so that we account for the
-	 * display coherency whilst setting up the cache domains.
-	 */
-	obj->pin_global++;
-
-	/* The display engine is not coherent with the LLC cache on gen6.  As
+	/*
+	 * The display engine is not coherent with the LLC cache on gen6.  As
 	 * a result, we make sure that the pinning that is about to occur is
 	 * done with uncached PTEs. This is lowest common denominator for all
 	 * chipsets.
@@ -439,12 +435,11 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 	ret = i915_gem_object_set_cache_level(obj,
 					      HAS_WT(to_i915(obj->base.dev)) ?
 					      I915_CACHE_WT : I915_CACHE_NONE);
-	if (ret) {
-		vma = ERR_PTR(ret);
-		goto err_unpin_global;
-	}
+	if (ret)
+		return ERR_PTR(ret);
 
-	/* As the user may map the buffer once pinned in the display plane
+	/*
+	 * As the user may map the buffer once pinned in the display plane
 	 * (e.g. libkms for the bootup splash), we have to ensure that we
 	 * always use map_and_fenceable for all scanout buffers. However,
 	 * it may simply be too big to fit into mappable, in which case
@@ -461,22 +456,19 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 	if (IS_ERR(vma))
 		vma = i915_gem_object_ggtt_pin(obj, view, 0, alignment, flags);
 	if (IS_ERR(vma))
-		goto err_unpin_global;
+		return vma;
 
 	vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
 
 	__i915_gem_object_flush_for_display(obj);
 
-	/* It should now be out of any other write domains, and we can update
+	/*
+	 * It should now be out of any other write domains, and we can update
 	 * the domain values for our changes.
 	 */
 	obj->read_domains |= I915_GEM_DOMAIN_GTT;
 
 	return vma;
-
-err_unpin_global:
-	obj->pin_global--;
-	return vma;
 }
 
 static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
@@ -514,12 +506,6 @@ i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
 
 	assert_object_held(obj);
 
-	if (WARN_ON(obj->pin_global == 0))
-		return;
-
-	if (--obj->pin_global == 0)
-		vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
-
 	/* Bump the LRU to try and avoid premature eviction whilst flipping  */
 	i915_gem_object_bump_inactive_ggtt(obj);
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index 5efb9936e05b..29b9eddc4c7f 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -406,7 +406,8 @@ static inline bool cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
 	if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
 		return true;
 
-	return obj->pin_global; /* currently in use by HW, keep flushed */
+	/* Currently in use by HW (display engine)? Keep flushed. */
+	return i915_gem_object_is_framebuffer(obj);
 }
 
 static inline void __start_cpu_write(struct drm_i915_gem_object *obj)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index ede0eb4218a8..13b9dc0e1a89 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -152,8 +152,6 @@ struct drm_i915_gem_object {
 
 	/** Count of VMA actually bound by this object */
 	atomic_t bind_count;
-	/** Count of how many global VMA are currently pinned for use by HW */
-	unsigned int pin_global;
 
 	struct {
 		struct mutex lock; /* protects the pages and their use */
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
index edd21d14e64f..4e55cfc2b0dc 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
@@ -61,7 +61,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
 	if (!i915_gem_object_is_shrinkable(obj))
 		return false;
 
-	/* Only report true if by unbinding the object and putting its pages
+	/*
+	 * Only report true if by unbinding the object and putting its pages
 	 * we can actually make forward progress towards freeing physical
 	 * pages.
 	 *
@@ -72,16 +73,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
 	if (atomic_read(&obj->mm.pages_pin_count) > atomic_read(&obj->bind_count))
 		return false;
 
-	/* If any vma are "permanently" pinned, it will prevent us from
-	 * reclaiming the obj->mm.pages. We only allow scanout objects to claim
-	 * a permanent pin, along with a few others like the context objects.
-	 * To simplify the scan, and to avoid walking the list of vma under the
-	 * object, we just check the count of its permanently pinned.
-	 */
-	if (READ_ONCE(obj->pin_global))
-		return false;
-
-	/* We can only return physical pages to the system if we can either
+	/*
+	 * We can only return physical pages to the system if we can either
 	 * discard the contents (because the user has marked them as being
 	 * purgeable) or if we can move their contents out to swap.
 	 */
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index e103fcba6435..4aa7caa3aa28 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -77,11 +77,6 @@ static int i915_capabilities(struct seq_file *m, void *data)
 	return 0;
 }
 
-static char get_pin_flag(struct drm_i915_gem_object *obj)
-{
-	return obj->pin_global ? 'p' : ' ';
-}
-
 static char get_tiling_flag(struct drm_i915_gem_object *obj)
 {
 	switch (i915_gem_object_get_tiling(obj)) {
@@ -140,9 +135,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
 	struct i915_vma *vma;
 	int pin_count = 0;
 
-	seq_printf(m, "%pK: %c%c%c%c %8zdKiB %02x %02x %s%s%s",
+	seq_printf(m, "%pK: %c%c%c %8zdKiB %02x %02x %s%s%s",
 		   &obj->base,
-		   get_pin_flag(obj),
 		   get_tiling_flag(obj),
 		   get_global_flag(obj),
 		   get_pin_mapped_flag(obj),
@@ -221,8 +215,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
 	seq_printf(m, " (pinned x %d)", pin_count);
 	if (obj->stolen)
 		seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
-	if (obj->pin_global)
-		seq_printf(m, " (global)");
+	if (i915_gem_object_is_framebuffer(obj))
+		seq_printf(m, " (fb)");
 
 	engine = i915_gem_object_last_write_engine(obj);
 	if (engine)
-- 
2.23.0

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

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

* ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3)
  2019-08-23 16:20 [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer Chris Wilson
                   ` (3 preceding siblings ...)
  2019-08-23 17:11 ` Chris Wilson
@ 2019-08-23 20:12 ` Patchwork
  2019-08-23 21:05 ` ✓ Fi.CI.BAT: success " Patchwork
  2019-08-25  0:22 ` ✓ Fi.CI.IGT: " Patchwork
  6 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2019-08-23 20:12 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3)
URL   : https://patchwork.freedesktop.org/series/65710/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
280c38d6b493 drm/i915: Replace obj->pin_global with obj->frontbuffer
-:23: WARNING:TYPO_SPELLING: 'frambuffer' may be misspelled - perhaps 'framebuffer'?
#23: 
set for as long as an intel_frambuffer is attached to an object, but

-:242: WARNING:PREFER_SEQ_PUTS: Prefer seq_puts to seq_printf
#242: FILE: drivers/gpu/drm/i915/i915_debugfs.c:219:
+		seq_printf(m, " (fb)");

total: 0 errors, 2 warnings, 0 checks, 171 lines checked

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

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

* ✓ Fi.CI.BAT: success for drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3)
  2019-08-23 16:20 [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer Chris Wilson
                   ` (4 preceding siblings ...)
  2019-08-23 20:12 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3) Patchwork
@ 2019-08-23 21:05 ` Patchwork
  2019-08-25  0:22 ` ✓ Fi.CI.IGT: " Patchwork
  6 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2019-08-23 21:05 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3)
URL   : https://patchwork.freedesktop.org/series/65710/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6779 -> Patchwork_14174
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/

Known issues
------------

  Here are the changes found in Patchwork_14174 that come from known issues:

### IGT changes ###

#### Possible fixes ####

  * igt@gem_exec_suspend@basic-s3:
    - fi-blb-e6850:       [INCOMPLETE][1] ([fdo#107718]) -> [PASS][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html

  * igt@i915_module_load@reload-no-display:
    - {fi-icl-u4}:        [DMESG-WARN][3] ([fdo#105602]) -> [PASS][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/fi-icl-u4/igt@i915_module_load@reload-no-display.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/fi-icl-u4/igt@i915_module_load@reload-no-display.html

  * igt@kms_chamelium@dp-edid-read:
    - fi-cml-u2:          [FAIL][5] ([fdo#109483]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/fi-cml-u2/igt@kms_chamelium@dp-edid-read.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/fi-cml-u2/igt@kms_chamelium@dp-edid-read.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-icl-u2:          [FAIL][7] ([fdo#103167]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/fi-icl-u2/igt@kms_frontbuffer_tracking@basic.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/fi-icl-u2/igt@kms_frontbuffer_tracking@basic.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#109483]: https://bugs.freedesktop.org/show_bug.cgi?id=109483
  [fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045


Participating hosts (54 -> 45)
------------------------------

  Additional (1): fi-bxt-dsi 
  Missing    (10): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-j1900 fi-byt-squawks fi-bsw-cyan fi-gdg-551 fi-icl-y fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6779 -> Patchwork_14174

  CI-20190529: 20190529
  CI_DRM_6779: 96b21ba1b7912952fef64efcaa6ee1e4c4182b92 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5149: 6756ede680ee12745393360d7cc87cc0eb733ff6 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_14174: 280c38d6b493288dd258fba95d4997e7e7fe7569 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

280c38d6b493 drm/i915: Replace obj->pin_global with obj->frontbuffer

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✓ Fi.CI.IGT: success for drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3)
  2019-08-23 16:20 [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer Chris Wilson
                   ` (5 preceding siblings ...)
  2019-08-23 21:05 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-08-25  0:22 ` Patchwork
  6 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2019-08-25  0:22 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3)
URL   : https://patchwork.freedesktop.org/series/65710/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6779_full -> Patchwork_14174_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Known issues
------------

  Here are the changes found in Patchwork_14174_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_isolation@bcs0-s3:
    - shard-skl:          [PASS][1] -> [INCOMPLETE][2] ([fdo#104108])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-skl2/igt@gem_ctx_isolation@bcs0-s3.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-skl9/igt@gem_ctx_isolation@bcs0-s3.html

  * igt@gem_exec_balancer@smoke:
    - shard-iclb:         [PASS][3] -> [SKIP][4] ([fdo#110854])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb2/igt@gem_exec_balancer@smoke.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb3/igt@gem_exec_balancer@smoke.html

  * igt@gem_exec_schedule@preempt-other-chain-bsd:
    - shard-iclb:         [PASS][5] -> [SKIP][6] ([fdo#111325]) +5 similar issues
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb6/igt@gem_exec_schedule@preempt-other-chain-bsd.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb2/igt@gem_exec_schedule@preempt-other-chain-bsd.html

  * igt@i915_suspend@fence-restore-tiled2untiled:
    - shard-apl:          [PASS][7] -> [DMESG-WARN][8] ([fdo#108566]) +4 similar issues
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-apl5/igt@i915_suspend@fence-restore-tiled2untiled.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-apl1/igt@i915_suspend@fence-restore-tiled2untiled.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
    - shard-skl:          [PASS][9] -> [INCOMPLETE][10] ([fdo#110741])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-skl6/igt@kms_cursor_crc@pipe-a-cursor-suspend.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-skl4/igt@kms_cursor_crc@pipe-a-cursor-suspend.html

  * igt@kms_cursor_legacy@cursor-vs-flip-toggle:
    - shard-hsw:          [PASS][11] -> [FAIL][12] ([fdo#103355])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-hsw6/igt@kms_cursor_legacy@cursor-vs-flip-toggle.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-hsw6/igt@kms_cursor_legacy@cursor-vs-flip-toggle.html

  * igt@kms_flip@flip-vs-expired-vblank:
    - shard-skl:          [PASS][13] -> [FAIL][14] ([fdo#105363])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-skl6/igt@kms_flip@flip-vs-expired-vblank.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-skl1/igt@kms_flip@flip-vs-expired-vblank.html

  * igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-pwrite:
    - shard-iclb:         [PASS][15] -> [FAIL][16] ([fdo#103167]) +4 similar issues
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb7/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-pwrite.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb5/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-pwrite.html

  * igt@kms_psr@psr2_primary_page_flip:
    - shard-iclb:         [PASS][17] -> [SKIP][18] ([fdo#109441]) +3 similar issues
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb2/igt@kms_psr@psr2_primary_page_flip.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb1/igt@kms_psr@psr2_primary_page_flip.html

  * igt@prime_vgem@fence-wait-bsd2:
    - shard-iclb:         [PASS][19] -> [SKIP][20] ([fdo#109276]) +20 similar issues
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb1/igt@prime_vgem@fence-wait-bsd2.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb7/igt@prime_vgem@fence-wait-bsd2.html

  * igt@tools_test@tools_test:
    - shard-glk:          [PASS][21] -> [SKIP][22] ([fdo#109271])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-glk7/igt@tools_test@tools_test.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-glk6/igt@tools_test@tools_test.html
    - shard-hsw:          [PASS][23] -> [SKIP][24] ([fdo#109271])
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-hsw1/igt@tools_test@tools_test.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-hsw1/igt@tools_test@tools_test.html

  
#### Possible fixes ####

  * igt@gem_exec_schedule@independent-bsd2:
    - shard-iclb:         [SKIP][25] ([fdo#109276]) -> [PASS][26] +18 similar issues
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb3/igt@gem_exec_schedule@independent-bsd2.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb1/igt@gem_exec_schedule@independent-bsd2.html

  * igt@gem_exec_schedule@preempt-contexts-bsd:
    - shard-iclb:         [SKIP][27] ([fdo#111325]) -> [PASS][28] +2 similar issues
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb2/igt@gem_exec_schedule@preempt-contexts-bsd.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb3/igt@gem_exec_schedule@preempt-contexts-bsd.html

  * igt@gem_exec_suspend@basic-s3:
    - shard-skl:          [INCOMPLETE][29] ([fdo#104108]) -> [PASS][30]
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-skl2/igt@gem_exec_suspend@basic-s3.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-skl9/igt@gem_exec_suspend@basic-s3.html

  * {igt@gem_userptr_blits@stress-purge}:
    - shard-apl:          [INCOMPLETE][31] ([fdo#103927]) -> [PASS][32] +1 similar issue
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-apl6/igt@gem_userptr_blits@stress-purge.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-apl1/igt@gem_userptr_blits@stress-purge.html

  * igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic:
    - shard-snb:          [SKIP][33] ([fdo#109271]) -> [PASS][34]
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-snb2/igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-snb7/igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic.html

  * igt@kms_flip@flip-vs-expired-vblank:
    - shard-snb:          [FAIL][35] ([fdo#105363]) -> [PASS][36]
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-snb2/igt@kms_flip@flip-vs-expired-vblank.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-snb1/igt@kms_flip@flip-vs-expired-vblank.html

  * igt@kms_flip@flip-vs-expired-vblank-interruptible:
    - shard-skl:          [FAIL][37] ([fdo#105363]) -> [PASS][38]
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-skl6/igt@kms_flip@flip-vs-expired-vblank-interruptible.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-skl4/igt@kms_flip@flip-vs-expired-vblank-interruptible.html

  * igt@kms_frontbuffer_tracking@fbc-1p-pri-indfb-multidraw:
    - shard-iclb:         [FAIL][39] ([fdo#103167]) -> [PASS][40] +3 similar issues
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb6/igt@kms_frontbuffer_tracking@fbc-1p-pri-indfb-multidraw.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb6/igt@kms_frontbuffer_tracking@fbc-1p-pri-indfb-multidraw.html

  * igt@kms_frontbuffer_tracking@fbc-suspend:
    - shard-apl:          [DMESG-WARN][41] ([fdo#108566]) -> [PASS][42] +3 similar issues
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-apl5/igt@kms_frontbuffer_tracking@fbc-suspend.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-apl1/igt@kms_frontbuffer_tracking@fbc-suspend.html

  * igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-mmap-gtt:
    - shard-skl:          [FAIL][43] ([fdo#103167] / [fdo#110379]) -> [PASS][44]
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-skl1/igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-mmap-gtt.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-skl2/igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-mmap-gtt.html

  * igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
    - shard-skl:          [FAIL][45] ([fdo#108145]) -> [PASS][46]
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-skl9/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-skl8/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html

  * igt@kms_psr2_su@page_flip:
    - shard-iclb:         [SKIP][47] ([fdo#109642] / [fdo#111068]) -> [PASS][48]
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb5/igt@kms_psr2_su@page_flip.html
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb2/igt@kms_psr2_su@page_flip.html

  * igt@kms_psr@psr2_primary_mmap_cpu:
    - shard-iclb:         [SKIP][49] ([fdo#109441]) -> [PASS][50] +1 similar issue
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-iclb8/igt@kms_psr@psr2_primary_mmap_cpu.html
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html

  * igt@kms_setmode@basic:
    - shard-apl:          [FAIL][51] ([fdo#99912]) -> [PASS][52]
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-apl4/igt@kms_setmode@basic.html
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-apl3/igt@kms_setmode@basic.html

  
#### Warnings ####

  * igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-fullscreen:
    - shard-skl:          [FAIL][53] ([fdo#103167]) -> [FAIL][54] ([fdo#108040])
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6779/shard-skl1/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-fullscreen.html
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/shard-skl2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-fullscreen.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103355]: https://bugs.freedesktop.org/show_bug.cgi?id=103355
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
  [fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
  [fdo#108040]: https://bugs.freedesktop.org/show_bug.cgi?id=108040
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
  [fdo#110379]: https://bugs.freedesktop.org/show_bug.cgi?id=110379
  [fdo#110741]: https://bugs.freedesktop.org/show_bug.cgi?id=110741
  [fdo#110854]: https://bugs.freedesktop.org/show_bug.cgi?id=110854
  [fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
  [fdo#111325]: https://bugs.freedesktop.org/show_bug.cgi?id=111325
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912


Participating hosts (9 -> 9)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6779 -> Patchwork_14174

  CI-20190529: 20190529
  CI_DRM_6779: 96b21ba1b7912952fef64efcaa6ee1e4c4182b92 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5149: 6756ede680ee12745393360d7cc87cc0eb733ff6 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_14174: 280c38d6b493288dd258fba95d4997e7e7fe7569 @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14174/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer
  2019-08-23 17:11 ` Chris Wilson
@ 2019-09-02 11:50   ` Ville Syrjälä
  0 siblings, 0 replies; 10+ messages in thread
From: Ville Syrjälä @ 2019-09-02 11:50 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Fri, Aug 23, 2019 at 06:11:26PM +0100, Chris Wilson wrote:
> obj->pin_global was original used as a means to keep the shrinker off
> the active scanout, but we use the vma->pin_count itself for that and
> the obj->frontbuffer to delay shrinking active framebuffers. The other
> role that obj->pin_global gained was for spotting display objects inside
> GEM and working harder to keep those coherent; for which we can again
> simply inspect obj->frontbuffer directly.
> 
> Coming up next, we will want to manipulate the pin_global counter
> outside of the principle locks, so would need to make pin_global atomic.
> However, since obj->frontbuffer is already managed atomically, it makes
> sense to use that the primary key for display objects instead of having
> pin_global.
> 
> Ville pointed out the principle difference is that obj->frontbuffer is
> set for as long as an intel_frambuffer is attached to an object, but
> obj->pin_global was only raised for as long as the object was active. In
> practice, this means that we consider the object as being on the scanout
> for longer than is strictly required, causing us to be more proactive in
> flushing -- though it should be true that we would have flushed
> eventually when the back became the front, except that on the flip path
> that flush is aync but when hit from another ioctl it will be
> synchronous.
> 
> v2: i915_gem_object_is_framebuffer()
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

> ---
>  .../gpu/drm/i915/display/intel_frontbuffer.c  | 13 +++++--
>  drivers/gpu/drm/i915/gem/i915_gem_domain.c    | 34 ++++++-------------
>  drivers/gpu/drm/i915/gem/i915_gem_object.h    |  3 +-
>  .../gpu/drm/i915/gem/i915_gem_object_types.h  |  2 --
>  drivers/gpu/drm/i915/gem/i915_gem_shrinker.c  | 15 +++-----
>  drivers/gpu/drm/i915/i915_debugfs.c           | 12 ++-----
>  6 files changed, 29 insertions(+), 50 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> index 719379774fa5..fc40dc1fdbcc 100644
> --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
> @@ -220,11 +220,18 @@ static void frontbuffer_release(struct kref *ref)
>  {
>  	struct intel_frontbuffer *front =
>  		container_of(ref, typeof(*front), ref);
> +	struct drm_i915_gem_object *obj = front->obj;
> +	struct i915_vma *vma;
>  
> -	front->obj->frontbuffer = NULL;
> -	spin_unlock(&to_i915(front->obj->base.dev)->fb_tracking.lock);
> +	spin_lock(&obj->vma.lock);
> +	for_each_ggtt_vma(vma, obj)
> +		vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
> +	spin_unlock(&obj->vma.lock);
>  
> -	i915_gem_object_put(front->obj);
> +	obj->frontbuffer = NULL;
> +	spin_unlock(&to_i915(obj->base.dev)->fb_tracking.lock);
> +
> +	i915_gem_object_put(obj);
>  	kfree(front);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> index 9c58e8fac1d9..6af740a5e3db 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> @@ -27,7 +27,7 @@ static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)
>  
>  void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj)
>  {
> -	if (!READ_ONCE(obj->pin_global))
> +	if (!i915_gem_object_is_framebuffer(obj))
>  		return;
>  
>  	i915_gem_object_lock(obj);
> @@ -422,12 +422,8 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
>  
>  	assert_object_held(obj);
>  
> -	/* Mark the global pin early so that we account for the
> -	 * display coherency whilst setting up the cache domains.
> -	 */
> -	obj->pin_global++;
> -
> -	/* The display engine is not coherent with the LLC cache on gen6.  As
> +	/*
> +	 * The display engine is not coherent with the LLC cache on gen6.  As
>  	 * a result, we make sure that the pinning that is about to occur is
>  	 * done with uncached PTEs. This is lowest common denominator for all
>  	 * chipsets.
> @@ -439,12 +435,11 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
>  	ret = i915_gem_object_set_cache_level(obj,
>  					      HAS_WT(to_i915(obj->base.dev)) ?
>  					      I915_CACHE_WT : I915_CACHE_NONE);
> -	if (ret) {
> -		vma = ERR_PTR(ret);
> -		goto err_unpin_global;
> -	}
> +	if (ret)
> +		return ERR_PTR(ret);
>  
> -	/* As the user may map the buffer once pinned in the display plane
> +	/*
> +	 * As the user may map the buffer once pinned in the display plane
>  	 * (e.g. libkms for the bootup splash), we have to ensure that we
>  	 * always use map_and_fenceable for all scanout buffers. However,
>  	 * it may simply be too big to fit into mappable, in which case
> @@ -461,22 +456,19 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
>  	if (IS_ERR(vma))
>  		vma = i915_gem_object_ggtt_pin(obj, view, 0, alignment, flags);
>  	if (IS_ERR(vma))
> -		goto err_unpin_global;
> +		return vma;
>  
>  	vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
>  
>  	__i915_gem_object_flush_for_display(obj);
>  
> -	/* It should now be out of any other write domains, and we can update
> +	/*
> +	 * It should now be out of any other write domains, and we can update
>  	 * the domain values for our changes.
>  	 */
>  	obj->read_domains |= I915_GEM_DOMAIN_GTT;
>  
>  	return vma;
> -
> -err_unpin_global:
> -	obj->pin_global--;
> -	return vma;
>  }
>  
>  static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
> @@ -514,12 +506,6 @@ i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
>  
>  	assert_object_held(obj);
>  
> -	if (WARN_ON(obj->pin_global == 0))
> -		return;
> -
> -	if (--obj->pin_global == 0)
> -		vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
> -
>  	/* Bump the LRU to try and avoid premature eviction whilst flipping  */
>  	i915_gem_object_bump_inactive_ggtt(obj);
>  
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> index 5efb9936e05b..29b9eddc4c7f 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> @@ -406,7 +406,8 @@ static inline bool cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
>  	if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
>  		return true;
>  
> -	return obj->pin_global; /* currently in use by HW, keep flushed */
> +	/* Currently in use by HW (display engine)? Keep flushed. */
> +	return i915_gem_object_is_framebuffer(obj);
>  }
>  
>  static inline void __start_cpu_write(struct drm_i915_gem_object *obj)
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> index ede0eb4218a8..13b9dc0e1a89 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> @@ -152,8 +152,6 @@ struct drm_i915_gem_object {
>  
>  	/** Count of VMA actually bound by this object */
>  	atomic_t bind_count;
> -	/** Count of how many global VMA are currently pinned for use by HW */
> -	unsigned int pin_global;
>  
>  	struct {
>  		struct mutex lock; /* protects the pages and their use */
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> index edd21d14e64f..4e55cfc2b0dc 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> @@ -61,7 +61,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
>  	if (!i915_gem_object_is_shrinkable(obj))
>  		return false;
>  
> -	/* Only report true if by unbinding the object and putting its pages
> +	/*
> +	 * Only report true if by unbinding the object and putting its pages
>  	 * we can actually make forward progress towards freeing physical
>  	 * pages.
>  	 *
> @@ -72,16 +73,8 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)
>  	if (atomic_read(&obj->mm.pages_pin_count) > atomic_read(&obj->bind_count))
>  		return false;
>  
> -	/* If any vma are "permanently" pinned, it will prevent us from
> -	 * reclaiming the obj->mm.pages. We only allow scanout objects to claim
> -	 * a permanent pin, along with a few others like the context objects.
> -	 * To simplify the scan, and to avoid walking the list of vma under the
> -	 * object, we just check the count of its permanently pinned.
> -	 */
> -	if (READ_ONCE(obj->pin_global))
> -		return false;
> -
> -	/* We can only return physical pages to the system if we can either
> +	/*
> +	 * We can only return physical pages to the system if we can either
>  	 * discard the contents (because the user has marked them as being
>  	 * purgeable) or if we can move their contents out to swap.
>  	 */
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index e103fcba6435..4aa7caa3aa28 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -77,11 +77,6 @@ static int i915_capabilities(struct seq_file *m, void *data)
>  	return 0;
>  }
>  
> -static char get_pin_flag(struct drm_i915_gem_object *obj)
> -{
> -	return obj->pin_global ? 'p' : ' ';
> -}
> -
>  static char get_tiling_flag(struct drm_i915_gem_object *obj)
>  {
>  	switch (i915_gem_object_get_tiling(obj)) {
> @@ -140,9 +135,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
>  	struct i915_vma *vma;
>  	int pin_count = 0;
>  
> -	seq_printf(m, "%pK: %c%c%c%c %8zdKiB %02x %02x %s%s%s",
> +	seq_printf(m, "%pK: %c%c%c %8zdKiB %02x %02x %s%s%s",
>  		   &obj->base,
> -		   get_pin_flag(obj),
>  		   get_tiling_flag(obj),
>  		   get_global_flag(obj),
>  		   get_pin_mapped_flag(obj),
> @@ -221,8 +215,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
>  	seq_printf(m, " (pinned x %d)", pin_count);
>  	if (obj->stolen)
>  		seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
> -	if (obj->pin_global)
> -		seq_printf(m, " (global)");
> +	if (i915_gem_object_is_framebuffer(obj))
> +		seq_printf(m, " (fb)");
>  
>  	engine = i915_gem_object_last_write_engine(obj);
>  	if (engine)
> -- 
> 2.23.0

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

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

end of thread, other threads:[~2019-09-02 11:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-23 16:20 [PATCH] drm/i915: Replace obj->pin_global with obj->frontbuffer Chris Wilson
2019-08-23 16:38 ` Chris Wilson
2019-08-23 16:39 ` Chris Wilson
2019-08-23 16:48 ` Ville Syrjälä
2019-08-23 17:03   ` Chris Wilson
2019-08-23 17:11 ` Chris Wilson
2019-09-02 11:50   ` Ville Syrjälä
2019-08-23 20:12 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Replace obj->pin_global with obj->frontbuffer (rev3) Patchwork
2019-08-23 21:05 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-25  0:22 ` ✓ Fi.CI.IGT: " Patchwork

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.