Skip to contentSkip to conversation

drm/i915: do not clear mappings beyond VMA size

PATCH In review Joonas Lahtinen 2 participants 2 messages Apr 17, 2015

Subsystems (2)
lore
Share & tools
lore

Joonas Lahtinen

author maintainer
#0 lore raw

PATCH 1/2 drm/i915: do not clear mappings beyond VMA size

Do not to clear mappings outside the allocated VMA under any circumstances. Only clear the smaller of VMA or object page count.

This is required to allow creating partial object VMAs which in turn are needed for partial GGTT views.

---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +18 -4
index 9041f3d..18c695b 100644
@@ -1730,9 +1730,14 @@ ppgtt_bind_vma(struct i915_vma *vma,
 
 static void ppgtt_unbind_vma(struct i915_vma *vma)
 {
+	struct drm_i915_gem_object *obj = vma->obj;
+	const uint64_t size = min_t(uint64_t,
+				    obj->base.size,
+				    vma->node.size);
+
 	vma->vm->clear_range(vma->vm,
 			     vma->node.start,
-			     vma->obj->base.size,
+			     size,
 			     true);
 }
 
@@ -2078,8 +2083,11 @@ static void i915_ggtt_clear_range(struct i915_address_space *vm,
 
 static void i915_ggtt_unbind_vma(struct i915_vma *vma)
 {
+	struct drm_i915_gem_object *obj = vma->obj;
 	const unsigned int first = vma->node.start >> PAGE_SHIFT;
-	const unsigned int size = vma->obj->base.size >> PAGE_SHIFT;
+	const unsigned int size = min_t(uint64_t,
+					obj->base.size,
+					vma->node.size) >> PAGE_SHIFT;
 
 	BUG_ON(!i915_is_ggtt(vma->vm));
 	vma->bound = 0;
@@ -2139,21 +2147,27 @@ static void ggtt_unbind_vma(struct i915_vma *vma)
 	struct drm_device *dev = vma->vm->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_object *obj = vma->obj;
+	const uint64_t size = min_t(uint64_t,
+				    obj->base.size,
+				    vma->node.size);
 
 	if (vma->bound & GLOBAL_BIND) {
 		vma->vm->clear_range(vma->vm,
 				     vma->node.start,
-				     obj->base.size,
+				     size,
 				     true);
+
 		vma->bound &= ~GLOBAL_BIND;
 	}
 
 	if (vma->bound & LOCAL_BIND) {
 		struct i915_hw_ppgtt *appgtt = dev_priv->mm.aliasing_ppgtt;
+
 		appgtt->base.clear_range(&appgtt->base,
 					 vma->node.start,
-					 obj->base.size,
+					 size,
 					 true);
+
 		vma->bound &= ~LOCAL_BIND;
 	}
 }
Signature · 8 lines
1.9.3



_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 5 lines · Joonas Lahtinen

Do not to clear mappings outside the allocated VMA under any circumstances. Only clear the smaller of VMA or object page count.

This is required to allow creating partial object VMAs which in turn are needed for partial GGTT views.

This doesn't fix a current bug so it doesn't need to be sent ahead of the partial views.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx