[PATCH 109/124] drm/i915: Limit rpm wakeref for freeing objects

Chris Wilson chris at chris-wilson.co.uk
Mon Sep 10 21:43:29 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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 855fed7a97b1..0f5277cf74bf 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4330,11 +4330,10 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 				    struct llist_node *freed)
 {
 	struct drm_i915_gem_object *obj, *on;
-	intel_wakeref_t wakeref;
 
-	wakeref = intel_runtime_pm_get(i915);
 	llist_for_each_entry_safe(obj, on, freed, freed) {
 		struct i915_vma *vma, *vn;
+		intel_wakeref_t wakeref = 0;
 
 		trace_i915_gem_object_destroy(obj);
 
@@ -4343,14 +4342,19 @@ 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))
+				wakeref = intel_runtime_pm_get(i915);
 			GEM_BUG_ON(i915_vma_is_active(vma));
 			vma->flags &= ~I915_VMA_PIN_MASK;
 			i915_vma_destroy(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, wakeref);
 
-		/* 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
@@ -4393,7 +4397,6 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 		if (on)
 			cond_resched();
 	}
-	intel_runtime_pm_put(i915, wakeref);
 }
 
 static void i915_gem_flush_free_objects(struct drm_i915_private *i915)
-- 
2.19.0.rc2



More information about the Intel-gfx-trybot mailing list