[Intel-gfx] [PATCH 101/190] drm/i915: Only retire if necessary when creating a userptr

Chris Wilson chris at chris-wilson.co.uk
Mon Jan 11 02:44:45 PST 2016


We only want to retire requests if we have an existing object that
conflicts with the fresh userptr range in order to avoid unnecessary
work during creation of every userptr.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index a90392246471..2f922392bd10 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -187,17 +187,23 @@ i915_mmu_notifier_add(struct drm_device *dev,
 	 * using an interrupt timer is likely to get stuck in an EINTR loop).
 	 */
 	mutex_lock(&dev->struct_mutex);
-
-	/* Make sure we drop the final active reference (and thereby
-	 * remove the objects from the interval tree) before we do
-	 * the check for overlapping objects.
-	 */
-	i915_gem_retire_requests(dev);
-
 	spin_lock(&mn->lock);
 	it = interval_tree_iter_first(&mn->objects,
 				      mo->it.start, mo->it.last);
 	if (it) {
+		spin_unlock(&mn->lock);
+
+		/* Make sure we drop the final active reference (and thereby
+		 * remove the objects from the interval tree) before we do
+		 * the check for overlapping objects.
+		 */
+		i915_gem_retire_requests(dev);
+
+		spin_lock(&mn->lock);
+		it = interval_tree_iter_first(&mn->objects,
+					      mo->it.start, mo->it.last);
+	}
+	if (it) {
 		struct drm_i915_gem_object *obj;
 
 		/* We only need to check the first object in the range as it
-- 
2.7.0.rc3



More information about the Intel-gfx mailing list