[Intel-gfx] [PATCH] drm/i915: move objects to the GTT domain at fault time

Jesse Barnes jbarnes at virtuousgeek.org
Wed Jun 17 22:30:04 CEST 2009


Chris pointed out that Kristian's fix to move faulted objects into the
GTT domain wouldn't work if the object was still bound, but in another
domain.

So move the domain transition to just before the vm_insert_pfn to make
sure the domain is always correct when the user is about to access the
object.  We might want to add a check to the GTT domain transition
function to avoid unnecessary flushes in the event the object is
already there.

Reported-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>


diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index c0ae6bb..6cbefe2 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1146,12 +1146,6 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 			return VM_FAULT_SIGBUS;
 		}
 
-		ret = i915_gem_object_set_to_gtt_domain(obj, write);
-		if (ret) {
-			mutex_unlock(&dev->struct_mutex);
-			return VM_FAULT_SIGBUS;
-		}
-
 		list_add_tail(&obj_priv->list, &dev_priv->mm.inactive_list);
 	}
 
@@ -1168,6 +1162,16 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	pfn = ((dev->agp->base + obj_priv->gtt_offset) >> PAGE_SHIFT) +
 		page_offset;
 
+	/*
+	 * Make sure everything is flushed out to the GTT domain, since
+	 * that's how the caller will be accessing it.
+	 */
+	ret = i915_gem_object_set_to_gtt_domain(obj, write);
+	if (ret) {
+		mutex_unlock(&dev->struct_mutex);
+		return VM_FAULT_SIGBUS;
+	}
+
 	/* Finally, remap it using the new GTT offset */
 	ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn);
 



More information about the Intel-gfx mailing list