@@ -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;
}
}
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. Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> --- drivers/gpu/drm/i915/i915_gem_gtt.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)