[PATCH 30/48] drm/i915: Limit rpm wakeref for freeing objects

Chris Wilson chris at chris-wilson.co.uk
Fri Jan 19 22:58:46 UTC 2018


If we wake up only to free the objects, we do not immediately wake up
the device for a potentially long operation that may not require
interacting with the device at all. Only if we need to unbind the object
from the GGTT do we require the device to be awake, so defer waking the
device until then.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 46f014afc6d3..7cac06a3765c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4685,9 +4685,9 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 {
 	struct drm_i915_gem_object *obj, *on;
 
-	intel_runtime_pm_get(i915);
 	llist_for_each_entry_safe(obj, on, freed, freed) {
 		struct i915_vma *vma, *vn;
+		bool wakeref = false;
 
 		trace_i915_gem_object_destroy(obj);
 
@@ -4696,14 +4696,21 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 		GEM_BUG_ON(i915_gem_object_is_active(obj));
 		list_for_each_entry_safe(vma, vn,
 					 &obj->vma_list, obj_link) {
+			if (!wakeref && i915_vma_is_ggtt(vma)) {
+				intel_runtime_pm_get(i915);
+				wakeref = true;
+			}
 			GEM_BUG_ON(i915_vma_is_active(vma));
 			vma->flags &= ~I915_VMA_PIN_MASK;
 			i915_vma_close(vma);
 		}
 		GEM_BUG_ON(!list_empty(&obj->vma_list));
 		GEM_BUG_ON(!RB_EMPTY_ROOT(&obj->vma_tree));
+		if (wakeref)
+			intel_runtime_pm_put(i915);
 
-		/* This serializes freeing with the shrinker. Since the free
+		/*
+		 * This serializes freeing with the shrinker. Since the free
 		 * is delayed, first by RCU then by the workqueue, we want the
 		 * shrinker to be able to free pages of unreferenced objects,
 		 * or else we may oom whilst there are plenty of deferred
@@ -4743,7 +4750,6 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 		if (on)
 			cond_resched();
 	}
-	intel_runtime_pm_put(i915);
 }
 
 static void i915_gem_flush_free_objects(struct drm_i915_private *i915)
-- 
2.15.1



More information about the Intel-gfx-trybot mailing list