drm/i915: move vma sanity checking into i915_vma_bind
authorMatthew Auld <matthew.auld@intel.com>
Tue, 13 Dec 2016 20:32:20 +0000 (20:32 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 16 Dec 2016 21:17:22 +0000 (21:17 +0000)
If we move the sanity checking from gen8_alloc_va_range_3lvl and
gen6_alloc_va_range into i915_vma_bind, we will increase our coverage to
now both callbacks. We also convert each WARN_ON over to a GEM_WARN_ON.

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213203222.32564-2-matthew.auld@intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_vma.c

index ef00d36680c97f1379437dc207789a60d98a553a..4f405b445b6c3c630ee4a42c80052bfe61ec631a 100644 (file)
@@ -1303,15 +1303,6 @@ static int gen8_alloc_va_range_3lvl(struct i915_address_space *vm,
        uint32_t pdpes = I915_PDPES_PER_PDP(dev_priv);
        int ret;
 
-       /* Wrap is never okay since we can only represent 48b, and we don't
-        * actually use the other side of the canonical address space.
-        */
-       if (WARN_ON(start + length < start))
-               return -ENODEV;
-
-       if (WARN_ON(start + length > vm->total))
-               return -ENODEV;
-
        ret = alloc_gen8_temp_bitmaps(&new_page_dirs, &new_page_tables, pdpes);
        if (ret)
                return ret;
@@ -1929,9 +1920,6 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
        uint32_t pde;
        int ret;
 
-       if (WARN_ON(start_in + length_in > ppgtt->base.total))
-               return -ENODEV;
-
        start = start_save = start_in;
        length = length_save = length_in;
 
index 37c3eebe8316a7c249e14396f90709a099222ebc..9e121222c5ebfeb007c45a70f68617dd1e78e531 100644 (file)
@@ -176,6 +176,12 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
        if (bind_flags == 0)
                return 0;
 
+       if (GEM_WARN_ON(vma->node.start + vma->node.size < vma->node.start))
+               return -ENODEV;
+
+       if (GEM_WARN_ON(vma->node.start + vma->node.size > vma->vm->total))
+               return -ENODEV;
+
        if (vma_flags == 0 && vma->vm->allocate_va_range) {
                trace_i915_va_alloc(vma);
                ret = vma->vm->allocate_va_range(vma->vm,