[141/190] drm/i915: Choose not to evict faultable objects from the GGTT
diff mbox

Message ID 1452509174-16671-55-git-send-email-chris@chris-wilson.co.uk
State New
Headers show

Commit Message

Chris Wilson Jan. 11, 2016, 10:45 a.m. UTC
Often times we do not want to evict mapped objects from the GGTT as
these are quite expensive to teardown and frequently reused (causing an
equally, if not more so, expensive setup). In particular, when faulting
in a new object we want to avoid evicting an active object, or else we
may trigger a page-fault-of-doom as we ping-pong between evicting two
objects.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.h       | 7 ++++---
 drivers/gpu/drm/i915/i915_gem.c       | 4 +++-
 drivers/gpu/drm/i915/i915_gem_evict.c | 7 +++++--
 3 files changed, 12 insertions(+), 6 deletions(-)

Patch
diff mbox

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index bb0f750bb5b5..45b8cbdfab55 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2709,9 +2709,10 @@  i915_vma_pin(struct i915_vma *vma,
 #define PIN_MAPPABLE	(1<<3)
 #define PIN_ZONE_4G	(1<<4)
 #define PIN_NONBLOCK	(1<<5)
-#define PIN_HIGH	(1<<6)
-#define PIN_OFFSET_BIAS	(1<<7)
-#define PIN_OFFSET_FIXED (1<<8)
+#define PIN_NOFAULT	(1<<6)
+#define PIN_HIGH	(1<<7)
+#define PIN_OFFSET_BIAS	(1<<8)
+#define PIN_OFFSET_FIXED (1<<9)
 #define PIN_OFFSET_MASK (~4095)
 
 static inline void __i915_vma_unpin(struct i915_vma *vma)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index a8f4d4633bdb..60dfee56f6ef 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1483,7 +1483,9 @@  int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	/* Use a partial view if the object is bigger than the aperture. */
 	/* Now pin it into the GTT if needed */
 	ggtt = i915_gem_object_ggtt_pin(obj, NULL, 0, 0,
-					PIN_MAPPABLE | PIN_NONBLOCK);
+					PIN_MAPPABLE |
+					PIN_NONBLOCK |
+					PIN_NOFAULT);
 	if (IS_ERR(ggtt)) {
 		static const unsigned int chunk_size = 256; // 1 MiB
 		struct i915_ggtt_view partial;
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index 679b7dd3a312..fdc4941be15a 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -64,7 +64,7 @@  static int switch_to_pinned_context(struct drm_i915_private *dev_priv)
 }
 
 static bool
-mark_free(struct i915_vma *vma, struct list_head *unwind)
+mark_free(struct i915_vma *vma, unsigned flags, struct list_head *unwind)
 {
 	if (vma->pin_count)
 		return false;
@@ -72,6 +72,9 @@  mark_free(struct i915_vma *vma, struct list_head *unwind)
 	if (WARN_ON(!list_empty(&vma->exec_list)))
 		return false;
 
+	if (flags & PIN_NOFAULT && vma->obj->fault_mappable)
+		return false;
+
 	list_add(&vma->exec_list, unwind);
 	return drm_mm_scan_add_block(&vma->node);
 }
@@ -146,7 +149,7 @@  search_again:
 	phase = phases;
 	do {
 		list_for_each_entry(vma, *phase, vm_link)
-			if (mark_free(vma, &eviction_list))
+			if (mark_free(vma, flags, &eviction_list))
 				goto found;
 	} while (*++phase);